Hi,
This topic was asked about a month ago, and I was rellying on finding it here once I needed it, but now that I need it I see the old threads got deleted [depressed]
So could someone explain to me again how to make an image transparent? I remember that I need to get an array of int from the Raster, and then I need to go through it and if some pixel is, for example, white, then I set array
= 0 and then it'll be transparent.
I tried like this:
gc - GraphicsConfiguration
offscreen,picture - BufferedImage
offscreen = gc.createCompatibleImage(500,500,Transparency.TRANSLUCENT);
for (int y=0; y<picture.getHeight(); y++)
{
for (int x=0; x<picture.getHeight(); x++
{
int pixel = picture.getRGB(x,y);
if (new Color(pixel) == Color.WHITE)
{
picture.setRGB(x,y,0);
}
}
}
This turns the white area into black [oh]
offscreen.getGraphics().drawImage(10,20,picture,null);