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

JPEG Reader throws IllegalArgumentException when setting the dest type to TYPE_3BYTE_BGR

XMLWordPrintable

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

      I am reading a jpeg image which is created by ImageIO by color convering a TYPE_INT_BGR from sRGB colorspace to CS_GRAY color space. When inspecting this image, JPEG Reader returns 2 image types as supported - TYPE_BYTE_GRAY and TYPE_3BYTE_BGR. When I used TYPE_3BYTE_BGR as the destination type, I am getting an IllegalArgumentException saying source and destination bands differ. This is incorrect. The image should be decodable using all image types returned by getImageTypes().

      This is reproducible atleast since 1.5 on all platforms.

      I have attached a sample image and a test case. Run the testcase passing the attached image on the command line. If you get the following exception, the bug is reproduced.

      java.lang.IllegalArgumentException: ImageReadParam num source & dest bands differ!
      at javax.imageio.ImageReader.checkReadParamBandSettings(ImageReader.java:2746)
      at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:958)
      at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:915)
      at KannanImageIOTest.<init>(KannanImageIOTest.java:107)
      at KannanImageIOTest.main(KannanImageIOTest.java:165)

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

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: