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

IAE from ImageFormatTool.convertImageFrame()

XMLWordPrintable

      An exception is thrown from ImageFormatTool.convertImageFrame():
      java.lang.IllegalArgumentException: Image scanlineStride is too small
      at com.sun.prism.Image.<init>(Image.java:136)
      at com.sun.prism.Image.fromByteBgraPreData(Image.java:43)
      at com.sun.prism.ImageFormatTool.convertImageFrame(ImageFormatTool.java:43)
      at ImageLoaderTest.start(ImageLoaderTest.java:26)
      at com.sun.javafx.application.LauncherImpl$4.run(LauncherImpl.java:164)
      at com.sun.javafx.application.PlatformImpl$4.run(PlatformImpl.java:126)
      at com.sun.javafx.application.PlatformImpl$3.run(PlatformImpl.java:102)


      A testcase is below; put the attached search.png into /tmp directory. It's also easy to reproduce with Browser demo, just open any Wikipedia article and you'll see the exception.

      import com.sun.javafx.iio.ImageFrame;
      import com.sun.javafx.iio.ImageLoadListener;
      import com.sun.javafx.iio.ImageLoader;
      import com.sun.javafx.iio.ImageMetadata;
      import com.sun.javafx.iio.ImageStorage;
      import com.sun.prism.ImageFormatTool;
      import java.io.FileInputStream;
      import java.io.InputStream;
      import javafx.application.Application;
      import javafx.stage.Stage;


      public class ImageLoaderTest extends Application implements ImageLoadListener {
          
          public static void main(String[] args) {
              launch(ImageLoaderTest.class, args);
          }

          @Override public void start(Stage stage) {
              try {
                  InputStream in = new FileInputStream("/tmp/search.png");
                  ImageFrame[] frames = ImageStorage.loadAll(in, this, 0, 0, true, false);
                  System.out.println("Image loaded");
                  
                  for (int i=0; i<frames.length; i++) {
                      ImageFormatTool.convertImageFrame(frames[i]);
                  }
              } catch (Exception e) {
                  e.printStackTrace();
              }
          }
              
          @Override public void imageLoadProgress(ImageLoader l, float p) {
          }
          @Override public void imageLoadWarning(ImageLoader l, String warning) {
          }
          @Override public void imageLoadMetaData(ImageLoader l, ImageMetadata metadata) {
              System.out.printf("Image size is %dx%d\n", metadata.imageWidth, metadata.imageHeight);
          }
      }

        1. search.png
          0.2 kB
          Peter Zhelezniakov

            kprazdnikwse Kirill.Prazdnikov (Inactive)
            peterz Peter Zhelezniakov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: