title: java.lang.IllegalArgumentException when splitting bitmap in android
body: <p>Can  someone tell me why I am getting this error when splitting a bitmap.
  Code:</p>
  
  <pre><code> public static List&lt;Bitmap&gt; ScambleImage(Bitmap image, int rows, int cols){
      List&lt;Bitmap&gt; scambledImage =  new ArrayList&lt;Bitmap&gt;();
      int chunkWidth = image.getWidth(); //cols
      int chunkHeight = image.getHeight(); //rows
      int finalSize = chunkWidth/rows;
  
      Bitmap bMapScaled = Bitmap.createScaledBitmap(image, chunkWidth, chunkHeight, true);
      int yCoord = 0;//The y coordinate of the first pixel in source
      for(int x = 0; x &lt; rows; x++){
          int xCoord = 0;//The x coordinate of the first pixel in source
          for(int y = 0; y &lt; cols; y++){
              scambledImage.add(Bitmap.createBitmap(bMapScaled, xCoord, yCoord, finalSize, finalSize));
              xCoord = finalSize + xCoord;
          }
          yCoord = finalSize + yCoord;//The y coordinate of the first pixel in source
      }
  
      return scambledImage;
  }
  </code></pre>
  
  <p>rows = 6, and cols = 6;
  image size = 648 x 484</p>
  
  <p>this is the exception but don't know how to go about fixing:</p>
  
  <pre><code>java.lang.IllegalArgumentException: y + height must be &lt;= bitmap.height()
  </code></pre>
  
  <p><a href="http://i.stack.imgur.com/XlN4b.jpg" rel="nofollow">Image I'm splitting</a></p>
  
  <p>Thanks!</p>