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

drawImage exception when using non-convex clipping regions and custom composite

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3 P3
    • None
    • 6u10
    • client-libs
    • 2d
    • x86
    • windows_2008

      FULL PRODUCT VERSION :
      java version "1.6.0_18"
      Java(TM) SE Runtime Environment (build 1.6.0_18-b07)
      Java HotSpot(TM) Client VM (build 16.0-b13, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [Version 6.0.6002]

      A DESCRIPTION OF THE PROBLEM :
      When using a concave clipping region and a custom composite object, Graphics.drawImage method throws an exception. The problem doesn't occur when AlphaComposite is used.

      The cause looks to be inside sun.java2d.loops.Blit.java, line 157. The source raster is re-assigned with the newly created child raster. When consecutive spans are on the same line (same y coordinate,) the second span will throw an exception as the requested child raster coordinates are outside of the previously created raster area.





      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception in thread "AWT-EventQueue-0" java.awt.image.RasterFormatException: (x + width) is outside raster
              at sun.awt.image.IntegerInterleavedRaster.createWritableChild(IntegerInterleavedRaster.java:450)
              at sun.awt.image.IntegerInterleavedRaster.createChild(IntegerInterleavedRaster.java:499)
              at sun.java2d.loops.Blit$AnyBlit.Blit(Blit.java:157)
              at sun.java2d.pipe.DrawImage.blitSurfaceData(DrawImage.java:927)
              at sun.java2d.pipe.DrawImage.renderImageCopy(DrawImage.java:550)
              at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:73)
              at sun.java2d.pipe.DrawImage.copyImage(DrawImage.java:998)
              at sun.java2d.pipe.ValidatePipe.copyImage(ValidatePipe.java:178)
              at sun.java2d.SunGraphics2D.copyImage(SunGraphics2D.java:2909)
              at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2940)
              at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:2895)

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
          public void paintComponent(Graphics g) {

              super.paintComponent(g);

              Graphics2D g2d = (Graphics2D)g;

              Composite composite = new Composite() {
                  
                  public CompositeContext createContext(ColorModel srcColorModel,
                                                        ColorModel dstColorModel,
                                                        RenderingHints hints) {
                      
                      return new CompositeContext() {
                          public void compose(Raster src, Raster dstIn, WritableRaster dstOut) {}
                          public void dispose() {}
                      };
                  }
              };

              Path2D.Double clip = new Path2D.Double();

              clip.moveTo(0, 0);
              clip.lineTo(200, 100);
              clip.lineTo(400, 0);
              clip.lineTo(200, 400);

              g2d.setClip(clip);
              g2d.setComposite(composite);

              BufferedImage image = new BufferedImage(400, 400, BufferedImage.TYPE_INT_ARGB);
              
              g2d.drawImage(image, 0, 0, 400, 400, null);
          }

      ---------- END SOURCE ----------

            Unassigned Unassigned
            igor Igor Nekrestyanov (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: