I am trying to determine an image’s color space in Java. I believe this is referred to as “imageType” in the BufferedImage class. This is the line of code which causes me trouble – I don’t know what to put as the third argument:
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
I’m going to stitch several images together into the BufferedImage using the class Graphics2D. Some images I use may be in RGB format, others in ARGB, 4-byte ARGB etc…
Is there any way I can programatically determine the color spaces of the images? Or if not, is there a way of converting all images into the same color space before stitching?
The
ColorConvertOpclass can be used to convert an image from one ColorSpace to another.BufferedImage.getType()can be used to determine the color space used by the image.