设置位图的旋转和位置

我想知道我如何改变位图的位置,同时旋转它。 我画在canvas上。

我目前正在使用这行代码:

canvas.drawBitmap(bitmap, posX, posY, paint); 

我认为使用矩阵进行轮换是最好的选择吗? 问题是上面发布的代码行不是一个矩阵而是一个位置。

还有一个类似的代码行:

 canvas.drawBitmap(bitmap, matrix, paint); 

这个采用矩阵而不是位置。

我该怎么做?

 Matrix matrix = new Matrix(); matrix.SetRotate(90,pivotX,pivotY); matrix.PostTranslate(positionX,positionY); canvas.drawBitmap(bitmap, matrix , null); 

用文字表示 – 旋转设定位置。

将位置作为posMatrix放入矩阵中,并将其与旋转矩阵相乘。 然后将结果矩阵作为参数传递。

编辑—

 Matrix myTransformedMatrix = new Matrix(); myTransformedMatrix.setRotate(); myTransformedMatrix.setTranslate(); canvas.drawBitmap(bitmap, myTransformedMatrix, paint); 

有关矩阵类的更多信息,请访问http://developer.android.com/reference/android/graphics/Matrix.html