I would like to get the result of coloring the image. I'm just trying to paint in a slightly different way than the fill color.
Multiplies two different colors.
That is, given two colors, returns the multiplied value, and transparent color returns itself.
The code below fills the screen with the same color.
public static BufferedImage color(BufferedImage image, Color color) {
Graphics2D g = image.createGraphics();
g.setPaint(color);
g.fillRect(0, 0, image.getWidth(), image.getHeight());
g.dispose();
return image;
}
Is there a fastest way to compute the operation below for every pixel? ('c2' variable is guaranteed to always be the same color for the same object) If I simply repeated that, my program would be absurdly slow.
public static BufferedImage color(Color c1, Color c2) {
return new Color(
c1.getRed() * c2.getRed(),
c1.getGreen() * c2.getGreen(),
c1.getBlue() * c2.getBlue(),
c1.getAlpha() * c2.getAlpha()
);
}
The result I want is this: