I’ve searched the forums, and even the web extensively in search for an answer to this question, so I’m sorry if this topic has already been discussed. In any event could you please refer me to the article or thread if this happens to have already been asked.
I’m new to Java, having recently finished my first semester with it at the university level. So I do know the basics but Java’s 2D graphics abilities are still a bit hazy to me. Anyway, I’m trying to figure out how to create transparent images programmatically after loading them from file in an opaque state. I’m familiar with blitting transparent images with Win32 and I’m trying for a similar but simple approach to this in java. I am terrible with graphics and do not understand alpha channels very well so that is why I’m not making the images transparent with a graphics editor; I simply do not know how.
In any event, how would I go about loading a 24 bit PNG from file and then modifying the image to allow any white pixels in the image to be transparent? Would I load the image from file as an image and then copy the image into a bufferedImage? Could I then use setRGB to iterate through the white pixels and change them to be transparent? If so, how would I do this? Also is there a way to iterate through a single PNG that holds all the frames for an animation, and then select the pixels for that particular frame and store them in a bufferedImage?
I seek to do all this for the purpose of game programming, so the fastest way to do this would be ideal. If there is a better way to do the procedures I listed above please let me know. Basically I do not know how to add transparency to images I create or edit in a graphics editor so if there is a way to do it in code for PNG or BITMAP your knowledge on the subject would be most appreciated. Thanks guys, and I’m sorry if I was a bit wordy. Like I said I might be looking at this the wrong way, so correct me if I am.