title: rotating and scaling an image in android using matrix
body: <p>I'm trying to rotate and then scale an image using android.graphics.Matrix. The code is as follows:</p>
  
  <pre><code>    int width = bmp1.getWidth();
      int height = bmp1.getHeight();
      int smallerVal = (height &gt; width) ? width : height;
      int n = 0;
      while (smallerVal &gt; 1)
      {
          smallerVal = smallerVal &gt;&gt; 1;
          n++;
      }
  
      int pow2 = (int) Math.pow(2, n);
      float scaleWidth = ((float) AppBase.width) / (float)pow2;
      float scaleHeight = ((float) AppBase.height) / (float)pow2;
  
      Matrix matrix = new Matrix();
      matrix.postRotate(90);
      matrix.postScale(scaleWidth, scaleHeight);
      Bitmap bmp2 = Bitmap.createBitmap(bmp1, 0, 0, pow2, pow2, matrix, true);
  </code></pre>
  
  <p>pow2 is to get a square power-of-2 image for the sake of applying a texture. bmp2 turns out to have -1 as height and width, ie an invalid image. Am I missing something?</p>
  
  <p>Thanks,<br>
  Rajath</p>