FileDocCategorySizeDatePackage
JPEGQTable.javaAPI DocAndroid 1.5 API5389Wed May 06 22:41:54 BST 2009javax.imageio.plugins.jpeg

JPEGQTable

public class JPEGQTable extends Object
The JPEGQTable class represents a single JPEG quantization table and provides for the standard tables taken from the JPEG specification.
since
Android 1.0

Fields Summary
private static final int
SIZE
The Constant SIZE.
private static final int
BASELINE_MAX
The Constant BASELINE_MAX.
private static final int
MAX
The Constant MAX.
private int[]
theTable
The table.
private static final int[]
K1LumTable
The Constant K1LumTable.
private static final int[]
K2ChrTable
The Constant K2ChrTable.
public static final JPEGQTable
K1Luminance
The K1Luminance indicates standard table K.1 from JPEG specification and produces "good" quality output.
public static final JPEGQTable
K1Div2Luminance
The K1Div2Luminance indicates K.1 table from JPEG specification with all elements divided by 2 and produces "very good" quality output.
public static final JPEGQTable
K2Chrominance
The K2Chrominance indicates K.2 table from JPEG specification and produces "good" quality output.
public static final JPEGQTable
K2Div2Chrominance
The Constant K2Div2Chrominance indicates K.2 table from JPEG specification with all elements divided by 2 and produces "very good" quality output.
Constructors Summary
public JPEGQTable(int[] table)
Instantiates a new JPEGQTable from the array, which should contain 64 elements in natural order.

param
table the quantization table.


                                         
       
        if (table == null) {
            throw new IllegalArgumentException("table should not be NULL");
        }
        if (table.length != SIZE) {
            throw new IllegalArgumentException("illegal table size: " + table.length);
        }
        theTable = table.clone();
    
Methods Summary
public javax.imageio.plugins.jpeg.JPEGQTablegetScaledInstance(float scaleFactor, boolean forceBaseline)
Gets the scaled instance as quantization table where the values are multiplied by the scaleFactor and then clamped if forceBaseline is true.

param
scaleFactor the scale factor of table.
param
forceBaseline the force baseline flag, the values should be clamped if true.
return
the new quantization table.

        int table[] = new int[SIZE];

        int maxValue = forceBaseline ? BASELINE_MAX : MAX;

        for (int i = 0; i < theTable.length; i++) {
            int rounded = Math.round(theTable[i] * scaleFactor);
            if (rounded < 1) {
                rounded = 1;
            }
            if (rounded > maxValue) {
                rounded = maxValue;
            }
            table[i] = rounded;
        }
        return new JPEGQTable(table);
    
public int[]getTable()
Gets the current quantization table as an array of integer values.

return
the current quantization table as an array of integer values.

        return theTable.clone();
    
public java.lang.StringtoString()
Returns the string representation of this JPEGQTable object.

return
the string representation of this JPEGQTable object.

        // -- TODO more informative info
        return "JPEGQTable";