Reputation: 1092
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!
Upvotes: 0
Views: 786
Reputation: 66573
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;
}
Upvotes: 1