使用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)。
答案 0 :(得分:4)
您可以将十六进制值解码为这样的颜色:
Color myColor = Color.decode("#2B2B2B");