Getting rid of image background?

How would I go about getting rid of the background of an image? If that's not possible, how would I make the background transparent?
[140 byte] By [nullbyte00a] at [2007-11-27 8:40:18]
# 1

I am not sure if you are trying to make it so you can see your desktop as the background? But if you are painting on a Frame or JFrame then You can creat a BufferedImage, and if you paint that it expose the backround color of your frame.

import java.awt.*;

import java.awt.image.*;

BufferedImage bi;

bi = new BufferedImage(x, y, BufferedImage.TYPE_INT_RGB);

public void paint(Graphics g){

g.drawImage(0, 0, x, y, this);

}

where x and y is the total size of the screen, and BufferedImage.TYPE_INT_RGB is the type, I think and int.

or you can set an alphacomposite which controls transparency of an object, such as an image.

private AlphaComposite alp;

alp = AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.3f);

g2d.setComposite(alp);

g2d.draw(yourImage, 0, 0, x, y, this);

where the .3f means 30% transparency and the g2d is the graphics of your frame. I think this might answer your question, if it doesn't please include more informationof your problem.

noone392a at 2007-7-12 20:38:41 > top of Java-index,Security,Cryptography...
# 2
I just need to know how to make an image loaded in Java have a transparent background.
nullbyte00a at 2007-7-12 20:38:41 > top of Java-index,Security,Cryptography...
# 3
Well you cant see the background of an image when its painted on a canvas, but if you wanted to make the image and its background transparent, then you would see the background color of you canvas, and the alpha composite class can do that that I mentioned above
noone392a at 2007-7-12 20:38:41 > top of Java-index,Security,Cryptography...