i’m trying to load a transparent png image with the following code, which also converts it to a bufferedimage:
public createImage(Image img)
{
if(img instanceof BufferedImage)
{
theImage=(BufferedImage)img;
}
else
{
MediaTracker mediaTracker=new MediaTracker(new Frame());
mediaTracker.addImage(img,0);
try
{
mediaTracker.waitForID(0);
}
catch(InterruptedException ie)
{
System.err.println(ie);
}
theImage=GraphicsEnvironment.getLocalGraphicsEnvironment().
getDefaultScreenDevice().getDefaultConfiguration().
createCompatibleImage(img.getWidth(null),
img.getHeight(null),
Transparency.BITMASK);
theImage.getGraphics().drawImage(img,0,0,null);
}
}
but when i draw the image i’ve loaded i see an opaque image, (the transparent pixels are white and opaque). if i open the image using windows picture viewer or acdc the image is displated correctly, with the transparent pixels transparet.