PocketMatrix forums

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

accessing the framebuffer

i'm accessing the back framebuffer directly and modify a pixel by the following code:

Code:


pixel_t *pDest=(pixel_t*)((byte*)buffer.pixels + ((x * sizeof(pixel_t)) + (y * buffer.pitch)));
*pDest=color;



the code works fine for my ipaq (both PocketFrog and PocketHal).

i always assumed that pitch is calculated as:

Code:


pitch=sizeof(pixel_t)*width;



but is this assumption correct? and will the code above still work for other devices?
Kzinti · 09 Dec 2003, 16:49 UTC — accessing the framebuffer
izeman wrote:
i always assumed that pitch is calculated as:

Code:

pitch=sizeof(pixel_t)*width;


but is this assumption correct? and will the code above still work for other devices?


No this is not correct. Some devices can have a pitch that is not equal to sizeof(pixel_t) * width. Otherwise there wouldn't be a reason to talk about the "pitch" at all.