Re: Painting Negative



And thus spoke Knute Johnson...

So the big question is: How can I fill everything EXCEPT the polygons?

Flo

There are a couple of ways to do this. The important thing to note is
that it is not possible to draw on a component and clear the alpha. You
can draw on a BufferedImage and do that however. In the example below,
I create a mask image that is black with an alpha hole in the middle.
Then in the paintComponent() method, I draw my subject image and then
draw the mask over the top of that image. In the portion where I have
the alpha hole, the image underneath shows through. You could put the
mask in a separate JPanel as long as you made sure that the JPanel was
set to transparent (setOpaque(false)).

Works like a charm, thanks.

Flo
.


Quantcast