Can't get transperancy on volatile images to work

How is it done. I’ve a png image with 1-bit transparency that comes out as white when it is drawn.

VolatileImages in Java 1.4.2 are not translucent.

We’ll have to wait for 1.5 for that.

Trans[parent|lucent] VolatileImages are only supported in 1.5 upward.

VolatileImage vi = gc.createVolatileImage(width,height,Transparency.BITMASK);
Graphics2D g2d = vi.createGraphics();
g2d.setComposite(AlphaComposite.Src);
g2d.drawImage(loadedImage,0,0,null);
g2d.dispose();

:edit:

SNAP! :stuck_out_tongue:

So what is the next fastest image format to use?

It isn’t a simple case of 1 image type being faster than another, the reason BufferedImages and VolatileImages exist, is because they are both optimal, just in different circumstances.

What do you want to use the image for?
Is it going to be a Sprite (read from, and never (or very infrequently) written to)
or a Buffer, read from, and written to.

Sorry for not explaining things a bit more. I need the image for my sprites (i.e. loaded once and then a part of it is blitted on a backbuffer (buffer strategy)) so I need the transparency so that I won’t get boxes around my sprites. I will probably still use volatile images for the ground tiles since they need not be transparent. So, are BufferedImages my best bet?

yes, BufferedImages returned from

graphicsConfiguration.createCompatibleImage(width,height,Transparency.BITMASK); //or OPAQUE

are called ‘managed images’, they are elligable for caching in VRAM, and will be as fast as VolatileImages. (well a tiny tiny bit slower, but only because of a small overhead involved in managing the cache)