我编写了以下代码来检查图像的类型是“RGB,BGR还是任何其他类型”。当我运行代码我收到的值等于5,我也检查了文档here,但我仍然不知道哪个类型相当于5号!
请让我知道如何知道5的等效图像类型。
码:
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());
}
}
答案 0 :(得分:3)
/**
* 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;
答案 1 :(得分:2)
阅读您提供的getType()文档,让我看到“另请参阅”中的图像类型列表。这导致了Constant Field Values文件。似乎5相当于“TYPE_3BYTE_BGR”。