-
Bug
-
Resolution: Fixed
-
P3
-
1.4.0
-
tiger
-
generic
-
generic
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-2169097 | 1.4.2_19 | Abhijit Saha | P3 | Resolved | Fixed | b04 |
JDK-2166501 | 1.4.2_18-rev | Nikolay Gorshkov | P3 | Resolved | Fixed | b12 |
I am creating a JPEG writer and writing a TYPE_INT_RGB image to a file. After this, i am calling writer.reset(). I am creating a new ImageOutputStream (out of a newly created file) and setting it to the same writer and using the same writer to write another buffered image which is of type TYPE_INT_ARGB. In this case, I am getting an IIOException saying Metadata components are not equal to number of destination bands. The above scenario works fine if both the images are either RGB or ARGB. Unable to write a RGB after ARGB and vice versa.
Any ImageWriter must be reusable and the user should not be expected to create a new writer for each write operation. In the above scenario, the only workaround is to create the JPEGWriter again and the existing writer could not be reused to write another image inspite of restoring it to its initial state.
This is reproducible on Solaris and Win32 right from JDK1.4+.
I have attached a sample code. Execute the same application as follows.
java WriterReuseTest <imgformat>
This will throw an IIOException at the console.
The exception thrown:
javax.imageio.IIOException: Metadata components != number of destination bands
at com.sun.imageio.plugins.jpeg.JPEGImageWriter.checkSOFBands(JPEGImageWriter.java:1162)
at com.sun.imageio.plugins.jpeg.JPEGImageWriter.write(JPEGImageWriter.java:611)
at javax.imageio.ImageWriter.write(ImageWriter.java:591)
at WriterReuseTest.<init>(WriterReuseTest.java:69)
at WriterReuseTest.main(WriterReuseTest.java:101)
Any ImageWriter must be reusable and the user should not be expected to create a new writer for each write operation. In the above scenario, the only workaround is to create the JPEGWriter again and the existing writer could not be reused to write another image inspite of restoring it to its initial state.
This is reproducible on Solaris and Win32 right from JDK1.4+.
I have attached a sample code. Execute the same application as follows.
java WriterReuseTest <imgformat>
This will throw an IIOException at the console.
The exception thrown:
javax.imageio.IIOException: Metadata components != number of destination bands
at com.sun.imageio.plugins.jpeg.JPEGImageWriter.checkSOFBands(JPEGImageWriter.java:1162)
at com.sun.imageio.plugins.jpeg.JPEGImageWriter.write(JPEGImageWriter.java:611)
at javax.imageio.ImageWriter.write(ImageWriter.java:591)
at WriterReuseTest.<init>(WriterReuseTest.java:69)
at WriterReuseTest.main(WriterReuseTest.java:101)
- backported by
-
JDK-2166501 JPEG Writer throws an IIOException when trying to reuse it
- Resolved
-
JDK-2169097 JPEG Writer throws an IIOException when trying to reuse it
- Resolved