When working with BufferedImages ( {@link com.sun.image.codec.jpeg.JPEGImageDecoder#decodeAsBufferedImage}), the codec will attempt to generate an appropriate ColorModel for the JPEG COLOR_ID. This is not always possible (example mappings are listed below) . In cases where unsupported conversions are required, or unknown encoded COLOR_ID's are in use, the user must request the data as a Raster and perform the transformations themselves. When decoding into a raster ( {@link com.sun.image.codec.jpeg.JPEGImageDecoder#decodeAsRaster}) no ColorSpace adjustments are made. Note: The color ids described herein are simply enumerated values that influence data processing by the JPEG codec. JPEG compression is by definition color blind. These values are used as hints when decompressing JPEG data. Of particular interest is the default conversion from YCbCr to sRGB when decoding buffered Images.
Note: because JPEG is mostly color-blind color fidelity can not be garunteed. This will hopefully be rectified in the near future by the wide spread inclusion of ICC-profiles in the JPEG data stream (as a special marker). The following is an example of the conversions that take place. This is only a guide to the types of conversions that are allowed. This list is likely to change in the future so it is strongly recommended that you check for thrown ImageFormatExceptions and check the actual ColorModel associated with the BufferedImage returned rather than make assumtions.
DECODING: JPEG (Encoded) Color ID BufferedImage ColorSpace ======================= ======================== COLOR_ID_UNKNOWN ** Invalid COLOR_ID_GRAY CS_GRAY COLOR_ID_RGB CS_sRGB COLOR_ID_YCbCr CS_sRGB COLOR_ID_CMYK ** Invalid COLOR_ID_PYCC CS_PYCC COLOR_ID_RGBA CS_sRGB (w/ alpha) COLOR_ID_YCbCrA CS_sRGB (w/ alpha) COLOR_ID_RGBA_INVERTED ** Invalid COLOR_ID_YCbCrA_INVERTED ** Invalid COLOR_ID_PYCCA CS_PYCC (w/ alpha) COLOR_ID_YCCK ** InvalidIf the user needs better control over conversion, the user must request the data as a Raster and handle the conversion of the image data themselves.
When decoding JFIF files the encoded COLOR_ID will always be one of: COLOR_ID_UNKNOWN, COLOR_ID_GRAY, COLOR_ID_RGB, COLOR_ID_YCbCr, COLOR_ID_CMYK, or COLOR_ID_YCCK
Note that the classes in the com.sun.image.codec.jpeg package are not part of the core Java APIs. They are a part of Sun's JDK and JRE distributions. Although other licensees may choose to distribute these classes, developers cannot depend on their availability in non-Sun implementations. We expect that equivalent functionality will eventually be available in a core API or standard extension.
|
|