Copy pixel data from System.Drawing.Bitmap

  • Thread starter Thread starter Dennis Myrén
  • Start date Start date
D

Dennis Myrén

Hi.

I use System.Drawing.Bitmap to copy bitmap pixel data.
I use LockBits to retrieve a BitmapData which in turn provides me with the
Scan0 property which i then use to loop the pixel data using a byte *.
I am aware of that internally GDI+ stores RGB as BGR,
therefore i have to manually swap the R and B components of each
pixel.
Since GDI+ internally stores the components in BGR order, there is'nt a
way to copy the entire pixel data directly without looping the pixels, is
it?


Thank you!
MVH Dennis
 
Dennis,

No, it would appear that there isn't. If it was in RGB order, then you
could just copy the block of memory, but that doesn't seem feasable.

You could also try copying the block of memory, and then swapping the
bytes at every 1st and 3rd index (the R and B components). It might be
faster, and require less loop iterations.

Hope this helps.
 
Back
Top