Skip to main content

Bug in ... sun.java2d.pipe.AlphaPaintPipe.renderPathTile()

1 reply [Last post]
jvaudry
Offline
Joined: 2006-05-05

I have a custom PaintContext that implements the following method:

Raster getRaster(int x, int y, int w, int h);

When it provides a Raster that is not a WritableRaster, I see the following exception. However, I believe I should be allowed to use just a Raster, and not a WritableRaster?!?

Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: MyGradientContext$MyRaster
at sun.java2d.pipe.AlphaPaintPipe.renderPathTile(AlphaPaintPipe.java:114)
at sun.java2d.pipe.DuctusShapeRenderer.renderPath(DuctusShapeRenderer.java:102)
at sun.java2d.pipe.DuctusShapeRenderer.fill(DuctusShapeRenderer.java:49)
at sun.java2d.pipe.ValidatePipe.fill(ValidatePipe.java:142)
at sun.java2d.SunGraphics2D.fill(SunGraphics2D.java:2258)

...

Here is the offending line of code from AlphaPaintPipe:

BufferedImage bImg = new BufferedImage(paintModel, (WritableRaster) srcRaster, paintModel.isAlphaPremultiplied(), null);

...

If you know anything about rasters or paint contexts, please answer this question:

When I cache my rasters then I see painting artifacts. I figure this is because somewhere in the Java2D the rasters are being mutated. This can only happen if I provide WritableRasters, so I tried to provide a non-mutable raster, but then I see this exception. So how on earth do I implement a raster cache for a PaintContext object???

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Dmitri Trembovetski

Hi,

this indeed looks like a bug - there's even a comment
in the code to this effect (that it wouldn't work
for non-writable rasters)..

Thanks,
Dmitri

On Wed, Sep 20, 2006 at 10:35:57AM -0700, java2d@javadesktop.org wrote:
> I have a custom PaintContext that implements the following method:
>
> Raster getRaster(int x,
> int y,
> int w,
> int h);
>
> When it provides a Raster that is not a WritableRaster, I see the following exception. However, I believe I should be allowed to use just a Raster, and not a WritableRaster?!?
>
> Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: MyGradientContext$MyRaster
> at sun.java2d.pipe.AlphaPaintPipe.renderPathTile(AlphaPaintPipe.java:114)
> at sun.java2d.pipe.DuctusShapeRenderer.renderPath(DuctusShapeRenderer.java:102)
> at sun.java2d.pipe.DuctusShapeRenderer.fill(DuctusShapeRenderer.java:49)
> at sun.java2d.pipe.ValidatePipe.fill(ValidatePipe.java:142)
> at sun.java2d.SunGraphics2D.fill(SunGraphics2D.java:2258)
> [Message sent by forum member 'jvaudry' (jvaudry)]
>
> http://forums.java.net/jive/thread.jspa?messageID=155092
>
> ===========================================================================
> To unsubscribe, send email to listserv@java.sun.com and include in the body
> of the message "signoff JAVA2D-INTEREST". For general help, send email to
> listserv@java.sun.com and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff JAVA2D-INTEREST". For general help, send email to
listserv@java.sun.com and include in the body of the message "help".