user4488621
user4488621

Reputation:

Java - Clearing graphics from Buffered Image

Here is my problem:

I have a bufferedImage that acts as a base. Then, I have another BufferedImage that is an ARGB that is placed over the base. The problem is I want to clear all the graphics on the ARGB image. If I use clearRect(); then it will just put a layer of alpha over the ARGB, which will do nothing. Also, I can't use setRGB(); to control the graphics.

So my question is: how can I remove all graphics from a ARGB image?

Upvotes: 2

Views: 4363

Answers (1)

Prometheus
Prometheus

Reputation: 1015

Make sure the right background color is set. It is used for clearing the image.

Graphics2d g2d = image.createGraphics();
g2d.setBackground(new Color(0, 0, 0, 0));
g2d.clearRect(0, 0, image.getWidth(), image.getHeight());

Upvotes: 1

Related Questions