joelwenzel
Programmer
- Jun 28, 2002
- 448
Hi,
I've been working on this silly jigsaw puzzle program and am having a problem. My puzzle pieces are contained in a JLayeredPane so that when I pick one up and set it down again, it is ontop of all previous pieces. Anyway, the puzzle pieces are each contained in a panel and part of the pieces are transparent. When I click on the transparent part of a piece, I want to be able to selected the piece beneath. Is there a way to send the event down a layer ?
Also, to determine if a pixel is transparent, I am using a really bad method.
ufferedImage t = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g1 = (Graphics2D)t.getGraphics();
g1.drawImage(pic,0,0,this);//=g;
int pixColour = t.getRGB(oldX, oldY);
if(pixColour==0)
//pixel is transparent
Actually, I'm pretty syre 0 is black so this code won't even work if there is solid black in the picture. I tried using pixelgrabber to get a single pixel but it is overly complicated and I couldn't figure it out
I've been working on this silly jigsaw puzzle program and am having a problem. My puzzle pieces are contained in a JLayeredPane so that when I pick one up and set it down again, it is ontop of all previous pieces. Anyway, the puzzle pieces are each contained in a panel and part of the pieces are transparent. When I click on the transparent part of a piece, I want to be able to selected the piece beneath. Is there a way to send the event down a layer ?
Also, to determine if a pixel is transparent, I am using a really bad method.
ufferedImage t = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
Graphics2D g1 = (Graphics2D)t.getGraphics();
g1.drawImage(pic,0,0,this);//=g;
int pixColour = t.getRGB(oldX, oldY);
if(pixColour==0)
//pixel is transparent
Actually, I'm pretty syre 0 is black so this code won't even work if there is solid black in the picture. I tried using pixelgrabber to get a single pixel but it is overly complicated and I couldn't figure it out