使用BufferedImage我创建一个图像并用darkGray颜色绘制它:
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB_PRE);
Graphics2D graphics = image.createGraphics();
Color darkGray = new Color(44, 47, 48);
graphics.setColor(darkGray);
graphics.fill(new RoundRectangle2D.Float(0, 0, image.getWidth(), image.getHeight(), ROUND_OF_CORNERS, ROUND_OF_CORNERS));
我想通过使用另一种颜色显示格式来改变图像的颜色,如:#2B2B2B(而不是RGB格式:44,47,48).
解决方法:
您可以将十六进制值解码为颜色,如下所示:
Color myColor = Color.decode("#2B2B2B");