title: Issue rotating bitmap in Android
body: <p>I'm having a problem getting a bitmap to rotate properly.  I have a SurfaceView with multiple bitmaps on it.  These bitmaps exist within an arraylist and using a for loop I call canvas.drawBitmap for each one in the onDraw method.  </p>
  
  <pre><code>@Override
  protected void onDraw(Canvas canvas) {
      super.onDraw(canvas);
      canvas.drawColor(Color.BLACK);
  
      for (int i = 0; i &lt; jumper.size(); i++) {
          canvas.drawBitmap(jumper.get(i).getGraphic(), jumper.get(i)
                  .getCoordinates().getX(), jumper.get(i).getCoordinates()
                  .getY(), null);
      }
  }
  </code></pre>
  
  <p>I am attempting to have the user select a specific bitmap (one of many) and then have that bitmap rotate while the user drags his finger across the screen.  So here is the rotation code.  For now I'm just using the default android icon (72x72px) existing at a random position somewhere near the center of the screen.</p>
  
  <pre><code>private void rotateJumper(int direction) {
      Matrix matrix = new Matrix();
      Bitmap source = jumper.get(selectedJumperPos).getGraphic();
      matrix.postRotate(direction, source.getWidth() / 2, 
              source.getHeight() / 2);
      int x = 0;
      int y = 0;
      int width = 72;
      int height = 72;
      Bitmap tempBitmap = Bitmap.createBitmap(source, x, y, width, height,       
              matrix, true);
      jumper.get(selectedJumperPos).setGraphic(tempBitmap);
  }
  </code></pre>
  
  <p>The integer direction is either +1 or -1 depending on the direction of the finger drag.  So the image should rotate 1 degree for every MotionEvent.ACTION_MOVE event.</p>
  
  <p>Here are the problems:</p>
  
  <ol>
  <li>The image doesn't rotate about the image center.  CW rotations center about the bottom left corner.  CCW rotations center about the top right corner.</li>
  <li>Since it isn't rotating about the center, the image rotates outside its initial bounds and eventually disappears. </li>
  <li>The image gets blurry as it rotates.</li>
  </ol>
  
  <p>Any help you could give me would be greatly appreciated.  </p>
  
  <p>Thanks!</p>