title: Setting RGB values for reducing palette in PNG Image
body: <p>I have the <a href="https://stackoverflow.com/questions/6832434/png-possible-to-reduce-the-palette-using-java-2d/6836879#6836879">following method</a>, that reduces the palette size in a PNG image.</p>
  
  <pre><code>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;
  }
  </code></pre>
  
  <p>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 <strong><em>slightly</em></strong> reduce the colour number in the PNG image. </p>