JPEGQTablepublic class JPEGQTable extends Object Class to encapsulate the JPEG quantization tables.
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.
|
Fields Summary |
---|
private int[] | quantvalQuantization step for each coefficient in zig-zag order | private static final byte | QTABLESIZEThe number of coefficients in a DCT block | public static final JPEGQTable | StdLuminanceThis is the sample luminance quantization table given in the
JPEG spec section K.1, expressed in zigzag order. The spec says
that the values given produce "good" quality, and when divided
by 2, "very good" quality. | public static final JPEGQTable | StdChrominanceThis is the sample luminance quantization table given in the
JPEG spec section K.1, expressed in zigzag order. The spec says
that the values given produce "good" quality, and when divided
by 2, "very good" quality. |
Constructors Summary |
---|
private JPEGQTable()Constructs an empty quantization table. This is used to create
the Std Q-Tables.
int [] chromVals = {
17, 18, 18, 24, 21, 24, 47, 26,
26, 47, 99, 66, 56, 66, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99,
99, 99, 99, 99, 99, 99, 99, 99
};
StdChrominance.quantval = chromVals;
quantval = new int[QTABLESIZE];
| public JPEGQTable(int[] table)Constructs an quantization table from the array that was
passed. The coefficents must be in zig-zag order. The array
must be of length 64.
if ( table.length != QTABLESIZE ) {
throw new IllegalArgumentException
("Quantization table is the wrong size.");
} else {
quantval = new int[QTABLESIZE];
System.arraycopy( table, 0, quantval, 0, QTABLESIZE );
}
|
Methods Summary |
---|
public com.sun.image.codec.jpeg.JPEGQTable | getScaledInstance(float scaleFactor, boolean forceBaseline)Returns a new Quantization table where the values are
multiplied by scaleFactor and then clamped to the range
1..32767 (or to 1..255 if forceBaseline is 'true').
Values less than one tend to improve the quality level of the
table, and values greater than one degrade the quality level of
the table.
long max = (forceBaseline)?255L:32767L;
int []ret = new int[QTABLESIZE];
for (int i=0; i<QTABLESIZE; i++ ) {
long holder = (long)((quantval[i] * scaleFactor) + 0.5);
// limit to valid range
if (holder <= 0L) holder = 1L;
// Max quantizer for 12 bits
if (holder > max ) holder = max;
ret[i] = (int)holder;
}
return new JPEGQTable(ret);
| public int[] | getTable()Returns the current quantization table as an array of ints in
zig zag order.
int[] table = new int[QTABLESIZE];
System.arraycopy( quantval, 0, table, 0, QTABLESIZE );
return table;
|
|