The correct way to check this is:
For JPEG files, you must check the corresponding properties using the PropertyItems bitmap collection. It may contain appropriate EXIF tags to help determine bit depth. The next step is to analyze the JPEG header and search for the “start frame” marker, and then the number of components in the image.
The last way is to load the JPEG into a Bitmap object and compare the number of pixels with the forum (width * height * bytes_per_pixel). Thus, if you are loading a bitmap, and the number of bytes of actual raw data is equal (width * height), then you know that it is a safe bet that the image has 1 byte per pixel and as such has shades of gray.
The last thing you want to check out is the PixelFormat of the bitmap itself.
For the TIFF format, you must do the same with the PropertyItems collection and check the corresponding tag mentioned in the specification. If they fail, compare the bytes of the image and finally use the PixelFormat property as a last resort.
user113476
source share