如何在 Java 中创建带圆角的图像?
How to create an image with rounded corners in Java?
当我绘制带圆角的 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));
输出图像为:
如何接收没有黑角的图像?
将BufferedImage.TYPE_INT_RGB
更改为BufferedImage.TYPE_INT_ARGB
以创建透明图像
当我绘制带圆角的 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));
输出图像为:
如何接收没有黑角的图像?
将BufferedImage.TYPE_INT_RGB
更改为BufferedImage.TYPE_INT_ARGB
以创建透明图像