I have a method that extracts the 8bit value (below), although my impression of the output would be something like the following:
010 020 030 = Specific Colour
135 250 250 = Specific Colour
The method I have returns the 8 bit values in an array – should the method not return the 8 bit values in a multidimensional array (like above) since all 3 sets of 8 bits correspond with each other to form a colour?
Current Method:
private static byte[] GetColorData(Bitmap bmp)
{
Rectangle rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
BitmapData bmpdata = bmp.LockBits(rect, ImageLockMode.ReadOnly, PixelFormat.Format24bppRgb);
IntPtr ptr = bmpdata.Scan0;
int bytes = bmpdata.Stride * bmp.Height;
byte[] results = new byte[bytes];
Marshal.Copy(ptr, results, 0, bytes);
bmp.UnlockBits(bmpdata);
return results;
}
Current Method Output:
100
101
000
255
250
The color values of a bitmap are just an array of bytes. It’s up to the interpretation of the values as to how they should be grouped. Your code explicitly converts the image to 24bpp RGB, so it’s up to you to do the grouping.
Also, you return a
byte[], which by definition only has one dimension. If you want a three-dimensional array, you need to create one yourself and add the values inresultsto the new multi-dimensional array yourself.