围绕在画布上的中心点旋转图像 [英] rotate image in around its center point in canvas
问题描述
旋转图像围绕其中心帆布。我试图从网上的一些例子,但我失败了。
rotate image on canvas around its center . i tried some example from net but i am failed
如果我使用 bitmap.creatbitmap
与矩阵我收到错误
if i am using bitmap.creatbitmap
with matrix i am getting error
请建议我哪个更好
在此先感谢
阿斯旺
推荐答案
您可以用一个矩阵来旋转。首先,你(我使用的是位图的中心坐标)设定的位置。然后应用的旋转。然后绘制使用你的矩阵。
You can use a matrix to rotate. First you set the position (I'm using the coordinates of the bitmap's centre). Then apply a rotation. Then draw using your matrix.
Matrix transform = new Matrix();
transform.setTranslate(xOfCentre, yOfCentre);
transform.preRotate(turnDegrees, width/2, height/2);
canvas.drawBitmap(bitmap, transform, null);
如果你希望你的转折点是动画,然后看到<一href="http://stackoverflow.com/questions/2439301/animating-and-rotating-an-image-in-a-surface-view/4090989#4090989">my回答动画和旋转图像......。
If you want your turning to be animated, then see my answer to "animating and rotating an image...".
这篇关于围绕在画布上的中心点旋转图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!