Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6294960

BMP Reader throws NPE when reading TYPE_BYTE_GRAY encoded by BMP Writer with BI_BITFIELDS compressn

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 5.0
    • client-libs

      I am encoding a TYPE_BYTE_GRAY buffered image using BMP ImageWriter and writing this image to a file. I am setting the compression mode to MODE_EXPLICIT and setting the compression type to BI_BITFIELDS compression type. BMP writer claims that it supports the given buffered image and the given compression type. canEncodeImage() method of BMPWriter does not enforce any restriction for this combination. The writing process was successful But there was a NPE when I tried to read the image back from the file using BMP ImageReader.

      Here is the exception:
      Exception in thread "main" java.lang.NullPointerException
      at com.sun.imageio.plugins.bmp.BMPImageReader.readHeader(BMPImageReader.java:510)
      at com.sun.imageio.plugins.bmp.BMPImageReader.read(BMPImageReader.java:657)
      at javax.imageio.ImageIO.read(ImageIO.java:1400)
      at javax.imageio.ImageIO.read(ImageIO.java:1286)
      at BMPWriterByteGrayTest.<init>(BMPWriterByteGrayTest.java:135)
      at BMPWriterByteGrayTest.main(BMPWriterByteGrayTest.java:208)

      This is reproducible on all platforms, since Tiger-FCS.

      I have attached a sample test and the image. Execute the sample test as follows:
      'java BMPWriterByteGrayTest bmp'. You would see the above exception on the console.
      ###@###.### 2005-07-08 12:29:57 GMT

      The same exception is reproducible when writing TYPE_BYTE_INDEXED image also, with the same compression type.
      ###@###.### 2005-07-08 12:38:09 GMT

            bae Andrew Brygin
            pmohansunw Praveen Mohan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: