Do certain types of image files always match certain types of BufferedImage?

The BufferedImage class in Java contains a method getType()that returns an integer that maps to a variable of type BufferedImage that describes some information about how the image is encoded (you can look at the source of BufferedImage to determine which number corresponds to a variable of constant type). For example, if it returns an integer corresponding to BufferedImage.TYPE_3BYTE_BGR, then this means that BufferedImage is an 8-bit RGB image without alpha and with blue, green, and yellow, each of which is represented by 3 bits.

Some of these types of images seem to correlate with certain properties of a particular format. For example, it TYPE_BYTE_INDEXEDsays that it is created from the "256-color 6/6/6 color palette of cubes." This is very similar to GIF images created from 256 colors.

Curiously, I looked at several hundred photos on my hard drive and converted each of them to BufferedImage, using ImageIO.read(File file), and then typed BufferedImage.getType(). I decided that there are only a few types of BufferedImage that were created from specific types of images. The results were as follows:

JPG: TYPE_3BYTE_BGR, TYPE_BYTE_GRAY

PNG: TYPE_3BYTE_BGR, TYPE_BYTE_GRAY, TYPE_4BYTE_BGRA

GIF: TYPE_BYTE_INDEXED

, JPG, PNG BufferedImage, PNG TYPE_4BYTE_BGRA, GIF TYPE_BYTE_INDEXED.

, , . , : , , BufferedImages ? , GIF TYPE_BYTE_INDEXED? , BufferedImage?

+4
1

[Do] BufferedImage ?

; , BufferedImage .

, BufferedImage ?

, . , , , 16- , 8 ..


, BufferedImage "", .

GIF:

"" GIF ( LZW) "t24", " " Java. GIF 16 TYPE_BYTE_BINARY . , GIF TYPE_4BYTE_ABGR TYPE_INT_ARGB ( TYPE_3BYTE_BGR TYPE_INT_RGB, ).

, , (, ImageIO API) .

, , GIF- ImageIO (GIFImageReader) GIF 16 TYPE_BYTE_INDEXED. / .


, :

BufferedImage, , . . , , , . - . , , , , , "" .

, "" ad hoc , . - . , , / .

, , . " A = > B", " A C = > B".

+7

All Articles