Reputation: 81
I have a BufferedImage
called originalImage
that is drawn on a JPanel
. I have an array of BufferedImage
called layer
and I draw all of those layer
on the originalImage
So how can I delete (for example) layer[0]
entirely from the originalImage
?
Upvotes: 0
Views: 735
Reputation: 8361
You need to save the position where you draw your BufferedImage
(e.g. layer[0]
). Then you can just overpaint this:
public void overpaintImage (BuffereImage originalImage, Point imagePos, Dimension imageSize)
{
Rectangle r = new Rectangle(imagePos.x, imagePos.y, imageSize.width, imageSize.height);
Graphics2D g = originalImage.createGraphics();
g.setColor(Color.WHITE); // or whatever your background color is
g.fill(r);
}
Upvotes: 0
Reputation: 370
Simple answer: you can't! Just delete one layer entry and paint everything new. It's at low cost, so don't worry.
Upvotes: 2