Trouble retaining transparent back color while setting opacity
I'm trying to set opacity of an image and also making it's back transparent....
The program suppose to mark the back color (the 1st pixel's color) of an image to transparent and also define the whole opacity (translucent) of the image...
The problem is if I, first make the image transparent and then apply the opacity the image is loosing it's backcolor :confused:
However if I do opposite that is , first apply opacity and then make it transparent then everythings is OK.
Why is this happening?
Bellow is the code that make the opacity...
private BufferedImage getTranslucentImage(float opacity)
int width = img.getWidth();
int height = img.getHeight();
BufferedImage tmp = new BufferedImage(width, height,
Graphics2D g2 = tmp.createGraphics();
g2.drawImage(img, null, 0, 0);