-
Bug
-
Resolution: Fixed
-
P4
-
1.4.0
-
b26
-
x86
-
windows_2000
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8056802 | emb-9 | Unassigned | P4 | Resolved | Fixed | b26 |
JDK-8063741 | 8u45 | Mikhail Cherkasov | P4 | Resolved | Fixed | b01 |
JDK-8049887 | 8u40 | Mikhail Cherkasov | P4 | Resolved | Fixed | b01 |
JDK-8070192 | emb-8u47 | Mikhail Cherkasov | P4 | Resolved | Fixed | team |
JDK-8050487 | 7u80 | Mikhail Cherkasov | P4 | Resolved | Fixed | b02 |
JDK-8061060 | 7u79 | Mikhail Cherkasov | P4 | Resolved | Fixed | b01 |
JDK-8057384 | 7u76 | Mikhail Cherkasov | P4 | Resolved | Fixed | b01 |
Name: cc94850 Date: 02/09/2004
FULL PRODUCT VERSION :
java version "1.4.2"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows 2000 [Version 5.00.2195]
A DESCRIPTION OF THE PROBLEM :
When trying to get the metadata as tree, the first call of the getAsTree() method returns a valid PNGMetadata tree. After setting the metadata from this tree with the setFromTree() method, the metadata object is still intact(node information is correctly stored in the PNGMetadata object). When trying to retreive the metadata as tree again ( getAsTree() ) the returned tree is invalid (bitDepht value is corrupted).
The error is caused by the PNGMetadata.getNativeTree() method:
IHDR_node.setAttribute("bitDepth", Integer.toString(IHDR_bitDepth));
should be:
IHDR_node.setAttribute("bitDepth", IHDR_bitDepths[IHDR_bitDepth]);
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
-create an empty, new PNGMetadata object
-call getAsTree() method
-call setFromTree() method
-call getAsTree() method
-call setFromTree() method
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
bitDepht should have been set to 8
ACTUAL -
bitDepht was set to 3 instead of 8
ERROR MESSAGES/STACK TRACES THAT OCCUR :
javax.imageio.metadata.IIOInvalidTreeException: Illegal value for attribute bitDepth!
at com.sun.imageio.plugins.png.PNGMetadata.fatal(PNGMetadata.java:1076)
at com.sun.imageio.plugins.png.PNGMetadata.getEnumeratedAttribute(PNGMetadata.java:1179)
at com.sun.imageio.plugins.png.PNGMetadata.getEnumeratedAttribute(PNGMetadata.java:1187)
at com.sun.imageio.plugins.png.PNGMetadata.mergeNativeTree(PNGMetadata.java:1243)
at com.sun.imageio.plugins.png.PNGMetadata.mergeTree(PNGMetadata.java:1217)
at javax.imageio.metadata.IIOMetadata.setFromTree(IIOMetadata.java:705)
at TestCase.main(TestCase.java:54)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import java.awt.image.ColorModel;
import java.awt.image.SampleModel;
import java.util.Iterator;
import javax.imageio.ImageIO;
import javax.imageio.ImageTypeSpecifier;
import javax.imageio.ImageWriter;
import javax.imageio.metadata.IIOMetadata;
import org.w3c.dom.Node;
import com.sun.imageio.plugins.png.PNGMetadata;
/*
* Created on 30.01.2004
*/
/**
* @author Beskid Lucian Cristian
*/
public class TestCase {
public static void main(String[] args) {
// getting the writer for the png format
Iterator iter = ImageIO.getImageWritersByFormatName("png");
ImageWriter writer = (ImageWriter)iter.next();
// creating a color model
ColorModel colorModel= ColorModel.getRGBdefault();
// creating a sample model
SampleModel sampleModel = colorModel.createCompatibleSampleModel(640, 480);
// creating a default metadata object
IIOMetadata metaData = writer.getDefaultImageMetadata( new ImageTypeSpecifier(colorModel, sampleModel), null);
if (metaData instanceof PNGMetadata){
System.out.println("Assumption that this is a PNGMetadata object is correct.");
String formatName = metaData.getNativeMetadataFormatName();
// first call
Node metaDataNode = metaData.getAsTree(formatName);
try {
metaData.setFromTree(formatName, metaDataNode);
} catch (Exception ex) {
ex.printStackTrace();
}
// second call (bitdepht is already set to an invalid value)
metaDataNode = metaData.getAsTree(formatName);
// here an exception will occur because of the invalid bit depht
try {
metaData.setFromTree(formatName, metaDataNode);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
No workaround because the getNativeTree() method is private.
(Incident Review ID: 236471)
======================================================================
- backported by
-
JDK-8049887 PNGMetadata.getAsTree() sets bitDepth to invalid value
-
- Resolved
-
-
JDK-8050487 PNGMetadata.getAsTree() sets bitDepth to invalid value
-
- Resolved
-
-
JDK-8056802 PNGMetadata.getAsTree() sets bitDepth to invalid value
-
- Resolved
-
-
JDK-8057384 PNGMetadata.getAsTree() sets bitDepth to invalid value
-
- Resolved
-
-
JDK-8061060 PNGMetadata.getAsTree() sets bitDepth to invalid value
-
- Resolved
-
-
JDK-8063741 PNGMetadata.getAsTree() sets bitDepth to invalid value
-
- Resolved
-
-
JDK-8070192 PNGMetadata.getAsTree() sets bitDepth to invalid value
-
- Resolved
-
- duplicates
-
JDK-8041460 PNGImageWriter creates metadata with incorrect bitDepth
-
- Closed
-
-
JDK-8041460 PNGImageWriter creates metadata with incorrect bitDepth
-
- Closed
-