Android - Can't draw image at coordinates using matrix
<p>Okay, I have a method that takes the variables: an image, int x, int y, float angle.</p>

<p>I am using a canvas, and I am using a <code>Matrix transform = new Matrix();</code> to rotate the image at it's center. However, I want the image to be drawn at the coordinates of <code>x</code> and <code>y</code>. For some reason, all the different methods I have used have not worked. Sometimes it draws it at 0,0 or it doesn't even show up on the screen.</p>

<p>Here's my pseudo-code:</p>



<pre class="lang-java prettyprint-override"><code>//pseudo-code: img_width, img_height
public void drawImage(Bitmap img, int x, int y, float angle)
{
    transform.setTranslate(x, y);
    transform.setRotate(angle, img_width/2, img_height/2);
    canvas.drawBitmap(img, transform, null);
}
</code></pre>

<p>I have gotten the image to rotate, but I want the image to be drawn at the specified coordinates: x,y.</p>

<p>I have tried swapping all the variables, used <code>transform.preRotate</code>, and basically spent 1 hour trying to figure out why nothing will work. I have lots of other images being drawn to the canvas, and they appear where they should, but when I want to rotate, it won't draw at the specified coordinates.</p>

<p>I've read about 5 SO questions and answers related to this, but none give me what I need.</p>

<p>I really need an answer and code urgently, thank you.</p>
