W
Will Clark
Is there any way of clearing a BufferedImage object? By which I mean
returning it to completely transparent, as when created using:
new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB)
I must have missed something really obvious, because there must be a simple
way to do it, and not by creating a new BufferedImage every time the image
needs redrawing...
Obviously, if it were not a transparent background, I could just use a
Graphics2D.fill(...) to fill the background in, say, white... but
unsurprisingly using this method with a "transparent" color doesn't work
(
What I'd like is a BufferedImage.clear() function!
Any help would be great!
Cheers
)
Will
P.S. I've also come across the following code fragment, which I haven't yet
tried to test:
// Clear image with transparent alpha by drawing a rectangle
g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f));
g2D.fill(new Rectangle(0, 0, w, h));
Is this the best way? Or is there a better way?
returning it to completely transparent, as when created using:
new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB)
I must have missed something really obvious, because there must be a simple
way to do it, and not by creating a new BufferedImage every time the image
needs redrawing...
Obviously, if it were not a transparent background, I could just use a
Graphics2D.fill(...) to fill the background in, say, white... but
unsurprisingly using this method with a "transparent" color doesn't work
What I'd like is a BufferedImage.clear() function!
Any help would be great!
Cheers
Will
P.S. I've also come across the following code fragment, which I haven't yet
tried to test:
// Clear image with transparent alpha by drawing a rectangle
g2D.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0.0f));
g2D.fill(new Rectangle(0, 0, w, h));
Is this the best way? Or is there a better way?