title: Exception in BufferedImage.getData().getPixels()
body: <p>I was looking to convert a buffered image to its corresponding pixel value array. I found a code for that:</p>
  
  <pre><code>public static double[] createArrFromIm(BufferedImage im){
        int imWidth = im.getWidth();
        int imHeight = im.getHeight();
        double[] imArr = new double[imWidth* imHeight];
        im.getData().getPixels(0, 0, imWidth, imHeight, imArr);
        return imArr;
  }
  </code></pre>
  
  <p>The original author who wrote this code block also gave some sample images which work perfect for this block. However, when I try to run this block against my images (the images are always 125*150) the block throws an array index out of bound exception at line:</p>
  
  <pre><code>      im.getData().getPixels(0, 0, imWidth, imHeight, imArr);
  </code></pre>
  
  <p>This incident seems very arcane to me. Any help or suggestion will be very much appreciable. Thanks.</p>