使用BufferedImage 生成的图像总是黑色背景,即使是使用了Graphics2D的setBackground()也没有效用,实际上要得到其它颜色的背景“应该”是使用fillRect()将整个矩形变色。
Graphics g = bufferedImage.createGraphics();
g.setColor( Color.white );
g.fillRect(0, 0, width, height );
然后再是画你所需要的东西。
这样大概OK了。
Graphics g = bufferedImage.createGraphics();
g.setColor( Color.white );
g.fillRect(0, 0, width, height );
然后再是画你所需要的东西。
这样大概OK了。
本文介绍了一种使用BufferedImage和Graphics2D来改变图像背景颜色的方法。通过创建Graphics2D实例并调用fillRect()方法填充整个图像区域以实现背景颜色的更改。
1651

被折叠的 条评论
为什么被折叠?



