jai-imageio-core
  1. jai-imageio-core
  2. JAI_IMAGEIO_CORE-139

RawImageReader: flawed read of images with banded sample model

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.1
    • Fix Version/s: milestone 1
    • Component/s: implementation
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      139

      Description

      RawImageReader does not read images with banded sample model correct. E.g.:

      import java.awt.Dimension;
      import java.awt.color.ColorSpace;
      import java.awt.image.BufferedImage;
      import java.awt.image.DataBuffer;
      import java.awt.image.DataBufferByte;
      import java.awt.image.WritableRaster;
      import java.io.ByteArrayInputStream;
      import java.io.IOException;

      import javax.imageio.ImageIO;
      import javax.imageio.ImageReader;
      import javax.imageio.ImageTypeSpecifier;
      import javax.imageio.stream.ImageInputStream;

      import com.sun.media.imageio.stream.RawImageInputStream;

      public class RawImageReaderTest {

      private static final byte[] RGB_IMAGE =

      { 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'G', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', 'B', }

      ;

      private static final long[] IMAGE_OFFSETS =

      { 0L }

      ;

      private static final Dimension[] IMAGE_DIMENSIONS =

      { new Dimension(4, 4) }

      ;

      private static final int[] OFFSETS_0_0_0 =

      { 0, 0, 0 }

      ;

      private static final int[] OFFSETS_0_1_2 =

      { 0, 1, 2 }

      ;

      private static final ColorSpace sRGB =
      ColorSpace.getInstance(ColorSpace.CS_sRGB);

      private static final ImageTypeSpecifier RGB_PLANE =
      ImageTypeSpecifier.createBanded(sRGB, OFFSETS_0_1_2, OFFSETS_0_0_0,
      DataBuffer.TYPE_BYTE, false, false);

      public static void main(String[] args) throws IOException

      { ImageReader reader = (ImageReader) ImageIO.getImageReadersByFormatName("RAW").next(); ByteArrayInputStream is = new ByteArrayInputStream(RGB_IMAGE); ImageInputStream iis = ImageIO.createImageInputStream(is); RawImageInputStream riis = new RawImageInputStream(iis, RGB_PLANE, IMAGE_OFFSETS, IMAGE_DIMENSIONS); reader.setInput(riis); BufferedImage bi = reader.read(0); WritableRaster raster = bi.getRaster(); DataBuffer data = raster.getDataBuffer(); DataBufferByte bytes = (DataBufferByte) data; System.out.println(new String(bytes.getData(0))); System.out.println(new String(bytes.getData(1))); System.out.println(new String(bytes.getData(2))); }

      }

      Expected output:
      RRRRRRRRRRRRRRRR
      GGGGGGGGGGGGGGGG
      BBBBBBBBBBBBBBBB

      Actual output:
      RRRRRRGGGGGBBBBB
      RRRRRGGGGGGBBBBB
      RRRRRGGGGGBBBBBB

        Activity

        Hide
        gunterze added a comment -

        Created an attachment (id=90)
        adjust width/height of used SampleModel

        Show
        gunterze added a comment - Created an attachment (id=90) adjust width/height of used SampleModel

          People

          • Assignee:
            jai-imageio-core-issues
            Reporter:
            gunterze
          • Votes:
            2 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: