How can i know what is the bitmap color size of each pixel ?
-
I have some bitmap. I know that the bitmap format is PixelFormat.FormatXXXXXXbppRgb ==> but i want dynamically to calculate the size of each pixel. For example ==> if the bitmap pixel format is Format24bppRgb i want to calculate that the R/G/B range is between 0 to 255. So, i don't know how to get the information that in case of Format24bppRgb the R/G/B bit size is 3. or that in the format is Format32bppRgb that the R/G/B bit size is 4. P.S: i don't want to use the code BitmapData bmDateFrame = bitmap.LockBits(....) Int32 picPixelBit = bmDateFrame.Stride / bitmap.Width;
-
I have some bitmap. I know that the bitmap format is PixelFormat.FormatXXXXXXbppRgb ==> but i want dynamically to calculate the size of each pixel. For example ==> if the bitmap pixel format is Format24bppRgb i want to calculate that the R/G/B range is between 0 to 255. So, i don't know how to get the information that in case of Format24bppRgb the R/G/B bit size is 3. or that in the format is Format32bppRgb that the R/G/B bit size is 4. P.S: i don't want to use the code BitmapData bmDateFrame = bitmap.LockBits(....) Int32 picPixelBit = bmDateFrame.Stride / bitmap.Width;
There doesn't appear to be an easy way to do this from what I can tell. but looking at the PixelFormat Enumeration[^] it is only going to be 8 or 16 bits per pixel so a small switch statement should do the job. The bigger question is why do you need to know this? There is most likely a better way as I have never needed to know this information.
-
I have some bitmap. I know that the bitmap format is PixelFormat.FormatXXXXXXbppRgb ==> but i want dynamically to calculate the size of each pixel. For example ==> if the bitmap pixel format is Format24bppRgb i want to calculate that the R/G/B range is between 0 to 255. So, i don't know how to get the information that in case of Format24bppRgb the R/G/B bit size is 3. or that in the format is Format32bppRgb that the R/G/B bit size is 4. P.S: i don't want to use the code BitmapData bmDateFrame = bitmap.LockBits(....) Int32 picPixelBit = bmDateFrame.Stride / bitmap.Width;