页: 1
private BufferedImage setColour(BufferedImage image) {
IndexColorModel cm = new IndexColorModel(
3,
6,
new byte[]{-100, 0, 0, 0, -1, 0}, // r
new byte[]{0, -100, 60, 0, -1, 0}, // g
new byte[]{0, 0, 0, -100, -1, 0}); // b
BufferedImage img = new BufferedImage(
image.getWidth(), image.getHeight(),
BufferedImage.TYPE_BYTE_INDEXED,
cm);
Graphics2D g2 = img.createGraphics();
g2.drawImage(image, 0, 0, null);
g2.dispose();
return img;
}
I understand that each byte array is used for indexing the palette associated with a PNG pixel. What I don t understand, is how to set the values in the byte arrays so that I could only slightly reduce the colour number in the PNG image.