Hi,

Since you called me out by name, I feel compelled to respond...

I'm not sure which version of the JDK you're using, but the
original 1.4 VolatileImage was opaque-only.  The original use-case
for these images was as back buffers or other inherently
opaque images.

We introduced VolatileImage with transparency in a later release
(1.5?), although these images are not typically accelerated in the
same way as opaque VolatileImages (with the exception of the OpenGL
pipeline; VolatileImages get pretty good acceleration there in
general).

I'm assuming you're using the latter release that actually allows
creation of transparent or translucent VolatileImages.  In this
case, the trick is to erase that VolatileImage with a transparent
background color first.  Or, you can copy your transparent-background
image onto the VolatileImage with Src; the SrcOver operation will
ignore the transparent background in your source image and leave the
pixel values in the destination image.  So if you didn't erase the
VolatileImage to transparent first, then you may get stuck with
some opaque pixels there instead.

For sample code on this, check out the Intermediate Images article
here:
       http://java.sun.com/developer/technicalArticles/Media/intimages/
(go to the code snippet that renders the transparent-background
smiley correctly, about half-way through the article).
The article not using a VolatileImage, but the approach is similar
insofar as the need for a transparent background on the destination
image.

Note, with respect to my diatribe above on performance, that there
may not be a compelling reason to use VolatileImage here (you could
just use a managed image, as shown in the Intermediate Images article).
Any reason you're trying to use VolatileImage here instead?

Chet.




[EMAIL PROTECTED] wrote:
I'm having some problems with my VolatileImages:

First, I load PNG files with transparent regions into BufferedImages using 
ImageIO and then draw them into VolatileImages. When these VolatileImages are 
drawn to the screen, they have white where they're supposed to be transparent. 
I've tried specifying both BITMASK and TRANSLUCENT transparencies when creating 
the VolatileImage and neither way worked. I also tried with the translaccel 
option set to true.

The other problem I have is that when I try to validate my images, they go 
completely white. The validation returns IMAGE_OK and contentsLost() returns 
false, so I'm rather confused about this.

It seems that Chet and Chris, a couple of Java2D experts, frequent this forum 
so I'm hoping that one of them finds this message and is able to help me out.

Thanks.
[Message sent by forum member 'dialup' (dialup)]

http://forums.java.net/jive/thread.jspa?messageID=147826

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to