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

readAll(int imageIndex, ImageReadParam param) does not use param

XMLWordPrintable

    • beta2
    • generic
    • generic



      Name: bkR10012 Date: 04/25/2001


      Spec. of the class javax.imageio.ImageReader says:

      "readAll

      public IIOImage readAll(int imageIndex,
                              ImageReadParam param)
                       throws IOException

           Reads the image indexed by imageIndex and returns an
           IIOImage containing the image, thumbnails, and
           associated image metadata, using a supplied ImageReadParam."
           
      But method readAll does not use ImageReadParam when reading image.
      It uses read(imageIndex) instead of read(imageIndex, param).

      See test source and log below.
      ---------------------------------------- test.java
      import javax.imageio.*;
      import javax.imageio.spi.*;
      import javax.imageio.metadata.*;
      import javax.imageio.stream.MemoryCacheImageInputStream;
      import java.awt.image.BufferedImage;
      import java.io.IOException;
      import java.io.ByteArrayInputStream;
      import java.util.*;

      public class test {
          private final static byte[] ba = {};

          public static void main(String argv[]) {
              ImageReader ireader;
              ImageReadParam irp;
              IIOImage image;
              BufferedImage bi;
              BufferedImage bi_1;
              BufferedImage bi_2;
            
              ireader = new DummyImageReaderImpl(null);
              MemoryCacheImageInputStream mciis = new MemoryCacheImageInputStream
                  (new ByteArrayInputStream(ba));
              ireader.setInput(mciis);

              irp = new ImageReadParam();
              irp.setDestination(new BufferedImage(10, 10,
                                                   BufferedImage.TYPE_3BYTE_BGR));
              try {
                  image = ireader.readAll(0, irp);
                  bi_1 = ireader.read(0, irp);
                  bi_2 = ireader.read(0);
              } catch (java.io.IOException ee) {
                  System.out.println("Unexpected exception: " + ee);
                  return;
              }
              
              bi = (BufferedImage)image.getRenderedImage();
              
              if ( bi.getType() != bi_1.getType()) {
                  System.out.println("Failed.");
                  System.out.println(" readAll(0, irp) " + bi.getType());
                  System.out.println(" read(0, irp) " + bi_1.getType());
                  System.out.println(" read(0) " + bi_2.getType());
              } else {
                  System.out.println("Passed.");
              }
          }
      }

      class DummyImageReaderImpl extends ImageReader {

          public DummyImageReaderImpl(ImageReaderSpi originatingProvider) {
              super(originatingProvider);
          }
          
          public BufferedImage read(int imageIndex, ImageReadParam param)
              throws IOException {
              if (input == null)
                  throw new IllegalStateException();
              if (imageIndex >= 1 || imageIndex < 0)
                  throw new IndexOutOfBoundsException();
              if (seekForwardOnly) {
                  if (imageIndex < minIndex)
                      throw new IndexOutOfBoundsException();
                  minIndex = imageIndex;
              }
              
              return getDestination(param, getImageTypes(imageIndex), 10, 15);
          }

          public Iterator getImageTypes(int imageIndex) throws IOException {
              if (input == null)
                  throw new IllegalStateException();
              if (imageIndex >= 1 || imageIndex < 0)
                  throw new IndexOutOfBoundsException();
                  
              Vector imageTypes = new Vector();
              imageTypes.add(ImageTypeSpecifier.createFromBufferedImageType
                  (BufferedImage.TYPE_BYTE_GRAY ));
              return imageTypes.iterator();
          }

          public int getNumImages(boolean allowSearch) throws IOException {return 1;}
          public int getWidth(int imageIndex) throws IOException {return 1;}
          public int getHeight(int imageIndex) throws IOException {return 1;}
          public IIOMetadata getStreamMetadata() throws IOException {return null;}
          public IIOMetadata getImageMetadata(int imageIndex)
              throws IOException {return null;}
      }
      ----------------------------------------
      % java -version
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b61)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b61, mixed mode)
      % java test
      Failed.
       readAll(0, irp) 10
       read(0, irp) 5
       read(0) 10
      ----------------------------------------

      This bug causes failure of the new JCK test
      api/javax_imageio/ImageReader/index.html#readAll

      ======================================================================

            dricesunw Daniel Rice (Inactive)
            kuzsunw Kuz Kuz (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: