JPEGQTablepublic class JPEGQTable extends Object A class encapsulating a single JPEG quantization table. The
elements appear in natural order (as opposed to zig-zag order).
Static variables are provided for the "standard" tables taken from
Annex K of the JPEG spec, as well as the default tables
conventionally used for visually lossless encoding.
For more information about the operation of the built-in JPEG plug-ins,
see the JPEG
metadata format specification and usage notes. |
Fields Summary |
---|
private int[] | tableTable | private static final byte | QTABLESIZEThe number of coefficients in a quantization table. | public static final JPEGQTable | K1LuminanceThe sample luminance quantization table given in the JPEG
specification, table K.1. According to the specification,
these values produce "good" quality output. | public static final JPEGQTable | K1Div2LuminanceThe sample luminance quantization table given in the JPEG
specification, table K.1, with all elements divided by 2.
According to the specification, these values produce "very
good" quality output. This is the table usually used for
"visually lossless" encoding, and is the default luminance
table used if the default tables and quality settings are used. | public static final JPEGQTable | K2ChrominanceThe sample chrominance quantization table given in the JPEG
specification, table K.2. According to the specification,
these values produce "good" quality output. | public static final JPEGQTable | K2Div2ChrominanceThe sample chrominance quantization table given in the JPEG
specification, table K.2, with all elements divided by 2.
According to the specification, these values produce "very
good" quality output. This is the table usually used for
"visually lossless" encoding, and is the default chrominance
table used if the default tables and quality settings are used. |
Constructors Summary |
---|
private JPEGQTable()Constructs an empty quantization table. This is used to create
the standard tables.
| public JPEGQTable(int[] table)Constructs a quantization table from the argument, which must
contain 64 elements in natural order (not zig-zag order).
A copy is made of the the input array.
if (table == null) {
throw new IllegalArgumentException("table == null!");
}
if (table.length != QTABLESIZE) {
throw new IllegalArgumentException
("Quantization table is the wrong size.");
}
this.table = (int[])table.clone();
|
Methods Summary |
---|
public javax.imageio.plugins.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 of scaleFactorless than 1 tend to
improve the quality level of the table, and values greater than
1.0 degrade the quality level of the table.
int max = (forceBaseline) ? 255 : 32767;
int[] ret = new int[QTABLESIZE];
for (int i = 0; i < QTABLESIZE; i++) {
float scaledValue = (float)Math.round(table[i]*scaleFactor);
int holder;
// limit to valid range
if (scaledValue <= 1.0F) {
holder = 1;
} else if (scaledValue >= max) {
holder = max;
} else {
holder = (int)scaledValue;
}
ret[i] = holder;
}
return new JPEGQTable(ret);
| public int[] | getTable()Returns a copy of the current quantization table as an array of
ints in natural (not zig-zag) order.
return (int[])table.clone();
| public java.lang.String | toString()
StringBuffer sb = new StringBuffer();
sb.append("JPEGQTable:\n");
for (int i = 0; i< 8; i++) {
sb.append('\t");
for (int j = 0; j < 8; j++) {
sb.append(table[i]).append(" ");
}
sb.append('\n");
}
return sb.toString();
|
|