Best way to reverse bitmap data that is upside down

Posted by Wladimir on Stack Overflow See other posts from Stack Overflow or by Wladimir
Published on 2010-03-22T07:56:55Z Indexed on 2010/03/22 8:01 UTC
Read the original article Hit count: 273

Filed under:
|

Hello, I have a method that I call and it returns bitmap data from a capture device.

It returns a pointer to the buffer data as an IntPtr and the buffer length as an int.

I know in advance that this bitmap is a 24bpp and its width and height.

The problem is that the buffer contains the bitmap data upside down and I need this data to be in the right order (reverse it).

What I do is create a for loop and using CopyMemory, I copy each line (stride) of this data from bottom to up to a newly allocated memory space.

Is there any way to make it faster than creating more memory each time I receive a new frame? It makes the application get a bit slow and consumes more memory as each bitmap is pretty big.

I do this because I use another component that analyses the bitmaps and it doesn't work propertly if the bitmaps are upside down.

I'm using .net, c# thanks!

© Stack Overflow or respective owner

Related posts about c#

Related posts about bitmap