JDK-4474819 : No 16-bit PNG writers found on Windows/Linux.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.imageio
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: other,linux,windows_98
  • CPU: x86
  • Submitted: 2001-06-26
  • Updated: 2002-03-05
  • Resolved: 2002-02-21
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.1 hopperFixed
Related Reports
Relates :  
Relates :  
Description
This problem started on the beta refresh build, b63a. Build b69 was the build in which we found this bug.

Though the problem seems to appear only on Windows and Linux, even across different Windows machines, it doesn't appear on every Windows machine tested on. It appears on some while it does not on others. I was able to reproduce it on a Win98 and Win2000 machine.

Steps to reproduce:

1) Compile all the classes in the attached tar file.
2) Execute:

% java TestPNGReaderWriter

3) Once the GUI comes up with a single "Start" JButton, click on the button.
4) A PNG file of the button should be created in the same directory. It is also at this point in which the NPE often comes up on many Windows/Linux machines.

-----------------------------------------
java.lang.NullPointerException
        at PNGReaderWriter.writePNGImage(PNGReaderWriter.java:102)
        at TestPNGReaderWriter.actionPerformed(TestPNGReaderWriter.java:35)
        at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:17
63)
        at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Abstra
ctButton.java:1816)
        at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel
.java:414)
        at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:253
)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonL
istener.java:261)
        at java.awt.Component.processMouseEvent(Component.java:4972)
        at java.awt.Component.processEvent(Component.java:4782)
        at java.awt.Container.processEvent(Container.java:1383)
        at java.awt.Component.dispatchEventImpl(Component.java:3492)
        at java.awt.Container.dispatchEventImpl(Container.java:1440)
        at java.awt.Component.dispatchEvent(Component.java:3353)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3176
)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2889)

        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2842)
        at java.awt.Container.dispatchEventImpl(Container.java:1426)
        at java.awt.Window.dispatchEventImpl(Window.java:1531)
        at java.awt.Component.dispatchEvent(Component.java:3353)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:439)
        at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:15
0)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)

        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:131)

        at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
-------------------------------------------

Again, if you cannot reproduce it on your machine, please come see me and I'll reproduce it on our machines for you.


edmund.lou@eng 2001-06-26
=======================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: hopper FIXED IN: hopper INTEGRATED IN: hopper VERIFIED IN: hopper
14-06-2004

PUBLIC COMMENTS Verified in b03. ###@###.### 2002-03-05
05-03-2002

WORK AROUND Either set the display depth to 8 or 32 bits -- or don't use Jomponent.createImage to get a compatible image. Instead use a BufferedImage with 8 or 32 bits. jeannette.hung@Eng 2001-07-17 Developers should be able to use a PNGImageWriter directly by calling ImageIO.getImageWritersByFormatName("png") and using the returned ImageWriter to encode an image of TYPE_USHORT_565_RGB. ###@###.### 2002-02-07
07-02-2002

SUGGESTED FIX Change the check in canEncodeImage() so that it ensures that the maximum bit depth across all channels is within the acceptable limits (1..16). ###@###.### 2002-02-07
07-02-2002

EVALUATION ImageIO.getImageWriters(typeSpecifier, "png") isn't finding any PNG writers on Windows (I tested NT and Sparc). My NT display was running 16bits and they are using JComponent.createImage(). Most likely if they used a BufferedImage with xBGR, it would work fine. jeannette.hung@Eng 2001-06-26 The problem lies in PNGImageWriterSpi.canEncodeImage(). There is a check to see if all channels have the same sample size. If not, canEncodeImage() would return false. In the case of a USHORT_565_RGB image, the bands have different sample sizes (5, 6, and 5 respectively) but the PNGImageWriter can indeed handle this format. (There is another fixed bug, 4413109, which addresses similar problems in PNGMetadata and PNGImageWriter.) The check in canEncodeImage() should instead make sure that the maximum bit depth across all channels is within the acceptable limits (similar to the fix for 4413109). ###@###.### 2002-02-07
07-02-2002