title: Android rotate Bitmap and draw Canvas
body: <p>I am trying to rotate a Bitmap using matrix . Then I am trying to draw it on Canvas . But it just DISAPPEARS ! </p>
  
  <p>Here is my code below :</p>
  
  <pre><code>    public class MultitouchView extends View {
  
  private static final int INVALID_POINTER_ID = -1;
  private static final String TAG = "MultitouchView";
  private Drawable image;
  private Drawable userImage;
  
  Bitmap userOriginal;
  Bitmap userResult;
  
  private float scaleFactor = 1.0f;
  private ScaleGestureDetector scaleGestureDetector;
  
  private float mPosX;
  private float mPosY;
  
  private float mLastTouchX;
  private float mLastTouchY;
  private int mActivePointerId = INVALID_POINTER_ID;
  
  private int direction = 0;
  
  Context context;
  
  public MultitouchView(Context context) {
      super(context);
      image = context.getResources().getDrawable(
              R.drawable.plain_black_wallpaper);
      image.setBounds(0, 0, image.getIntrinsicWidth(),
              image.getIntrinsicHeight());
  
      userOriginal = BitmapFactory.decodeResource(this.getResources(), R.drawable.navigation);
  
      userImage = context.getResources().getDrawable(R.drawable.navigation);
      userImage.setBounds(500, 500, 550, 550);
  
      setFocusable(true);
  
      scaleGestureDetector = new ScaleGestureDetector(context,
              new ScaleListener());
  }
  
  @Override
  protected void onDraw(Canvas canvas) {
      super.onDraw(canvas);
      // Set the image bounderies
      canvas.save();
      //scale canvas
      canvas.scale(scaleFactor, scaleFactor);
      image.draw(canvas);
      canvas.translate(mPosX, mPosY);
  
      //rotate user drawable
  
      userImage.draw(canvas);
  
      canvas.restore();
  }
  
   public void setDirection(int direction) {
          this.direction = direction;
          rotateBitmap();
          invalidate();
        }
  
  private void rotateBitmap() {
      Matrix matrix = new Matrix();
      matrix.postRotate(this.direction);
      userResult = Bitmap.createBitmap(userOriginal,0,0, userOriginal.getWidth(), userOriginal.getHeight(), matrix,true);
      userImage=new BitmapDrawable(this.getResources(),userResult);
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>I have removed the functions for scale canvas and event listener etc . to make the code small and readable here. </p>
  
  <p>I call the setDirection method  periodically but then after it is called the "userImage" drawable just disappears . Can anyone please suggest as to what is going wrong here .. </p>
  
  <p>Thanks</p>