Hi… I’m getting some very strange behaviour (=completely broken) for a drawImage call. I’ve managed to scale the thing down to this file. Could someone test the following class and tell me if it works properly?
public class Bug extends Frame {
public static void main(String[] x) {
new Bug();
}
public Bug() {
setBounds(0,0,1024,768);
setVisible(true);
addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
);
}
public void paint(Graphics gg) {
BufferedImage img = getGraphicsConfiguration().createCompatibleImage(32,32,Transparency.OPAQUE);
Graphics2D gImg = img.createGraphics();
gImg.setColor(Color.red);
gImg.fillOval(4,4,24,24);
gImg.setColor(new Color(0x0));
gImg.drawOval(4,4,24,24);
gg.drawImage(img,200,200,200+15,200+15,0,0,31,31,null);
}
}
I get garbage on Windows (and a huge amount of it) with these combinations:
BufferedImage img = getGraphicsConfiguration().createCompatibleImage(32,32,Transparency.OPAQUE);
BufferedImage img = getGraphicsConfiguration().createCompatibleImage(32,32,Transparency.BITMASK);
BufferedImage img = new BufferedImage(32,32,BufferedImage.TYPE_INT_RGB);
I get a proper result with :
BufferedImage img = getGraphicsConfiguration().createCompatibleImage(32,32,Transparency.TRANSLUCENT);
BufferedImage img = new BufferedImage(32,32,BufferedImage.TYPE_INT_ARGB);
In Linux both things seem to work (same hardware)
Thanks in advance!