如何在Java中创建带圆角的图像?

时间:2015-07-11 22:34:36

标签: java bufferedimage graphics2d

当我绘制带圆角的BufferedImage时

BufferedImage image = new BufferedImage(100, 100, BufferedImage.TYPE_INT_RGB);
Graphics2D graphics = image.createGraphics();
graphics.setColor(Color.WHITE);
graphics.fill(new RoundRectangle2D.Float(0, 0, 60, 60, 20, 20));

输出图像是:

enter image description here

如何在没有黑角的情况下收到图像?

1 个答案:

答案 0 :(得分:4)

BufferedImage.TYPE_INT_RGB更改为BufferedImage.TYPE_INT_ARGB以创建透明图像