Skip to main content

JAI causes BufferedImage.getType() to return TYPE_CUSTOM

2 replies [Last post]
cowwoc
Offline
Joined: 2003-08-24

Before installing JAI ImageIO when I use an ImageReader to load a JPG file from disk, invoke getBufferedImageType() on it, it returns a decent value (like ARGB) but once JAI's imageio plugin is installed it returns TYPE_CUSTOM.

Others have reported this problem before but got no answer. Can anyone please explain what is going on?

Thank you,
Gili

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
cowwoc
Offline
Joined: 2003-08-24

When using JAI-imageio, image.toString() returns:

type = 0 ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace@1972e3a transparency = 1 has alpha = false isAlphaPre = false ByteInterleavedRaster: width = 1600 height = 1200 #numDataElements 3 dataOff[0] = 0

which looks like TYPE_INT_RGB to me, not TYPE_CUSTOM. Any ideas?

cowwoc
Offline
Joined: 2003-08-24

The only difference between TYPE_3BYTE_BRG and the TYPE_CUSTOM BufferedImage being returned seems to be the dataOff field. I am guessing the JPG is in the format TYPE_3BYTE_RGB which does not exist as a standard BufferedImage type. I also suspect the reason JAI modifies the default behavior is for performance reasons but that's just a guess.

actualImage:

BufferedImage@1f38fc6: type = 0 ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace@1642bd6 transparency = 1 has alpha = false isAlphaPre = false ByteInterleavedRaster: width = 1600 height = 1200 #numDataElements 3 dataOff[0] = 0

TYPE_3BYTE_RGB image:
BufferedImage@179f36b: type = 5 ColorModel: #pixelBits = 24 numComponents = 3 color space = java.awt.color.ICC_ColorSpace@1642bd6 transparency = 1 has alpha = false isAlphaPre = false ByteInterleavedRaster: width = 1600 height = 1200 #numDataElements 3 dataOff[0] = 2