which image type is equivalent to 5

2.5k views Asked by At

I wrote the below code to check if the type of the image "RGB,BGR or any other type". when i ran the code i received value equals to 5, and i also checked the docs here but still i do not know which type is equivalent to number 5!

please let me know how to know the equivalent image type to 5.

code:

public class MainClass {

public static void main(String[] args) throws IOException {

    File imgFile = new File("c:\\img.jpg");
    BufferedImage bi = ImageIO.read(imgFile);

    System.out.println(bi.getType());
}

}

2

There are 2 answers

0
Hadley Research On BEST ANSWER

Reading the getType() documentation you provided led me to the image type listings in "See Also". That led to the Constant Field Values document. It would seem that 5 is equivalent to "TYPE_3BYTE_BGR".

0
Marvin On

It's TYPE_3BYTE_BGR:

/**
 * Represents an image with 8-bit RGB color components, corresponding 
 * to a Windows-style BGR color model) with the colors Blue, Green,
 * and Red stored in 3 bytes.  There is no alpha.  The image has a
 * <code>ComponentColorModel</code>.
 * When data with non-opaque alpha is stored
 * in an image of this type,
 * the color data must be adjusted to a non-premultiplied form
 * and the alpha discarded,
 * as described in the
 * {@link java.awt.AlphaComposite} documentation.
 */
public static final int TYPE_3BYTE_BGR = 5;