Transparency

Hi all,

I’m writing a sprite animation system, and I’ve got everything to work except image transparency.

At the moment, each frame in a sprite’s animation is stored as an Image object. Then, they are drawn onto a buffered image which is in turn drawn onto the graphics context of a JFrame subclass.

Is there a simple way to make part of an image transparent, i.e. by specifying the colour that should not be drawn?

Thanks,
Mike.

Yes. The easiest way is to use GIF with a transparent color, or PNG with an alpha channel.

If you search the archives here you will find code for modifying an image so that a specific colour becomes transparent.