开发者

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 m开发者_如何学编程ethod. 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.


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜