title: Android: How to rotate a bitmap on a center point
body: <p>I've been looking for over a day for a solution to this problem but nothing helps, even the answers here. Documentation doesn't explain anything too.</p>
  
  <p>I am simply trying to get a rotation in the direction of another object. The problem is that the bitmap is not rotated around a fixed point, but rather around the bitmaps (0,0).</p>
  
  <p>Here is the code I am having troubles with:</p>
  
  <pre><code>  Matrix mtx = new Matrix();
    mtx.reset();
    mtx.preTranslate(-centerX, -centerY);
    mtx.setRotate((float)direction, -centerX, -centerY);
    mtx.postTranslate(pivotX, pivotY);
    Bitmap rotatedBMP = Bitmap.createBitmap(bitmap, 0, 0, spriteWidth, spriteHeight, mtx, true);
    this.bitmap = rotatedBMP;
  </code></pre>
  
  <p>The weird part is, it doesn't matter how I change the values within <code>pre</code>/<code>postTranslate()</code> and the float arguments in <code>setRotation()</code>. Can someone please help and push me in the right direction? :)</p>