JDK-6294965 : BMP Writer throws exception when writing TYPE_BYTE_BINARY image with BI_BITFIELDS compression
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.imageio
  • Affected Version: 5.0
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2005-07-08
  • Updated: 2011-01-19
  • Resolved: 2005-09-27
Related Reports
Duplicate :  
Relates :  
Description
I am writing a buffered image of type BYTE_BINARY to a file using BMP Writer. Compression Mode is set to MODE_EXPLICIT and compression type is set to BI_BITFIELDS. The image as well as compression modes are supported by the ImageWriter. When I call the write() method of the writer, I am getting an ArrayIndexOutOfBoundsException. 

Here is the exception: 
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
at com.sun.imageio.plugins.bmp.BMPImageWriter.write(BMPImageWriter.java:455)
at BMPWriterByteBinaryTest.<init>(BMPWriterByteBinaryTest.java:119)
at BMPWriterByteBinaryTest.main(BMPWriterByteBinaryTest.java:209)

This is reproducible on all platforms since Tiger-FCS. 

I have attached a sample test and the image. Run the sample test with any mustang build and you will see the above exception on the console.
###@###.### 2005-07-08 12:49:05 GMT

Comments
EVALUATION This problem is very similar to 6294960: the content of BYTE_BINARY image also should be handled by writePixels() procedure in order to provide correct data storage format. We just should use the index color model instance in order to restore RGB color values.
26-09-2005