PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

GetBuffer() question

Hi,

If I write a class based on CGapiSurface, can I access the pixels directly using "m_surface.pSurface", or do I still need to call GetBuffer() beforehand?

I'm currently accessing the pixels directly without using GetBuffer() and it seems to work, but I want to make sure I'm doing the right thing.

Thanks!

--Eric
Yes, you definitely need to call GetBuffer(). Do not access m_surface.pSurface directly. :)

The reason is that pSurface always points to buffer memory pointer (and is renamed to pBuffer in GD 1.1), and not pixel origo. On stationary PCs these two addresses are the same, on most Pocket PCs they are not. Also, you do not know the pixel format of the surface unless you call GetBuffer() - it can be 555 or 565.

Use GetBuffer() and you will always receive the correct buffer pointer.
Whoa... Thanks!

Just as a note, I'm using an iPaq 3850, and I never called GetBuffer() in any classes derived from CGapiSurface, and I never had a single problem.

I suspect that some other devices might not be as forgiving...

--Eric