-
Bug
-
Resolution: Won't Fix
-
P4
-
1.4.0, 5.0, 6u23, 6u38, 7
-
generic
-
generic
There is a method setDestination() in ImageReadParam which can be used to
specify a destination image. As per the specification, this must be one of the types returned by ImageReader.getImageTypes(). The API doc of setDestination() claims that if the image specified by this method does not use the sample model and color model used by one of the type specifiers returned by getImageTypes(), read() method would throw an IIOException. But If i specify a buffered image
type which uses a different color model and sample model, read() method either throws IllegalArgException saying the bands on source and destination mismatch or it throws a ClassCastException.
For JPEG and PNG, it throws IllegalArgumentException. for GIF, it throws ClassCastException. For BMP, it throws NullPointerException. But I don't see any IIOException being thrown. It would be great if all these readers are made consistant in handling an incompatible destination. However the NPE thrown by BMP ImageReader is weird and must be more meaningful.
Though the API doc for read() method claims that it would throw an IllegalArgException it is conflicting with setDestination() method which tells the user that it would throw an IIOException. Either it must be fixed or the doc must be modified.
This bug is reproducible since JDK1.4+ on Win32 as well as Solaris platforms.
I have attached a sample code. Execute the sample code as follows.
java SetDestinationTest <img file>. Ex: java SetDestinationTest cup.png
You will see a frame with a drop-down at the bottom. Choose the buffered image types one by one and you will see various exceptions in the console.
specify a destination image. As per the specification, this must be one of the types returned by ImageReader.getImageTypes(). The API doc of setDestination() claims that if the image specified by this method does not use the sample model and color model used by one of the type specifiers returned by getImageTypes(), read() method would throw an IIOException. But If i specify a buffered image
type which uses a different color model and sample model, read() method either throws IllegalArgException saying the bands on source and destination mismatch or it throws a ClassCastException.
For JPEG and PNG, it throws IllegalArgumentException. for GIF, it throws ClassCastException. For BMP, it throws NullPointerException. But I don't see any IIOException being thrown. It would be great if all these readers are made consistant in handling an incompatible destination. However the NPE thrown by BMP ImageReader is weird and must be more meaningful.
Though the API doc for read() method claims that it would throw an IllegalArgException it is conflicting with setDestination() method which tells the user that it would throw an IIOException. Either it must be fixed or the doc must be modified.
This bug is reproducible since JDK1.4+ on Win32 as well as Solaris platforms.
I have attached a sample code. Execute the sample code as follows.
java SetDestinationTest <img file>. Ex: java SetDestinationTest cup.png
You will see a frame with a drop-down at the bottom. Choose the buffered image types one by one and you will see various exceptions in the console.
- relates to
-
JDK-8154352 ImageReadParam.setDestination(wrong) results in assortment of failures
- Open
-
JDK-6433172 BMPImageReader fails if the Destination is set
- Closed