I've been trying to play around a little with images lately, and I ran into one issue that I've not found any reason for (so I think it's because of a misunderstanding on my part). What I'm trying to do is to draw images that overlap eachother, but parts of the images should be transparent so I can see several images stacked onto eachother. However, no matter what I do I can't make that happen. I make them transparent by doing this (I've preloaded the images before running this code):
It prints out the right amounts of "Setting blank" and loops through the right amount of loops, so I doubt there are any problems with the image not being completely loaded, and if I try to read the RGB back it says 0. It still draws the color as black when I use g.drawImage(shipimg, x, y) though (which draws onto another BufferedImage with TYPE_INT_ARGB). Any thoughts?BufferedImage shipimg=new BufferedImage(tempimg.getWidth(null), tempimg.getHeight(null), BufferedImage.TYPE_INT_ARGB); Graphics tempg=shipimg.getGraphics(); tempg.drawImage(tempimg, 0, 0, null); for (int x=0;x<shipimg.getWidth(null);x++) { for (int y=0;y<shipimg.getHeight(null);y++) { if ((shipimg.getRGB(x, y)&0x00FFFFFF)==0) // If the pixel is black { System.out.println("Setting "+x+":"+y+" blank."); shipimg.setRGB(x, y, 0); } } }
Also posted at Image issues