Copyright 2013-01-06 Werner Randelshofer

org.monte.media.jpeg
Class CMYKJPEGImageReader

java.lang.Object
  extended by javax.imageio.ImageReader
      extended by org.monte.media.jpeg.CMYKJPEGImageReader

public class CMYKJPEGImageReader
extends javax.imageio.ImageReader

Reads a JPEG image with colors in the CMYK color space.

Version:
$Id: CMYKJPEGImageReader.java 308 2013-01-06 11:24:06Z werner $
Author:
Werner Randelshofer

Field Summary
 
Fields inherited from class javax.imageio.ImageReader
availableLocales, ignoreMetadata, input, locale, minIndex, originatingProvider, progressListeners, seekForwardOnly, updateListeners, warningListeners, warningLocales
 
Constructor Summary
CMYKJPEGImageReader(javax.imageio.spi.ImageReaderSpi originatingProvider)
           
 
Method Summary
static java.awt.image.BufferedImage createRGBAImageFromRGBA(java.awt.image.Raster rgbaRaster, java.awt.color.ICC_Profile rgbaProfile)
          Creates a buffered image from a raster in the RGBA color space, converting the colors to RGB using the provided CMYK ICC_Profile.
static java.awt.image.BufferedImage createRGBImageFromCMYK(java.awt.image.Raster cmykRaster, java.awt.color.ICC_Profile cmykProfile)
          Creates a buffered image from a raster in the CMYK color space, converting the colors to RGB using the provided CMYK ICC_Profile.
static java.awt.image.BufferedImage createRGBImageFromInvertedYCCK(java.awt.image.Raster ycckRaster, java.awt.color.ICC_Profile cmykProfile)
          Creates a buffered image from a raster in the inverted YCCK color space, converting the colors to RGB using the provided CMYK ICC_Profile.
static java.awt.image.BufferedImage createRGBImageFromRGB(java.awt.image.Raster rgbaRaster, java.awt.color.ICC_Profile rgbaProfile)
           
static java.awt.image.BufferedImage createRGBImageFromYCC(java.awt.image.Raster rgbaRaster, java.awt.color.ICC_Profile rgbaProfile)
           
static java.awt.image.BufferedImage createRGBImageFromYCCK(java.awt.image.Raster ycckRaster, java.awt.color.ICC_Profile cmykProfile)
          Creates a buffered image from a raster in the YCCK color space, converting the colors to RGB using the provided CMYK ICC_Profile.
 int getHeight(int imageIndex)
           
 javax.imageio.metadata.IIOMetadata getImageMetadata(int imageIndex)
           
 java.util.Iterator<javax.imageio.ImageTypeSpecifier> getImageTypes(int imageIndex)
           
 int getNumImages(boolean allowSearch)
           
 javax.imageio.metadata.IIOMetadata getStreamMetadata()
           
 int getWidth(int imageIndex)
           
 boolean isIgnoreICCProfile()
           
 boolean isYCCKInversed()
           
static java.awt.image.BufferedImage read(javax.imageio.stream.ImageInputStream in, boolean inverseYCCKColors, boolean isIgnoreColorProfile)
           
 java.awt.image.BufferedImage read(int imageIndex, javax.imageio.ImageReadParam param)
           
static java.awt.image.BufferedImage readImageFromYCCorGray(javax.imageio.stream.ImageInputStream in)
          Reads a JPEG image from the provided InputStream.
static java.awt.image.BufferedImage readRGBAImageFromRGBA(java.io.InputStream in, java.awt.color.ICC_Profile rgbaProfile)
          Reads a RGBA JPEG image from the provided InputStream, converting the colors to RGBA using the provided RGBA ICC_Profile.
static java.awt.image.BufferedImage readRGBImageFromCMYK(java.io.InputStream in, java.awt.color.ICC_Profile cmykProfile)
          Reads a CMYK JPEG image from the provided InputStream, converting the colors to RGB using the provided CMYK ICC_Profile.
static java.awt.image.BufferedImage readRGBImageFromInvertedYCCK(java.io.InputStream in, java.awt.color.ICC_Profile cmykProfile)
          Reads an inverted-YCCK JPEG image from the provided InputStream, converting the colors to RGB using the provided CMYK ICC_Profile.
static java.awt.image.BufferedImage readRGBImageFromRGB(java.io.InputStream in, java.awt.color.ICC_Profile rgbaProfile)
           
static java.awt.image.BufferedImage readRGBImageFromYCC(java.io.InputStream in, java.awt.color.ICC_Profile rgbaProfile)
           
static java.awt.image.BufferedImage readRGBImageFromYCCK(java.io.InputStream in, java.awt.color.ICC_Profile cmykProfile)
          Reads a YCCK JPEG image from the provided InputStream, converting the colors to RGB using the provided CMYK ICC_Profile.
 void setIgnoreICCProfile(boolean newValue)
           
 void setYCCKInversed(boolean newValue)
           
 
Methods inherited from class javax.imageio.ImageReader
abort, abortRequested, addIIOReadProgressListener, addIIOReadUpdateListener, addIIOReadWarningListener, canReadRaster, checkReadParamBandSettings, clearAbortRequest, computeRegions, dispose, getAspectRatio, getAvailableLocales, getDefaultReadParam, getDestination, getFormatName, getImageMetadata, getInput, getLocale, getMinIndex, getNumThumbnails, getOriginatingProvider, getRawImageType, getSourceRegion, getStreamMetadata, getThumbnailHeight, getThumbnailWidth, getTileGridXOffset, getTileGridYOffset, getTileHeight, getTileWidth, hasThumbnails, isIgnoringMetadata, isImageTiled, isRandomAccessEasy, isSeekForwardOnly, processImageComplete, processImageProgress, processImageStarted, processImageUpdate, processPassComplete, processPassStarted, processReadAborted, processSequenceComplete, processSequenceStarted, processThumbnailComplete, processThumbnailPassComplete, processThumbnailPassStarted, processThumbnailProgress, processThumbnailStarted, processThumbnailUpdate, processWarningOccurred, processWarningOccurred, read, readAll, readAll, readAsRenderedImage, readerSupportsThumbnails, readRaster, readThumbnail, readTile, readTileRaster, removeAllIIOReadProgressListeners, removeAllIIOReadUpdateListeners, removeAllIIOReadWarningListeners, removeIIOReadProgressListener, removeIIOReadUpdateListener, removeIIOReadWarningListener, reset, setInput, setInput, setInput, setLocale
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CMYKJPEGImageReader

public CMYKJPEGImageReader(javax.imageio.spi.ImageReaderSpi originatingProvider)
Method Detail

getNumImages

public int getNumImages(boolean allowSearch)
                 throws java.io.IOException
Specified by:
getNumImages in class javax.imageio.ImageReader
Throws:
java.io.IOException

getWidth

public int getWidth(int imageIndex)
             throws java.io.IOException
Specified by:
getWidth in class javax.imageio.ImageReader
Throws:
java.io.IOException

getHeight

public int getHeight(int imageIndex)
              throws java.io.IOException
Specified by:
getHeight in class javax.imageio.ImageReader
Throws:
java.io.IOException

getImageTypes

public java.util.Iterator<javax.imageio.ImageTypeSpecifier> getImageTypes(int imageIndex)
                                                                   throws java.io.IOException
Specified by:
getImageTypes in class javax.imageio.ImageReader
Throws:
java.io.IOException

getStreamMetadata

public javax.imageio.metadata.IIOMetadata getStreamMetadata()
                                                     throws java.io.IOException
Specified by:
getStreamMetadata in class javax.imageio.ImageReader
Throws:
java.io.IOException

getImageMetadata

public javax.imageio.metadata.IIOMetadata getImageMetadata(int imageIndex)
                                                    throws java.io.IOException
Specified by:
getImageMetadata in class javax.imageio.ImageReader
Throws:
java.io.IOException

read

public java.awt.image.BufferedImage read(int imageIndex,
                                         javax.imageio.ImageReadParam param)
                                  throws java.io.IOException
Specified by:
read in class javax.imageio.ImageReader
Throws:
java.io.IOException

isYCCKInversed

public boolean isYCCKInversed()
Returns:
the YCCKInversed property.

setYCCKInversed

public void setYCCKInversed(boolean newValue)
Parameters:
newValue - the new value

isIgnoreICCProfile

public boolean isIgnoreICCProfile()

setIgnoreICCProfile

public void setIgnoreICCProfile(boolean newValue)

read

public static java.awt.image.BufferedImage read(javax.imageio.stream.ImageInputStream in,
                                                boolean inverseYCCKColors,
                                                boolean isIgnoreColorProfile)
                                         throws java.io.IOException
Throws:
java.io.IOException

readRGBImageFromCMYK

public static java.awt.image.BufferedImage readRGBImageFromCMYK(java.io.InputStream in,
                                                                java.awt.color.ICC_Profile cmykProfile)
                                                         throws java.io.IOException
Reads a CMYK JPEG image from the provided InputStream, converting the colors to RGB using the provided CMYK ICC_Profile. The image data must be in the CMYK color space.

Use this method, if you have already determined that the input stream contains a CMYK JPEG image.

Parameters:
in - An InputStream, preferably an ImageInputStream, in the JPEG File Interchange Format (JFIF).
cmykProfile - An ICC_Profile for conversion from the CMYK color space to the RGB color space. If this parameter is null, a default profile is used.
Returns:
a BufferedImage containing the decoded image converted into the RGB color space.
Throws:
java.io.IOException

readRGBAImageFromRGBA

public static java.awt.image.BufferedImage readRGBAImageFromRGBA(java.io.InputStream in,
                                                                 java.awt.color.ICC_Profile rgbaProfile)
                                                          throws java.io.IOException
Reads a RGBA JPEG image from the provided InputStream, converting the colors to RGBA using the provided RGBA ICC_Profile. The image data must be in the RGBA color space.

Use this method, if you have already determined that the input stream contains a RGBA JPEG image.

Parameters:
in - An InputStream, preferably an ImageInputStream, in the JPEG File Interchange Format (JFIF).
rgbaProfile - An ICC_Profile for conversion from the RGBA color space to the RGBA color space. If this parameter is null, a default profile is used.
Returns:
a BufferedImage containing the decoded image converted into the RGB color space.
Throws:
java.io.IOException

readRGBImageFromRGB

public static java.awt.image.BufferedImage readRGBImageFromRGB(java.io.InputStream in,
                                                               java.awt.color.ICC_Profile rgbaProfile)
                                                        throws java.io.IOException
Throws:
java.io.IOException

readRGBImageFromYCC

public static java.awt.image.BufferedImage readRGBImageFromYCC(java.io.InputStream in,
                                                               java.awt.color.ICC_Profile rgbaProfile)
                                                        throws java.io.IOException
Throws:
java.io.IOException

readRGBImageFromYCCK

public static java.awt.image.BufferedImage readRGBImageFromYCCK(java.io.InputStream in,
                                                                java.awt.color.ICC_Profile cmykProfile)
                                                         throws java.io.IOException
Reads a YCCK JPEG image from the provided InputStream, converting the colors to RGB using the provided CMYK ICC_Profile. The image data must be in the YCCK color space.

Use this method, if you have already determined that the input stream contains a YCCK JPEG image.

Parameters:
in - An InputStream, preferably an ImageInputStream, in the JPEG File Interchange Format (JFIF).
cmykProfile - An ICC_Profile for conversion from the CMYK color space to the RGB color space. If this parameter is null, a default profile is used.
Returns:
a BufferedImage containing the decoded image converted into the RGB color space.
Throws:
java.io.IOException

readRGBImageFromInvertedYCCK

public static java.awt.image.BufferedImage readRGBImageFromInvertedYCCK(java.io.InputStream in,
                                                                        java.awt.color.ICC_Profile cmykProfile)
                                                                 throws java.io.IOException
Reads an inverted-YCCK JPEG image from the provided InputStream, converting the colors to RGB using the provided CMYK ICC_Profile. The image data must be in the inverted-YCCK color space.

Use this method, if you have already determined that the input stream contains an inverted-YCCK JPEG image.

Parameters:
in - An InputStream, preferably an ImageInputStream, in the JPEG File Interchange Format (JFIF).
cmykProfile - An ICC_Profile for conversion from the CMYK color space to the RGB color space. If this parameter is null, a default profile is used.
Returns:
a BufferedImage containing the decoded image converted into the RGB color space.
Throws:
java.io.IOException

createRGBImageFromYCCK

public static java.awt.image.BufferedImage createRGBImageFromYCCK(java.awt.image.Raster ycckRaster,
                                                                  java.awt.color.ICC_Profile cmykProfile)
Creates a buffered image from a raster in the YCCK color space, converting the colors to RGB using the provided CMYK ICC_Profile.

Parameters:
ycckRaster - A raster with (at least) 4 bands of samples.
cmykProfile - An ICC_Profile for conversion from the CMYK color space to the RGB color space. If this parameter is null, a default profile is used.
Returns:
a BufferedImage in the RGB color space.
Throws:
NullPointerException.

createRGBImageFromInvertedYCCK

public static java.awt.image.BufferedImage createRGBImageFromInvertedYCCK(java.awt.image.Raster ycckRaster,
                                                                          java.awt.color.ICC_Profile cmykProfile)
Creates a buffered image from a raster in the inverted YCCK color space, converting the colors to RGB using the provided CMYK ICC_Profile.

Parameters:
ycckRaster - A raster with (at least) 4 bands of samples.
cmykProfile - An ICC_Profile for conversion from the CMYK color space to the RGB color space. If this parameter is null, a default profile is used.
Returns:
a BufferedImage in the RGB color space.

createRGBImageFromCMYK

public static java.awt.image.BufferedImage createRGBImageFromCMYK(java.awt.image.Raster cmykRaster,
                                                                  java.awt.color.ICC_Profile cmykProfile)
Creates a buffered image from a raster in the CMYK color space, converting the colors to RGB using the provided CMYK ICC_Profile. As seen from a comment made by 'phelps' at http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4799903

Parameters:
cmykRaster - A raster with (at least) 4 bands of samples.
cmykProfile - An ICC_Profile for conversion from the CMYK color space to the RGB color space. If this parameter is null, a default profile is used.
Returns:
a BufferedImage in the RGB color space.

createRGBAImageFromRGBA

public static java.awt.image.BufferedImage createRGBAImageFromRGBA(java.awt.image.Raster rgbaRaster,
                                                                   java.awt.color.ICC_Profile rgbaProfile)
Creates a buffered image from a raster in the RGBA color space, converting the colors to RGB using the provided CMYK ICC_Profile. As seen from a comment made by 'phelps' at http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4799903

Parameters:
rgbaRaster - A raster with (at least) 4 bands of samples.
rgbaProfile - An ICC_Profile for conversion from the CMYK color space to the RGB color space. If this parameter is null, a default profile is used.
Returns:
a BufferedImage in the RGB color space.

createRGBImageFromRGB

public static java.awt.image.BufferedImage createRGBImageFromRGB(java.awt.image.Raster rgbaRaster,
                                                                 java.awt.color.ICC_Profile rgbaProfile)

createRGBImageFromYCC

public static java.awt.image.BufferedImage createRGBImageFromYCC(java.awt.image.Raster rgbaRaster,
                                                                 java.awt.color.ICC_Profile rgbaProfile)

readImageFromYCCorGray

public static java.awt.image.BufferedImage readImageFromYCCorGray(javax.imageio.stream.ImageInputStream in)
                                                           throws java.io.IOException
Reads a JPEG image from the provided InputStream. The image data must be in the YUV or the Gray color space.

Use this method, if you have already determined that the input stream contains a YCC or Gray JPEG image.

Parameters:
in - An InputStream, preferably an ImageInputStream, in the JPEG File Interchange Format (JFIF).
Returns:
a BufferedImage containing the decoded image converted into the RGB color space.
Throws:
java.io.IOException

Copyright 2013-01-06 Werner Randelshofer