0 Replies Latest reply: Dec 15, 2010 11:11 PM by 824356 RSS

    Invalid code encountered while decoding 2D group 4 compressed data.

    824356
      Hi,

      We are getting encoded data stream image from another application. When we are
      trying to do decode and scale the images, we are getting 2 kind of exceptions on
      some TIFF images. Exceptions and codes are given below. I am getting the same
      error when I use ImageIO. Can you please help me to get some solution or
      alternatives for this issue.

      Code:
                     ByteArraySeekableStream bytearrayseekablestream = new
      ByteArraySeekableStream((byte[])byteArray);
                     String as[] = ImageCodec.getDecoderNames(bytearrayseekablestream);
                     ImageDecoder imagedecoder = ImageCodec.createImageDecoder(as[0],
      bytearrayseekablestream, null);
                     RenderedImage rend = imagedecoder.decodeAsRenderedImage(0);     
                     PlanarImage plnrImage = PlanarImage.wrapRenderedImage(rend);
                     BufferedImage bImage = plnrImage.getAsBufferedImage(); --> Getting Exception
      on this line.
                     
      Exception
      -----------------
                     
      java.lang.RuntimeException: Invalid code encountered while decoding 2D group 4
      compressed data.
           at com.sun.media.jai.codecimpl.TIFFFaxDecoder.decodeT6(TIFFFaxDecoder.java:1030)
           at com.sun.media.jai.codecimpl.TIFFImage.getTile(TIFFImage.java:1075)
           at javax.media.jai.RenderedImageAdapter.getTile(RenderedImageAdapter.java:148)
           at javax.media.jai.NullOpImage.computeTile(NullOpImage.java:162)
           at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
           at javax.media.jai.OpImage.getTile(OpImage.java:1129)
           at javax.media.jai.PlanarImage.copyData(PlanarImage.java:2343)
           at javax.media.jai.PlanarImage.getAsBufferedImage(PlanarImage.java:2525)
           at javax.media.jai.PlanarImage.getAsBufferedImage(PlanarImage.java:2546)

      java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 614
           at
      com.sun.media.jai.codecimpl.TIFFFaxDecoder.nextLesserThan8Bits(TIFFFaxDecoder.java:1484)
           at com.sun.media.jai.codecimpl.TIFFFaxDecoder.decodeT6(TIFFFaxDecoder.java:955)
           at com.sun.media.jai.codecimpl.TIFFImage.getTile(TIFFImage.java:1075)
           at javax.media.jai.RenderedImageAdapter.getTile(RenderedImageAdapter.java:148)
           at javax.media.jai.NullOpImage.computeTile(NullOpImage.java:162)
           at com.sun.media.jai.util.SunTileScheduler.scheduleTile(SunTileScheduler.java:904)
           at javax.media.jai.OpImage.getTile(OpImage.java:1129)
           at javax.media.jai.PlanarImage.copyData(PlanarImage.java:2343)
           at javax.media.jai.PlanarImage.getAsBufferedImage(PlanarImage.java:2525)
           at javax.media.jai.PlanarImage.getAsBufferedImage(PlanarImage.java:2546)
      -