-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
6
-
generic, x86
-
generic, windows_xp
FULL PRODUCT VERSION :
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
EXTRA RELEVANT SYSTEM CONFIGURATION :
Display adapter: ATI Radeon HD 2400 XT
A DESCRIPTION OF THE PROBLEM :
A Graphics2D clip region that consists of more than one box will cause a RasterFormatException when a full-size raster reference gets erroneously replaced with the first box's "child" raster. A subsequent box is then, by definition, outside of the first box. To reach the offending code in sun.java2d.loops.Blit.AnyBlit.Blit(), a custom Composite operator and a transform must also be specified.
Found in Java 6u3, retested in 6u10 and the problem is still present.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the provided demo program below.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Call to Graphics2D.drawImage() completes without exception.
ACTUAL -
Exception in thread "main" 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.transformImage(DrawImage.java:148)
at sun.java2d.pipe.DrawImage.transformImage(DrawImage.java:1053)
at sun.java2d.pipe.ValidatePipe.transformImage(ValidatePipe.java:212)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3101)
at Demo2.main(Demo2.java:42)
. . .
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Demo2
{
private static class CustomCompositeContext implements CompositeContext
{
public void dispose() {}
public void compose(Raster src, Raster dstIn, WritableRaster dstOut) {}
}
private static class CustomComposite implements Composite
{
public CompositeContext createContext(ColorModel srcColorModel, ColorModel dstColorModel, RenderingHints hints)
{
return new CustomCompositeContext();
}
}
public static void main(String[] args)
{
ColorModel colorModel = ColorModel.getRGBdefault();
BufferedImage src = new BufferedImage(colorModel, colorModel.createCompatibleWritableRaster(10, 1), false, null);
BufferedImage dst = new BufferedImage(colorModel, colorModel.createCompatibleWritableRaster(10, 2), false, null);
GeneralPath clipShape = new GeneralPath();
clipShape.append(new Rectangle(0, 1, 1, 1), false);
clipShape.append(new Rectangle(2, 1, 1, 1), false);
Graphics2D g2d = dst.createGraphics();
g2d.setComposite(new CustomComposite());
g2d.setClip(clipShape);
g2d.drawImage(src, AffineTransform.getTranslateInstance(0, 1), null);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
I do not have a workaround yet from the application level. The following change to Blit.AnyBlit.Blit() appears to fix the problem:
while (si.nextSpan(span)) {
int w = span[2] - span[0];
int h = span[3] - span[1];
< srcRas = srcRas.createChild(srcx + span[0], srcy + span[1],
< w, h, 0, 0, null);
< dstRas = dstRas.createWritableChild(span[0], span[1],
< w, h, 0, 0, null);
< ctx.compose(srcRas, dstRas, dstRas);
> Raster spanSrcRas = srcRas.createChild(srcx + span[0], srcy + span[1],
> w, h, 0, 0, null);
> WritableRaster spanDstRas = dstRas.createWritableChild(span[0], span[1],
> w, h, 0, 0, null);
> ctx.compose(spanSrcRas, spanDstRas, spanDstRas);
}
java version "1.6.0_10"
Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
Java HotSpot(TM) Client VM (build 11.0-b15, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows XP [Version 5.1.2600]
EXTRA RELEVANT SYSTEM CONFIGURATION :
Display adapter: ATI Radeon HD 2400 XT
A DESCRIPTION OF THE PROBLEM :
A Graphics2D clip region that consists of more than one box will cause a RasterFormatException when a full-size raster reference gets erroneously replaced with the first box's "child" raster. A subsequent box is then, by definition, outside of the first box. To reach the offending code in sun.java2d.loops.Blit.AnyBlit.Blit(), a custom Composite operator and a transform must also be specified.
Found in Java 6u3, retested in 6u10 and the problem is still present.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the provided demo program below.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Call to Graphics2D.drawImage() completes without exception.
ACTUAL -
Exception in thread "main" 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.transformImage(DrawImage.java:148)
at sun.java2d.pipe.DrawImage.transformImage(DrawImage.java:1053)
at sun.java2d.pipe.ValidatePipe.transformImage(ValidatePipe.java:212)
at sun.java2d.SunGraphics2D.drawImage(SunGraphics2D.java:3101)
at Demo2.main(Demo2.java:42)
. . .
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class Demo2
{
private static class CustomCompositeContext implements CompositeContext
{
public void dispose() {}
public void compose(Raster src, Raster dstIn, WritableRaster dstOut) {}
}
private static class CustomComposite implements Composite
{
public CompositeContext createContext(ColorModel srcColorModel, ColorModel dstColorModel, RenderingHints hints)
{
return new CustomCompositeContext();
}
}
public static void main(String[] args)
{
ColorModel colorModel = ColorModel.getRGBdefault();
BufferedImage src = new BufferedImage(colorModel, colorModel.createCompatibleWritableRaster(10, 1), false, null);
BufferedImage dst = new BufferedImage(colorModel, colorModel.createCompatibleWritableRaster(10, 2), false, null);
GeneralPath clipShape = new GeneralPath();
clipShape.append(new Rectangle(0, 1, 1, 1), false);
clipShape.append(new Rectangle(2, 1, 1, 1), false);
Graphics2D g2d = dst.createGraphics();
g2d.setComposite(new CustomComposite());
g2d.setClip(clipShape);
g2d.drawImage(src, AffineTransform.getTranslateInstance(0, 1), null);
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
I do not have a workaround yet from the application level. The following change to Blit.AnyBlit.Blit() appears to fix the problem:
while (si.nextSpan(span)) {
int w = span[2] - span[0];
int h = span[3] - span[1];
< srcRas = srcRas.createChild(srcx + span[0], srcy + span[1],
< w, h, 0, 0, null);
< dstRas = dstRas.createWritableChild(span[0], span[1],
< w, h, 0, 0, null);
< ctx.compose(srcRas, dstRas, dstRas);
> Raster spanSrcRas = srcRas.createChild(srcx + span[0], srcy + span[1],
> w, h, 0, 0, null);
> WritableRaster spanDstRas = dstRas.createWritableChild(span[0], span[1],
> w, h, 0, 0, null);
> ctx.compose(spanSrcRas, spanDstRas, spanDstRas);
}
- duplicates
-
JDK-7049339 Sun2D: Batik: Printing: java.awt.image.RasterFormatException: (x + width) is outside raster
-
- Closed
-