user559142
user559142

Reputation: 12517

drawImage Java api

drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer)

I would like to specify a null colour for bg colour in the above method. It defaults to black. I thought I could specify null as argument for bgcolor but it doesn't work. Any ideas?

I'm using

drawImage(img, 0, 0, null, this);

It works, but just draws black when I want no colour.

Upvotes: 0

Views: 1572

Answers (1)

Jesper
Jesper

Reputation: 206816

Why do you want to specify null as a colour; what is your goal? Do you want the background to be transparent instead of black?

When this is what you want, try using a colour that has alpha set to 0 (fully transparent):

Color transparent = new Color(0, 0, 0, 0);
graphics.drawImage(img, 0, 0, transparent, this);

Upvotes: 2

Related Questions