Please dont quote this How can I check the color depth of a Bitmap? or How to check if a picture is in grayScale
Because an image can be 24/32 bit per pixel even if
Bitmap.GetPixel()
returns a Color structure which has fields R
, G
and B
so you can just compare them however you want.
Do note that using GetPixel()
is very slow, but if you don't need speed it will do.
Ok you need to take the RGB components of a bit sequence. Lets say the sequence is 24 bits so you have the following bit sequence:
RRRRRRRRGGGGGGGGBBBBBBBB
WhereR
is a bit for red
, G
is a bit for green
and B
is a bit for blue. To separate this you can do it with bitwise operators.
color = Bitmap.GetPixel(iCounter, iCount).ToArgb();
blue = color & 0xFF; // Get the 1st 8 bits
green = (color >> 8) & 0xFF; // Remove the 1st 8 bits and take the 2n 8 bits
red = (color >> 16) & 0xFF; // Remove the 1st 16 bits and take the 3rd 8 bits