Package org.monte.media.jpeg
Class CMYKJPEGImageReader
- java.lang.Object
-
- javax.imageio.ImageReader
-
- org.monte.media.jpeg.CMYKJPEGImageReader
-
public class CMYKJPEGImageReader extends ImageReader
Reads a JPEG image with colors in the CMYK color space.- Version:
- $Id: CMYKJPEGImageReader.java 351 2016-10-23 15:15:55Z 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
Constructors Constructor Description CMYKJPEGImageReader()CMYKJPEGImageReader(ImageReaderSpi originatingProvider)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static BufferedImagecreateImageFromCMYK(Raster cmykRaster, ICC_Profile cmykProfile)static BufferedImagecreateImageFromICCProfile(Raster raster, ICC_Profile profile)Creates a buffered image from a raster in the color space specified by the given ICC_Profile.static BufferedImagecreateImageFromInvertedCMYK(Raster rgbwRaster, ICC_Profile cmykProfile)Creates a buffered image from a raster in the RGBW color space.static BufferedImagecreateImageFromInvertedYCCK(Raster ycckRaster, 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 BufferedImagecreateImageFromRGB(Raster rgbRaster, ICC_Profile rgbProfile)static BufferedImagecreateImageFromYCC(Raster yccRaster, ICC_Profile yccProfile)static BufferedImagecreateImageFromYCCK(Raster ycckRaster, 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.voiddispose()Disposes of resources held internally by the reader.intgetHeight(int imageIndex)IIOMetadatagetImageMetadata(int imageIndex)Iterator<ImageTypeSpecifier>getImageTypes(int imageIndex)intgetNumImages(boolean allowSearch)IIOMetadatagetStreamMetadata()intgetWidth(int imageIndex)booleanisIgnoreICCProfile()booleanisInvertColors()BufferedImageread(int imageIndex, ImageReadParam param)static BufferedImageread(ImageInputStream in, boolean inverseYCCKColors, boolean isIgnoreColorProfile)static BufferedImagereadImageFromCMYK(InputStream in, ICC_Profile cmykProfile)Reads a CMYK JPEG image from the provided InputStream, converting the colors to RGB using the provided CMYK ICC_Profile.static BufferedImagereadImageFromInvertedCMYK(InputStream in, ICC_Profile rgbaProfile)Reads a RGBA JPEG image from the provided InputStream, converting the colors to RGBA using the provided RGBA ICC_Profile.static BufferedImagereadImageFromInvertedYCCK(InputStream in, 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 BufferedImagereadImageFromRGB(InputStream in, ICC_Profile rgbaProfile)static BufferedImagereadImageFromYCCK(InputStream in, ICC_Profile cmykProfile)Reads a YCCK JPEG image from the provided InputStream, converting the colors to RGB using the provided CMYK ICC_Profile.static BufferedImagereadImageFromYCCorGray(ImageInputStream in)Reads a JPEG image from the provided InputStream.static BufferedImagereadRGBImageFromYCC(InputStream in, ICC_Profile rgbaProfile)voidsetIgnoreICCProfile(boolean newValue)voidsetInvertColors(boolean newValue)-
Methods inherited from class javax.imageio.ImageReader
abort, abortRequested, addIIOReadProgressListener, addIIOReadUpdateListener, addIIOReadWarningListener, canReadRaster, checkReadParamBandSettings, clearAbortRequest, computeRegions, 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
-
-
-
-
Constructor Detail
-
CMYKJPEGImageReader
public CMYKJPEGImageReader()
-
CMYKJPEGImageReader
public CMYKJPEGImageReader(ImageReaderSpi originatingProvider)
-
-
Method Detail
-
getNumImages
public int getNumImages(boolean allowSearch) throws IOException- Specified by:
getNumImagesin classImageReader- Throws:
IOException
-
getWidth
public int getWidth(int imageIndex) throws IOException- Specified by:
getWidthin classImageReader- Throws:
IOException
-
getHeight
public int getHeight(int imageIndex) throws IOException- Specified by:
getHeightin classImageReader- Throws:
IOException
-
getImageTypes
public Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex) throws IOException
- Specified by:
getImageTypesin classImageReader- Throws:
IOException
-
getStreamMetadata
public IIOMetadata getStreamMetadata() throws IOException
- Specified by:
getStreamMetadatain classImageReader- Throws:
IOException
-
getImageMetadata
public IIOMetadata getImageMetadata(int imageIndex) throws IOException
- Specified by:
getImageMetadatain classImageReader- Throws:
IOException
-
read
public BufferedImage read(int imageIndex, ImageReadParam param) throws IOException
- Specified by:
readin classImageReader- Throws:
IOException
-
isInvertColors
public boolean isInvertColors()
- Returns:
- the YCCKInversed property.
-
setInvertColors
public void setInvertColors(boolean newValue)
- Parameters:
newValue- the new value
-
isIgnoreICCProfile
public boolean isIgnoreICCProfile()
-
setIgnoreICCProfile
public void setIgnoreICCProfile(boolean newValue)
-
read
public static BufferedImage read(ImageInputStream in, boolean inverseYCCKColors, boolean isIgnoreColorProfile) throws IOException
- Throws:
IOException
-
readImageFromCMYK
public static BufferedImage readImageFromCMYK(InputStream in, ICC_Profile cmykProfile) throws 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:
IOException
-
readImageFromInvertedCMYK
public static BufferedImage readImageFromInvertedCMYK(InputStream in, ICC_Profile rgbaProfile) throws 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:
IOException
-
readImageFromRGB
public static BufferedImage readImageFromRGB(InputStream in, ICC_Profile rgbaProfile) throws IOException
- Throws:
IOException
-
readRGBImageFromYCC
public static BufferedImage readRGBImageFromYCC(InputStream in, ICC_Profile rgbaProfile) throws IOException
- Throws:
IOException
-
readImageFromYCCK
public static BufferedImage readImageFromYCCK(InputStream in, ICC_Profile cmykProfile) throws 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:
IOException
-
readImageFromInvertedYCCK
public static BufferedImage readImageFromInvertedYCCK(InputStream in, ICC_Profile cmykProfile) throws 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:
IOException
-
createImageFromYCCK
public static BufferedImage createImageFromYCCK(Raster ycckRaster, 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
-
createImageFromInvertedYCCK
public static BufferedImage createImageFromInvertedYCCK(Raster ycckRaster, 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.
-
createImageFromICCProfile
public static BufferedImage createImageFromICCProfile(Raster raster, ICC_Profile profile)
Creates a buffered image from a raster in the color space specified by the given ICC_Profile.- Parameters:
raster- A raster.profile- An ICC_Profile specifying the color space of the raster.- Returns:
- a BufferedImage in the color space specified by the profile.
-
createImageFromCMYK
public static BufferedImage createImageFromCMYK(Raster cmykRaster, ICC_Profile cmykProfile)
-
createImageFromInvertedCMYK
public static BufferedImage createImageFromInvertedCMYK(Raster rgbwRaster, ICC_Profile cmykProfile)
Creates a buffered image from a raster in the RGBW color space. As seen from a comment made by 'phelps' at http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4799903- Parameters:
rgbwRaster- A raster with inverted CMYK values (=RGBW).cmykProfile- An ICC_Profile. If this parameter is null, a default profile is used.- Returns:
- a BufferedImage in the RGB color space.
-
createImageFromRGB
public static BufferedImage createImageFromRGB(Raster rgbRaster, ICC_Profile rgbProfile)
-
createImageFromYCC
public static BufferedImage createImageFromYCC(Raster yccRaster, ICC_Profile yccProfile)
-
readImageFromYCCorGray
public static BufferedImage readImageFromYCCorGray(ImageInputStream in) throws 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:
IOException
-
dispose
public void dispose()
Disposes of resources held internally by the reader.- Overrides:
disposein classImageReader
-
-