tags:

views:

44

answers:

1

I need to get the byte array from my ColorConvertedBitmap representing the bitmap. I was trying to use CopyPixels method but with no success.

How to complete this task and what is the best approach?

Thank you in advance for the replies and hints!

+1  A: 
public static byte[] BitmapToBytes(ColorConvertedBitmap ccb)
{
    byte[] bytes = new byte[ccb.PixelWidth * ccb.PixelHeight * ccb.Format.BitsPerPixel / 8];
    ccb.CopyPixels(bytes, ccb.PixelWidth * ccb.Format.BitsPerPixel / 8, 0);
    return bytes;
}
Timwi