下面列出了怎么用javax.imageio.plugins.jpeg.JPEGHuffmanTable的API类实例代码及写法,或者点击链接到github查看源代码。
void print() {
System.out.println("Huffman Table");
System.out.println("table class: "
+ ((tableClass == 0) ? "DC":"AC"));
System.out.println("table id: " + Integer.toString(tableID));
(new JPEGHuffmanTable(numCodes, values)).toString();
/*
System.out.print("Lengths:");
for (int i=0; i<16; i++) {
System.out.print(" " + Integer.toString(numCodes[i]));
}
int count = 0;
if (values.length > 16) {
System.out.println("\nFirst 16 Values:");
count = 16;
} else {
System.out.println("\nValues:");
count = values.length;
}
for (int i=0; i<count; i++) {
System.out.println(Integer.toString(values[i]&0xff));
}
*/
}
void print() {
System.out.println("Huffman Table");
System.out.println("table class: "
+ ((tableClass == 0) ? "DC":"AC"));
System.out.println("table id: " + Integer.toString(tableID));
(new JPEGHuffmanTable(numCodes, values)).toString();
/*
System.out.print("Lengths:");
for (int i=0; i<16; i++) {
System.out.print(" " + Integer.toString(numCodes[i]));
}
int count = 0;
if (values.length > 16) {
System.out.println("\nFirst 16 Values:");
count = 16;
} else {
System.out.println("\nValues:");
count = values.length;
}
for (int i=0; i<count; i++) {
System.out.println(Integer.toString(values[i]&0xff));
}
*/
}
/**
* Returns <code>true</code> if the write was aborted.
*/
private native boolean writeImage(long structPointer,
byte [] data,
int inCsType, int outCsType,
int numBands,
int [] bandSizes,
int srcWidth,
int destWidth, int destHeight,
int stepX, int stepY,
JPEGQTable [] qtables,
boolean writeDQT,
JPEGHuffmanTable[] DCHuffmanTables,
JPEGHuffmanTable[] ACHuffmanTables,
boolean writeDHT,
boolean optimizeHuffman,
boolean progressive,
int numScans,
int [] scans,
int [] componentIds,
int [] HsamplingFactors,
int [] VsamplingFactors,
int [] QtableSelectors,
boolean haveMetadata,
int restartInterval);
void print() {
System.out.println("Huffman Table");
System.out.println("table class: "
+ ((tableClass == 0) ? "DC":"AC"));
System.out.println("table id: " + Integer.toString(tableID));
(new JPEGHuffmanTable(numCodes, values)).toString();
/*
System.out.print("Lengths:");
for (int i=0; i<16; i++) {
System.out.print(" " + Integer.toString(numCodes[i]));
}
int count = 0;
if (values.length > 16) {
System.out.println("\nFirst 16 Values:");
count = 16;
} else {
System.out.println("\nValues:");
count = values.length;
}
for (int i=0; i<count; i++) {
System.out.println(Integer.toString(values[i]&0xff));
}
*/
}
void print() {
System.out.println("Huffman Table");
System.out.println("table class: "
+ ((tableClass == 0) ? "DC":"AC"));
System.out.println("table id: " + Integer.toString(tableID));
(new JPEGHuffmanTable(numCodes, values)).toString();
/*
System.out.print("Lengths:");
for (int i=0; i<16; i++) {
System.out.print(" " + Integer.toString(numCodes[i]));
}
int count = 0;
if (values.length > 16) {
System.out.println("\nFirst 16 Values:");
count = 16;
} else {
System.out.println("\nValues:");
count = values.length;
}
for (int i=0; i<count; i++) {
System.out.println(Integer.toString(values[i]&0xff));
}
*/
}
/**
* Returns <code>true</code> if the read was aborted.
*/
private native boolean readImage(int imageIndex,
long structPointer,
byte [] buffer,
int numRasterBands,
int [] srcBands,
int [] bandSizes,
int sourceXOffset, int sourceYOffset,
int sourceWidth, int sourceHeight,
int periodX, int periodY,
JPEGQTable [] abbrevQTables,
JPEGHuffmanTable [] abbrevDCHuffmanTables,
JPEGHuffmanTable [] abbrevACHuffmanTables,
int minProgressivePass,
int maxProgressivePass,
boolean wantUpdates);
/**
* Returns {@code true} if the read was aborted.
*/
private native boolean readImage(int imageIndex,
long structPointer,
byte [] buffer,
int numRasterBands,
int [] srcBands,
int [] bandSizes,
int sourceXOffset, int sourceYOffset,
int sourceWidth, int sourceHeight,
int periodX, int periodY,
JPEGQTable [] abbrevQTables,
JPEGHuffmanTable [] abbrevDCHuffmanTables,
JPEGHuffmanTable [] abbrevACHuffmanTables,
int minProgressivePass,
int maxProgressivePass,
boolean wantUpdates);
/**
* Returns <code>true</code> if the write was aborted.
*/
private native boolean writeImage(long structPointer,
byte [] data,
int inCsType, int outCsType,
int numBands,
int [] bandSizes,
int srcWidth,
int destWidth, int destHeight,
int stepX, int stepY,
JPEGQTable [] qtables,
boolean writeDQT,
JPEGHuffmanTable[] DCHuffmanTables,
JPEGHuffmanTable[] ACHuffmanTables,
boolean writeDHT,
boolean optimizeHuffman,
boolean progressive,
int numScans,
int [] scans,
int [] componentIds,
int [] HsamplingFactors,
int [] VsamplingFactors,
int [] QtableSelectors,
boolean haveMetadata,
int restartInterval);
/**
* Returns <code>true</code> if the write was aborted.
*/
private native boolean writeImage(long structPointer,
byte [] data,
int inCsType, int outCsType,
int numBands,
int [] bandSizes,
int srcWidth,
int destWidth, int destHeight,
int stepX, int stepY,
JPEGQTable [] qtables,
boolean writeDQT,
JPEGHuffmanTable[] DCHuffmanTables,
JPEGHuffmanTable[] ACHuffmanTables,
boolean writeDHT,
boolean optimizeHuffman,
boolean progressive,
int numScans,
int [] scans,
int [] componentIds,
int [] HsamplingFactors,
int [] VsamplingFactors,
int [] QtableSelectors,
boolean haveMetadata,
int restartInterval);
/**
* Returns {@code true} if the write was aborted.
*/
private native boolean writeImage(long structPointer,
byte [] data,
int inCsType, int outCsType,
int numBands,
int [] bandSizes,
int srcWidth,
int destWidth, int destHeight,
int stepX, int stepY,
JPEGQTable [] qtables,
boolean writeDQT,
JPEGHuffmanTable[] DCHuffmanTables,
JPEGHuffmanTable[] ACHuffmanTables,
boolean writeDHT,
boolean optimizeHuffman,
boolean progressive,
int numScans,
int [] scans,
int [] componentIds,
int [] HsamplingFactors,
int [] VsamplingFactors,
int [] QtableSelectors,
boolean haveMetadata,
int restartInterval);
void print() {
System.out.println("Huffman Table");
System.out.println("table class: "
+ ((tableClass == 0) ? "DC":"AC"));
System.out.println("table id: " + Integer.toString(tableID));
(new JPEGHuffmanTable(numCodes, values)).toString();
/*
System.out.print("Lengths:");
for (int i=0; i<16; i++) {
System.out.print(" " + Integer.toString(numCodes[i]));
}
int count = 0;
if (values.length > 16) {
System.out.println("\nFirst 16 Values:");
count = 16;
} else {
System.out.println("\nValues:");
count = values.length;
}
for (int i=0; i<count; i++) {
System.out.println(Integer.toString(values[i]&0xff));
}
*/
}
/**
* Returns <code>true</code> if the write was aborted.
*/
private native boolean writeImage(long structPointer,
byte [] data,
int inCsType, int outCsType,
int numBands,
int [] bandSizes,
int srcWidth,
int destWidth, int destHeight,
int stepX, int stepY,
JPEGQTable [] qtables,
boolean writeDQT,
JPEGHuffmanTable[] DCHuffmanTables,
JPEGHuffmanTable[] ACHuffmanTables,
boolean writeDHT,
boolean optimizeHuffman,
boolean progressive,
int numScans,
int [] scans,
int [] componentIds,
int [] HsamplingFactors,
int [] VsamplingFactors,
int [] QtableSelectors,
boolean haveMetadata,
int restartInterval);
/**
* Returns <code>true</code> if the write was aborted.
*/
private native boolean writeImage(long structPointer,
byte [] data,
int inCsType, int outCsType,
int numBands,
int [] bandSizes,
int srcWidth,
int destWidth, int destHeight,
int stepX, int stepY,
JPEGQTable [] qtables,
boolean writeDQT,
JPEGHuffmanTable[] DCHuffmanTables,
JPEGHuffmanTable[] ACHuffmanTables,
boolean writeDHT,
boolean optimizeHuffman,
boolean progressive,
int numScans,
int [] scans,
int [] componentIds,
int [] HsamplingFactors,
int [] VsamplingFactors,
int [] QtableSelectors,
boolean haveMetadata,
int restartInterval);
Htable(Node node) throws IIOInvalidTreeException {
if (node.getNodeName().equals("dhtable")) {
NamedNodeMap attrs = node.getAttributes();
int count = attrs.getLength();
if (count != 2) {
throw new IIOInvalidTreeException
("dhtable node must have 2 attributes", node);
}
tableClass = getAttributeValue(node, attrs, "class", 0, 1, true);
tableID = getAttributeValue(node, attrs, "htableId", 0, 3, true);
if (node instanceof IIOMetadataNode) {
IIOMetadataNode ourNode = (IIOMetadataNode) node;
JPEGHuffmanTable table =
(JPEGHuffmanTable) ourNode.getUserObject();
if (table == null) {
throw new IIOInvalidTreeException
("dhtable node must have user object", node);
}
numCodes = table.getLengths();
values = table.getValues();
} else {
throw new IIOInvalidTreeException
("dhtable node must have user object", node);
}
} else {
throw new IIOInvalidTreeException
("Invalid node, expected dqtable", node);
}
}
Htable(Node node) throws IIOInvalidTreeException {
if (node.getNodeName().equals("dhtable")) {
NamedNodeMap attrs = node.getAttributes();
int count = attrs.getLength();
if (count != 2) {
throw new IIOInvalidTreeException
("dhtable node must have 2 attributes", node);
}
tableClass = getAttributeValue(node, attrs, "class", 0, 1, true);
tableID = getAttributeValue(node, attrs, "htableId", 0, 3, true);
if (node instanceof IIOMetadataNode) {
IIOMetadataNode ourNode = (IIOMetadataNode) node;
JPEGHuffmanTable table =
(JPEGHuffmanTable) ourNode.getUserObject();
if (table == null) {
throw new IIOInvalidTreeException
("dhtable node must have user object", node);
}
numCodes = table.getLengths();
values = table.getValues();
} else {
throw new IIOInvalidTreeException
("dhtable node must have user object", node);
}
} else {
throw new IIOInvalidTreeException
("Invalid node, expected dqtable", node);
}
}
IIOMetadataNode getNativeNode() {
IIOMetadataNode node = new IIOMetadataNode("dhtable");
node.setAttribute("class", Integer.toString(tableClass));
node.setAttribute("htableId", Integer.toString(tableID));
node.setUserObject(new JPEGHuffmanTable(numCodes, values));
return node;
}
IIOMetadataNode getNativeNode() {
IIOMetadataNode node = new IIOMetadataNode("dhtable");
node.setAttribute("class", Integer.toString(tableClass));
node.setAttribute("htableId", Integer.toString(tableID));
node.setUserObject(new JPEGHuffmanTable(numCodes, values));
return node;
}
/**
* Returns <code>true</code> if the read was aborted.
*/
private native boolean readImage(long structPointer,
byte [] buffer,
int numRasterBands,
int [] srcBands,
int [] bandSizes,
int sourceXOffset, int sourceYOffset,
int sourceWidth, int sourceHeight,
int periodX, int periodY,
JPEGQTable [] abbrevQTables,
JPEGHuffmanTable [] abbrevDCHuffmanTables,
JPEGHuffmanTable [] abbrevACHuffmanTables,
int minProgressivePass,
int maxProgressivePass,
boolean wantUpdates);
/**
* Return an array of default Huffman tables.
*/
static JPEGHuffmanTable [] getDefaultHuffmanTables(boolean wantDC) {
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;
}
DHTMarkerSegment(boolean needFour) {
super(JPEG.DHT);
tables.add(new Htable(JPEGHuffmanTable.StdDCLuminance, true, 0));
if (needFour) {
tables.add(new Htable(JPEGHuffmanTable.StdDCChrominance, true, 1));
}
tables.add(new Htable(JPEGHuffmanTable.StdACLuminance, false, 0));
if (needFour) {
tables.add(new Htable(JPEGHuffmanTable.StdACChrominance, false, 1));
}
}
DHTMarkerSegment(boolean needFour) {
super(JPEG.DHT);
tables.add(new Htable(JPEGHuffmanTable.StdDCLuminance, true, 0));
if (needFour) {
tables.add(new Htable(JPEGHuffmanTable.StdDCChrominance, true, 1));
}
tables.add(new Htable(JPEGHuffmanTable.StdACLuminance, false, 0));
if (needFour) {
tables.add(new Htable(JPEGHuffmanTable.StdACChrominance, false, 1));
}
}
DHTMarkerSegment(JPEGHuffmanTable[] dcTables,
JPEGHuffmanTable[] acTables) {
super(JPEG.DHT);
for (int i = 0; i < dcTables.length; i++) {
tables.add(new Htable(dcTables[i], true, i));
}
for (int i = 0; i < acTables.length; i++) {
tables.add(new Htable(acTables[i], false, i));
}
}
/**
* Returns <code>true</code> if the read was aborted.
*/
private native boolean readImage(long structPointer,
byte [] buffer,
int numRasterBands,
int [] srcBands,
int [] bandSizes,
int sourceXOffset, int sourceYOffset,
int sourceWidth, int sourceHeight,
int periodX, int periodY,
JPEGQTable [] abbrevQTables,
JPEGHuffmanTable [] abbrevDCHuffmanTables,
JPEGHuffmanTable [] abbrevACHuffmanTables,
int minProgressivePass,
int maxProgressivePass,
boolean wantUpdates);
IIOMetadataNode getNativeNode() {
IIOMetadataNode node = new IIOMetadataNode("dhtable");
node.setAttribute("class", Integer.toString(tableClass));
node.setAttribute("htableId", Integer.toString(tableID));
node.setUserObject(new JPEGHuffmanTable(numCodes, values));
return node;
}
/**
* Return an array of default Huffman tables.
*/
static JPEGHuffmanTable [] getDefaultHuffmanTables(boolean wantDC) {
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;
}
Htable(Node node) throws IIOInvalidTreeException {
if (node.getNodeName().equals("dhtable")) {
NamedNodeMap attrs = node.getAttributes();
int count = attrs.getLength();
if (count != 2) {
throw new IIOInvalidTreeException
("dhtable node must have 2 attributes", node);
}
tableClass = getAttributeValue(node, attrs, "class", 0, 1, true);
tableID = getAttributeValue(node, attrs, "htableId", 0, 3, true);
if (node instanceof IIOMetadataNode) {
IIOMetadataNode ourNode = (IIOMetadataNode) node;
JPEGHuffmanTable table =
(JPEGHuffmanTable) ourNode.getUserObject();
if (table == null) {
throw new IIOInvalidTreeException
("dhtable node must have user object", node);
}
numCodes = table.getLengths();
values = table.getValues();
} else {
throw new IIOInvalidTreeException
("dhtable node must have user object", node);
}
} else {
throw new IIOInvalidTreeException
("Invalid node, expected dqtable", node);
}
}
DHTMarkerSegment(JPEGHuffmanTable[] dcTables,
JPEGHuffmanTable[] acTables) {
super(JPEG.DHT);
for (int i = 0; i < dcTables.length; i++) {
tables.add(new Htable(dcTables[i], true, i));
}
for (int i = 0; i < acTables.length; i++) {
tables.add(new Htable(acTables[i], false, i));
}
}
IIOMetadataNode getNativeNode() {
IIOMetadataNode node = new IIOMetadataNode("dhtable");
node.setAttribute("class", Integer.toString(tableClass));
node.setAttribute("htableId", Integer.toString(tableID));
node.setUserObject(new JPEGHuffmanTable(numCodes, values));
return node;
}
/**
* Return an array of default Huffman tables.
*/
static JPEGHuffmanTable [] getDefaultHuffmanTables(boolean wantDC) {
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;
}
DHTMarkerSegment(boolean needFour) {
super(JPEG.DHT);
tables.add(new Htable(JPEGHuffmanTable.StdDCLuminance, true, 0));
if (needFour) {
tables.add(new Htable(JPEGHuffmanTable.StdDCChrominance, true, 1));
}
tables.add(new Htable(JPEGHuffmanTable.StdACLuminance, false, 0));
if (needFour) {
tables.add(new Htable(JPEGHuffmanTable.StdACChrominance, false, 1));
}
}