src/share/classes/com/sun/imageio/plugins/jpeg/DQTMarkerSegment.java
Print this page
rev 9230 : imported patch 8033716
*** 42,52 ****
/**
* A DQT (Define Quantization Table) marker segment.
*/
class DQTMarkerSegment extends MarkerSegment {
! List tables = new ArrayList(); // Could be 1 to 4
DQTMarkerSegment(float quality, boolean needTwo) {
super(JPEG.DQT);
tables.add(new Qtable(true, quality));
if (needTwo) {
--- 42,52 ----
/**
* A DQT (Define Quantization Table) marker segment.
*/
class DQTMarkerSegment extends MarkerSegment {
! List<Qtable> tables = new ArrayList<>(); // Could be 1 to 4
DQTMarkerSegment(float quality, boolean needTwo) {
super(JPEG.DQT);
tables.add(new Qtable(true, quality));
if (needTwo) {
*** 82,106 ****
for (int i = 0; i < size; i++) {
tables.add(new Qtable(children.item(i)));
}
}
! protected Object clone() {
DQTMarkerSegment newGuy = (DQTMarkerSegment) super.clone();
! newGuy.tables = new ArrayList(tables.size());
! Iterator iter = tables.iterator();
while (iter.hasNext()) {
! Qtable table = (Qtable) iter.next();
newGuy.tables.add(table.clone());
}
return newGuy;
}
IIOMetadataNode getNativeNode() {
IIOMetadataNode node = new IIOMetadataNode("dqt");
for (int i= 0; i<tables.size(); i++) {
! Qtable table = (Qtable) tables.get(i);
node.appendChild(table.getNativeNode());
}
return node;
}
--- 82,106 ----
for (int i = 0; i < size; i++) {
tables.add(new Qtable(children.item(i)));
}
}
! protected DQTMarkerSegment clone() {
DQTMarkerSegment newGuy = (DQTMarkerSegment) super.clone();
! newGuy.tables = new ArrayList<>(tables.size());
! Iterator<Qtable> iter = tables.iterator();
while (iter.hasNext()) {
! Qtable table = iter.next();
newGuy.tables.add(table.clone());
}
return newGuy;
}
IIOMetadataNode getNativeNode() {
IIOMetadataNode node = new IIOMetadataNode("dqt");
for (int i= 0; i<tables.size(); i++) {
! Qtable table = tables.get(i);
node.appendChild(table.getNativeNode());
}
return node;
}
*** 115,125 ****
void print() {
printTag("DQT");
System.out.println("Num tables: "
+ Integer.toString(tables.size()));
for (int i= 0; i<tables.size(); i++) {
! Qtable table = (Qtable) tables.get(i);
table.print();
}
System.out.println();
}
--- 115,125 ----
void print() {
printTag("DQT");
System.out.println("Num tables: "
+ Integer.toString(tables.size()));
for (int i= 0; i<tables.size(); i++) {
! Qtable table = tables.get(i);
table.print();
}
System.out.println();
}
*** 138,148 ****
allSame = false;
break;
}
}
if (allSame) {
! newGuy = (Qtable) luma.clone();
newGuy.tableID = 1;
} else {
// Otherwise, find the largest coefficient less than 255. This is
// the largest value that we know did not clamp on scaling.
int largestPos = 0;
--- 138,148 ----
allSame = false;
break;
}
}
if (allSame) {
! newGuy = luma.clone();
newGuy.tableID = 1;
} else {
// Otherwise, find the largest coefficient less than 255. This is
// the largest value that we know did not clamp on scaling.
int largestPos = 0;
*** 266,276 ****
throw new IIOInvalidTreeException
("Invalid node, expected dqtable", node);
}
}
! protected Object clone() {
Qtable newGuy = null;
try {
newGuy = (Qtable) super.clone();
} catch (CloneNotSupportedException e) {} // won't happen
if (data != null) {
--- 266,276 ----
throw new IIOInvalidTreeException
("Invalid node, expected dqtable", node);
}
}
! protected Qtable clone() {
Qtable newGuy = null;
try {
newGuy = (Qtable) super.clone();
} catch (CloneNotSupportedException e) {} // won't happen
if (data != null) {