I wanna change different pixel to different color. Basically, change part of pixel to transparent.
for(int i = 0; i < image.getWidth();i++)
for(int j = 0; j < image.getHeight(); j ++)
{
image.setRGB(i,j , 0);
}
//I aslo change the third parameter 0 to another attribute. but it still does not work. it all show black. do you have some ideas?
yin. thanks
class ImagePanel extends JPanel {
private BufferedImage image;
public ImagePanel(int width, int height, BufferedImage image) {
this.image = image;
image = new BufferedImage(width, height,
BufferedImage.TYPE_INT_ARGB);
repaint();
}
/**
* Draws the image.
*/
public void paintComponent(Graphics g) {
super.paintComponent(g);
for (int i = 0; i < image.getWidth(); i++) {
for (int j = 0; j < image.getHeight(); j++) {
image.setRGB(i, j, 0);
}
}
g.drawImage(image, 0, 0, getWidth(), getHeight(), this);
}
}