title: Getting and setting RGB values on a BufferedImage
body: <p>I'm having a really bad time dealing with RGB values in Java, which made me start trying small experiments with this.</p>
  
  <p>I came down to this: loading an image, get it's rgb values and creating a new image with the same values. Unfortunately, this does not work (the images are displayed differently, see picture), as per the following code... Can some one see what's wrong?</p>
  
  <pre><code>BufferedImage oriImage=ImageIO.read(new  URL("http://upload.wikimedia.org/wikipedia/en/2/24/Lenna.png"));
  
  int[] oriImageAsIntArray = new int[oriImage.getWidth()*oriImage.getHeight()];
  oriImage.getRGB(0, 0, oriImage.getWidth(),oriImage.getHeight(), oriImageAsIntArray, 0, 1);
  
  BufferedImage bfImage= new BufferedImage(oriImage.getWidth(),oriImage.getHeight(),
              BufferedImage.TYPE_INT_ARGB);
  
  bfImage.setRGB(0,0,bfImage.getWidth(),bfImage.getHeight(),oriImageAsIntArray, 0, 1);
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/FK5oK.png" alt="output"></p>