Sign in to follow this  
samcoles

[java] Setting Alpha in an image

Recommended Posts

samcoles    100
Hi, I remember when I programmed a few SDL demos a few years back there was a simple function to set a colour on a source image to alpha so it wasn't blitted to the screen. I've searched up and the function was SDL_SetColorKey(). I've begun programming PacMan in Java at the moment, I've made a sprite class, it all loads from files and animates and such... except for the lack of transparency in the bright pink areas! I've Googled and found some pretty long winded ways of doing it that all looked a bit confusing, I've also trawled through the API and I still can't really find what I'm looking for... I'd find it hard to believe the Java API doesn't have a similarly easy to use function like SDL_SetColorKey(). The sprite image is stored as a 'BufferedImage' once loaded. Can anyone point me in the right direction for what I should be looking at? Hoping that something as simple exists but if it doesn't and the simple solution would just be to save the images as PNGs with transparency already built into the image then I'll do that. Cheers Sam

Share this post


Link to post
Share on other sites
samcoles    100
I've achieved this by simply using PNGs with transparency by deleting the magenta around my sprites in GIMP and exporting. Probably makes sense this way anyway but if anyone knows a solution to what I was trying to achieve in the first place it would still be very much appreciated.

Sam.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this