Package ch.randelshofer.media.jpeg
Class JPEGImageIO
- java.lang.Object
-
- ch.randelshofer.media.jpeg.JPEGImageIO
-
public class JPEGImageIO extends java.lang.Object
JPEGImageIO supports reading of JPEG images with YUV, CMYK and YCCK color encoding.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description 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
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.static java.awt.image.BufferedImage
read(java.io.InputStream in)
Reads a JPEG image from the provided InputStream and convert it into a color space which can be handled by Java2D (that is RGB or Gray in J2SE 5).static java.awt.image.BufferedImage
read(java.io.InputStream in, boolean inverseYCCKColors)
static java.awt.image.BufferedImage
readImageFromYUVorGray(java.io.InputStream in)
Reads a JPEG image from the provided InputStream.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
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.
-
-
-
Method Detail
-
read
public static java.awt.image.BufferedImage read(java.io.InputStream in) throws java.io.IOException
Reads a JPEG image from the provided InputStream and convert it into a color space which can be handled by Java2D (that is RGB or Gray in J2SE 5). The image data in the file can be in the YUV, Gray, YCCK or CMYK color space.- Parameters:
in
- An InputStream in the JPEG File Interchange Format (JFIF).- Returns:
- a BufferedImage containing the decoded image converted into the RGB color space.
- Throws:
java.io.IOException
-
read
public static java.awt.image.BufferedImage read(java.io.InputStream in, boolean inverseYCCKColors) throws java.io.IOException
- Throws:
java.io.IOException
-
readImageFromYUVorGray
public static java.awt.image.BufferedImage readImageFromYUVorGray(java.io.InputStream 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 YUV 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
-
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
-
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.
-
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.
-
-