title: What's wrong with this Java code for Android?
body: <p>I have written this piece of code to break an image into 9 pieces and it gives me runtime error. There is no error in LogCat and I am stuck. The error comes at line 7 line from bottom (Bitmap.createBitmap(...);). </p>
  
  <pre><code>public Bitmap[] getPieces(Bitmap bmp) {
          Bitmap[] bmps = new Bitmap[9];
  
          int width = bmp.getWidth();
          int height = bmp.getHeight();
  
          int rows = 3;
          int cols = 3;
  
          int cellHeight = height / rows;
          int cellWidth = width / cols;
  
          int piece = 0;
  
          for (int x = 0; x &lt;= width; x += cellWidth) {
              for (int y = 0; y &lt;= height; y += cellHeight) {
                  Bitmap b = Bitmap.createBitmap(bmp, x, y, cellWidth,
                          cellHeight, null, false);
                  bmps[piece] = b;
                  piece++;
              }
          }
  
          return bmps;
      }
  </code></pre>