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

PIT: GIF ImageWriter fails by throwing IllegalArgException for many of the input images

XMLWordPrintable

    • beta
    • generic
    • generic
    • Verified

      I have written an application that does the following:

      1. reads gif / jpeg / png images using Toolkit API.
      2. Creates a BufferedImage of type INT_RGB
      3. Draws the image to the buffered image
      4. Checks whether this buffered image is supported by the GIF Writer (WriterSpi.canEncodeImage()).
      5. Creates an output file and sets the output for the writer.
      6. Writes the buffered image by calling ImageWriter.write(bi).

      As soon as I do this, I am getting an IllegalArgumentException which is given below:

      java.lang.IllegalArgumentException: Bad value 237!
      at com.sun.imageio.plugins.gif.GIFImageWriter.getNumBits(GIFImageWriter.java:133)
      at com.sun.imageio.plugins.gif.GIFImageWriter.write(GIFImageWriter.java:604)
      at com.sun.imageio.plugins.gif.GIFImageWriter.write(GIFImageWriter.java:453)
      at javax.imageio.ImageWriter.write(ImageWriter.java:598)
      at WriterTest.createBufferedImage(WriterTest.java:59)
      at WriterTest.<init>(WriterTest.java:27)
      at WriterTest.main(WriterTest.java:71)

      This exception is very widely seen across different input images and all the input images that I used are valid and well supported by other writers. The only diff across different input images is that the no given (237) in the exception is different.

      This is a basic functionality and should work fine. This is reproducible on all platforms with the following PIT build:
      java version "1.6.0-2d.pit-jcg-win-03"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-2d.pit-jcg-win-03-java2d_23_may_2005_02_25-b00)
      Java HotSpot(TM) Client VM (build 1.6.0-ea-b37, mixed mode)

      I have attached a sample test and few sample images that were used. Run the test passing one of the image files. You would see the above exception on the console.
      ###@###.### 2005-05-24 14:01:21 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: