title: Convert r,g,b value to one pixel value
body: <p>I am trying to access the pixels of image using method getRGB(). The image I use for this purose is 8-bit image i.e each pixel is represented by 8-bits, hence the possible values are 0-255.
  the image I used was png 8-bit image hence the type 'type_byte_indexed'</p>
  
  <pre><code>if (type == BufferedImage.TYPE_BYTE_INDEXED) { 
      System.out.println("type.byte.indexed");
      System.out.print(h+"   "+w);    
  
      sourceImage.getRGB(0, 0, w, h, rgbs, 0, w); //rgbs is integer array
  
      for (i = 0; i &lt;10; i++) {
          System.out.print("   "+rgbs[i]);  
       }
      System.out.println("rgbs len: " + rgbs.length); 
  }
  </code></pre>
  
  <p>The output of the for loop is something ilke:</p>
  
  <pre><code>-12048344   -12174804   -12048344   -12174804   -12174804 .......
  </code></pre>
  
  <p>I obtain the r,g,b components from it and store in array :</p>
  
  <pre><code>    Color c=new Color(rgbs[i]);
      r=c.getRed();
      g=c.getGreen();
      b=c.getBlue();
  </code></pre>
  
  <p>Now how do I combine again these values so that I can use the setRGB method? Like for 24 bit image we can use</p>
  
  <pre><code>int rgb=65536*pixel[i]+256*pixel[i+1]+pixel[i+2];
  </code></pre>