Either, as you suggest, use BufferedImage.getType()
(you can find what the int
return values mean, in the API doc).
Or, use BufferedImage.getColorModel()
to get more information, like ColorSpace
(ColorModel.getColorSpace()
) to determine color space type, like RGB, CMYK or Gray, or special color spaces, like sRGB, AdobeRGB, PhotoYCC, IEXYZ, Lab etc.
If you need to figure out if your image in 24/32 bit depth with RGB color model really is all gray, you are out of luck, and instead have to loop though all the pixel values and see if R == G == B (perhaps with a small threshold).