title: Java BufferedImage set new size
body: <p>I am using a <code>BufferedImage</code> to display a single image. I alter the image data by getting the pixel data from <code>getRaster()</code> and than changing it. It works great if I only alter pixel values, but if I change the size (width/height) of the pixel data array the new <code>BufferedImage</code> won't resize.</p>
  
  <p>Here is the code:</p>
  
  <pre><code>bufferedImage = new BufferedImage(img.width, img.height, bufferedImage.getType());
  bufferedImage.getRaster().setDataElements(0, 0,  img.width, img.height, img.pixels);
  </code></pre>
  
  <p>What else do I have to do so that the <code>bufferedImage</code>size is changed?</p>
  
  <p>For example, if I let the pixels array unchanged and just swap width/height (so pixels.length is the same) the image does not change.</p>