PocketMatrix forums

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

Copying contents of memory buffer to backbuffer surface

Hello to anybody, who is reading this now. :D

I have a memory buffer of image in RGB565 format.
And I am curious, what is the fastest way to copy it to backbuffer surface?
I've watched example in post:

http://www.pocketmatrix.com/forums/view ... 906#278906

But I didn't liked it because it checks buffer format for every point it must copy.
Are there any other faser methods?
Maybe I can set backbuffer format at the start of application to avoid everypixel checking and use memcopy insted of for-cycle?

Regards, Nomad.
Hi Nomad,

You have 3 options to make it faster:

1. Use a quick function if the horizontal pitch and vertical pitch are the same as your buffer format (in your case xpitch needs to be 2 bytes, and ypitch width * 2 bytes). If the pitch values don't match, use a slow function.

2. Prerotate your own memory buffer to have the same orientation as the surface.

3. Create a low-level assembly function to copy the surface with rotation.
Hi, Edge.

Thanks for your reply.


Use a quick function if the horizontal pitch and vertical pitch are the same as your buffer format (in your case xpitch needs to be 2 bytes, and ypitch width * 2 bytes).

Is (xpitch == 2 && ypitch == width*2) true for EDGElib backbuffer on all devices, or there may be exceptions? If there may be exceptions, how often they can be?
Hi Nomad,

The pitches can be different because the color format isn't always in RGB565. Old Symbian devices may run in 16-bit RGB444 and new devices may run in 32-bit.

Usually the xpitch is the same as the size of each pixel. The exception to this rule are orientation changes in the EDGELIB configuration. Also some old IPaq devices have an odd landscape oriented framebuffer, while the screen is in portrait.