使用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:
Color myColor = Color.decode("#2B2B2B");