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

ArrayIndexOutOfBoundsException during image rendering

XMLWordPrintable

    • 2d
    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Identification: JOSM/1.5 (18837 SVN en) Mac OS X 13.5.2
      OS Build number: macOS 13.5.2 (22G91)
      Memory Usage: 847 MB / 2048 MB (170 MB allocated, but free)
      Java version: 21+35, Azul Systems, Inc., OpenJDK 64-Bit Server VM
      Look and Feel: com.apple.laf.AquaLookAndFeel
      Screen: Display 188945233 1920×1080 (scaling 1.00×1.00) Display 188945231 1920×1080 (scaling 1.00×1.00) Display 69733382 1680×1050 (scaling 2.00×2.00)
      Maximum Screen Size: 1920×1080
      Best cursor sizes: 16×16→16×16, 32×32→32×32
      System property file.encoding: UTF-8
      System property sun.jnu.encoding: UTF-8
      Locale info: en_US

      A DESCRIPTION OF THE PROBLEM :
      Java cannot properly load tiffs from NOAA.

      Test file from https://www.ncei.noaa.gov/maps/grid-extract/ EMAG2v3_Sealevel dataset, AOI is -77.38, 36.17, -75.55, 37.26

      Test file: https://gis.ngdc.noaa.gov/arcgis/rest/services/EMAG2v3/ImageServer/exportImage?bbox=-77.40000,36.20000,-75.56667,37.26667&bboxSR=4326&size=55,32&imageSR=4326&format=tiff&pixelType=F32&interpolation=+RSP_NearestNeighbor&compression=LZ77&nodata=-999&mosaicRule={%22where%22:%22Name=%27EMAG2_V3_20170530_SeaLevel%27%22}&f=image

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Download an AOI from NOAA from the EMAG2v3_SeaLevel dataset; other datasets may trigger this bug, but that is what was tested.
      2. Load the tiff using ImageIO
      3. Attempt to paint the tiff via a Graphics object
      4. Crash

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      TIFF to be properly loaded and painted
      ACTUAL -
      Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -65469464
      at java.awt.image.ComponentColorModel.getRGBComponent(ComponentColorModel.java:903)
      at java.awt.image.ComponentColorModel.getRed(ComponentColorModel.java:944)
      at java.awt.image.ComponentColorModel.getRGB(ComponentColorModel.java:1135)
      at sun.java2d.loops.OpaqueCopyAnyToArgb.Blit(CustomComponent.java:145)
      at sun.java2d.pipe.DrawImage.blitSurfaceData(DrawImage.java:959)
      at sun.java2d.pipe.DrawImage.renderImageCopy(DrawImage.java:577)
      at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:67)
      at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:1014)
      at sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:186)
      at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3325)
      at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3303)
      at Scratch.main(scratch_10.java:15)


      ---------- BEGIN SOURCE ----------
      import java.awt.Image;
      import java.awt.image.BufferedImage;
      import java.io.IOException;
      import java.net.URI;
      import java.text.MessageFormat;

      import javax.imageio.ImageIO;

      class Scratch {
          public static void main(String[] args) throws IOException {
              // If this stops working, download and read a file from https://www.ncei.noaa.gov/maps/grid-extract/
              // This test case is from the EMAG2v3_SeaLevel dataset with an AOI of -77.38, 36.17, -75.55, 37.26
              Image image = ImageIO.read(URI.create("https://gis.ngdc.noaa.gov/arcgis/rest/services/EMAG2v3/ImageServer/exportImage?bbox=-77.40000,36.20000,-75.56667,37.26667&bboxSR=4326&size=55,32&imageSR=4326&format=tiff&pixelType=F32&interpolation=+RSP_NearestNeighbor&compression=LZ77&nodata=-999&mosaicRule=%7B%22where%22:%22Name=%27EMAG2_V3_20170530_SeaLevel%27%22%7D&f=image").toURL());
              Image paint = new BufferedImage(image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_ARGB);
              System.out.println(MessageFormat.format("Image: {0}x{1}", image.getWidth(null), image.getHeight(null)));
              paint.getGraphics().drawImage(image, 0, 0, null);
              System.out.println("It worked");
          }
      }
      ---------- END SOURCE ----------

      FREQUENCY : always


        1. exportImage.tiff
          10 kB
        2. LoadImageApp.java
          1 kB
        3. sample.tiff
          1.75 MB

            prr Philip Race
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated: