Adam
Adam

Reputation: 603

Determining the ColorModel of an image using If Statements?

I am trying to determin if an image is in a specific format to determin what sort of processing to execute on the image.

I've done BufferedImageObject.getColorModel() in a println statement to see what it returns and its too much information to to specify whether or not the image is RGB, HSI, Bitonal, Grayscale etc.

Could anyone direct me to a method that I could use to simply

if (object.colorModelMethod == RGB) { //Do stuff }

or something similar to that?

Upvotes: 0

Views: 124

Answers (1)

Hunter McMillen
Hunter McMillen

Reputation: 61512

I think what you actually want is a ColorSpace object, you can get to this using the BufferedImage and ColorModel APIs:

import java.awt.image.*;

BufferedImage im = new BufferedImage(//....);

if(im.getColorModel().getColorSpace() == ColorSpace.TYPE_RGB)
    //do stuff...

Hope this helps.

Upvotes: 1

Related Questions