FileDocCategorySizeDatePackage
JPEG.javaAPI DocJava SE 5 API11992Fri Aug 26 14:54:42 BST 2005com.sun.imageio.plugins.jpeg

JPEG

public class JPEG extends Object
A class containing JPEG-related constants, definitions, and static methods. This class and its constants must be public so that JPEGImageWriteParam can see it.

Fields Summary
public static final int
TEM
For temporary use in arithmetic coding
public static final int
SOF0
Baseline DCT
public static final int
SOF1
Extended Sequential DCT
public static final int
SOF2
Progressive DCT
public static final int
SOF3
Lossless Sequential
public static final int
DHT
Define Huffman Tables
public static final int
SOF5
Differential Sequential DCT
public static final int
SOF6
Differential Progressive DCT
public static final int
SOF7
Differential Lossless
public static final int
JPG
Reserved for JPEG extensions
public static final int
SOF9
Extended Sequential DCT, Arithmetic coding
public static final int
SOF10
Progressive DCT, Arithmetic coding
public static final int
SOF11
Lossless Sequential, Arithmetic coding
public static final int
DAC
Define Arithmetic conditioning tables
public static final int
SOF13
Differential Sequential DCT, Arithmetic coding
public static final int
SOF14
Differential Progressive DCT, Arithmetic coding
public static final int
SOF15
Differential Lossless, Arithmetic coding
public static final int
RST0
public static final int
RST1
public static final int
RST2
public static final int
RST3
public static final int
RST4
public static final int
RST5
public static final int
RST6
public static final int
RST7
public static final int
RESTART_RANGE
Number of restart markers
public static final int
SOI
Start of Image
public static final int
EOI
End of Image
public static final int
SOS
Start of Scan
public static final int
DQT
Define Quantisation Tables
public static final int
DNL
Define Number of lines
public static final int
DRI
Define Restart Interval
public static final int
DHP
Define Heirarchical progression
public static final int
EXP
Expand reference image(s)
public static final int
APP0
APP0 used by JFIF
public static final int
APP1
public static final int
APP2
public static final int
APP3
public static final int
APP4
public static final int
APP5
public static final int
APP6
public static final int
APP7
public static final int
APP8
public static final int
APP9
public static final int
APP10
public static final int
APP11
public static final int
APP12
public static final int
APP13
public static final int
APP14
APP14 used by Adobe
public static final int
APP15
public static final int
COM
Comment marker
public static final int
DENSITY_UNIT_ASPECT_RATIO
The X and Y units simply indicate the aspect ratio of the pixels.
public static final int
DENSITY_UNIT_DOTS_INCH
Pixel density is in pixels per inch.
public static final int
DENSITY_UNIT_DOTS_CM
Pixel density is in pixels per centemeter.
public static final int
NUM_DENSITY_UNIT
The max known value for DENSITY_UNIT
public static final int
ADOBE_IMPOSSIBLE
public static final int
ADOBE_UNKNOWN
public static final int
ADOBE_YCC
public static final int
ADOBE_YCCK
public static final String
vendor
public static final String
version
public static final String[]
names
public static final String[]
suffixes
public static final String[]
MIMETypes
public static final String
nativeImageMetadataFormatName
public static final String
nativeImageMetadataFormatClassName
public static final String
nativeStreamMetadataFormatName
public static final String
nativeStreamMetadataFormatClassName
public static final int
JCS_UNKNOWN
public static final int
JCS_GRAYSCALE
public static final int
JCS_RGB
public static final int
JCS_YCbCr
public static final int
JCS_CMYK
public static final int
JCS_YCC
public static final int
JCS_RGBA
public static final int
JCS_YCbCrA
public static final int
JCS_YCCA
public static final int
JCS_YCCK
public static final int
NUM_JCS_CODES
public static final int[]
bandOffsets
IJG can handle up to 4-channel JPEGs
public static final int[]
bOffsRGB
protected static final ColorSpace
sRGB
protected static ColorSpace
YCC
public static final float
DEFAULT_QUALITY
Constructors Summary
Methods Summary
static floatconvertToLinearQuality(float quality)
Converts an ImageWriteParam (i.e. IJG) non-linear quality value to a float suitable for passing to JPEGQTable.getScaledInstance().

        // The following is converted from the IJG code.
        if (quality <= 0.0F) {
            quality = 0.01F;
        }
        
        if (quality > 1.00F) {
            quality = 1.00F;
        }
        
        if (quality < 0.5F) {
            quality = 0.5F / quality;
        } else {
            quality = 2.0F - (quality * 2.0F);
        }

        return quality;
    
static javax.imageio.plugins.jpeg.JPEGHuffmanTable[]getDefaultHuffmanTables(boolean wantDC)
Return an array of default Huffman tables.

        JPEGHuffmanTable [] tables = new JPEGHuffmanTable[2];
        if (wantDC) {
            tables[0] = JPEGHuffmanTable.StdDCLuminance;
            tables[1] = JPEGHuffmanTable.StdDCChrominance;
        } else {
            tables[0] = JPEGHuffmanTable.StdACLuminance;
            tables[1] = JPEGHuffmanTable.StdACChrominance;
        }
        return tables;
    
static javax.imageio.plugins.jpeg.JPEGQTable[]getDefaultQTables()
Return an array of default, visually lossless quantization tables.

        JPEGQTable [] qTables = new JPEGQTable[2];
        qTables[0] = JPEGQTable.K1Div2Luminance;
        qTables[1] = JPEGQTable.K2Div2Chrominance;
        return qTables;
    
static booleanisJFIFcompliant(javax.imageio.ImageTypeSpecifier imageType, boolean input)
Returns true if the given imageType can be used in a JFIF file. If input is true, then the image type is considered before colorspace conversion.

        ColorModel cm = imageType.getColorModel();
        // Can't have alpha
        if (cm.hasAlpha()) {
            return false;
        }
        // Gray is OK, always
        int numComponents = imageType.getNumComponents();
        if (numComponents == 1) {
            return true;
        }
        
        // If it isn't gray, it must have 3 channels
        if (numComponents != 3) {
            return false;
        }
        
        if (input) {
            // Must be RGB
            if (cm.getColorSpace().getType() == ColorSpace.TYPE_RGB) {
                return true;
            }
        } else {
            // Must be YCbCr
            if (cm.getColorSpace().getType() == ColorSpace.TYPE_YCbCr) {
                return true;
            }
        }

        return false;
    
static booleanisNonStandardICC(java.awt.color.ColorSpace cs)
Returns true if the given ColorSpace object is an instance of ICC_ColorSpace but is not one of the standard ColorSpaces returned by ColorSpace.getInstance().


                                 
        
        boolean retval = false;
        if ((cs instanceof ICC_ColorSpace)
            && (!cs.isCS_sRGB())
            && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_CIEXYZ)))
            && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_GRAY)))
            && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB)))
            && (!cs.equals(ColorSpace.getInstance(ColorSpace.CS_PYCC)))
            ) {
            retval = true;
        }
        return retval;
    
static inttransformForType(javax.imageio.ImageTypeSpecifier imageType, boolean input)
Given an image type, return the Adobe transform corresponding to that type, or ADOBE_IMPOSSIBLE if the image type is incompatible with an Adobe marker segment. If input is true, then the image type is considered before colorspace conversion.

        int retval = ADOBE_IMPOSSIBLE;
        ColorModel cm = imageType.getColorModel();
        switch (cm.getColorSpace().getType()) {
        case ColorSpace.TYPE_GRAY:
            retval = ADOBE_UNKNOWN;
            break;
        case ColorSpace.TYPE_RGB:
            retval = input ? ADOBE_YCC : ADOBE_UNKNOWN;
            break;
        case ColorSpace.TYPE_YCbCr:
            retval = ADOBE_YCC;
            break;
        case ColorSpace.TYPE_CMYK:
            retval = input ? ADOBE_YCCK : ADOBE_IMPOSSIBLE;
        }
        return retval;