How to replace Color A for Transparency in image width Java

Hi,

The question in the subject is basically what I need to know. I have read the documentation and it seams to be a way to iterate through all image pixels and replace a color for another but I don’t know if this can be done with transparency. Also, i don’t know if this would be to slow to do for all sprites.

All my sprites are PNGs that support a 256 colors indexed table. the color at index 0 is the one I want to replace with transparency.

I’m sure that many of you have done something like this before. I just want to know what is the best way to do this. Can anyone point me in the right direction?

Thanks

I just use Image’s getRGB and setRGB methods.

[…]but I don’t know if this can be done with transparency.

Can be done.

Also, i don’t know if this would be to slow to do for all sprites.

Yes, it would be slow.

All my sprites are PNGs that support a 256 colors indexed table. the color at index 0 is the one I want to
replace with transparency.

Why don’t you use the bitmask transparency provided by the format itself?

Really… that replacing some color with transparency is from the days where image formats lacked transparency. It’s some ugly workaround for that. There is no reason for that nowadays.

Thing is I want to have different color palletes and apply them to the same image to have a different result. I can only do this if my images have an indexed color table and as we know transparency can’t be used on this kind of images. Do you know a way to work this out without the color tables?