[英]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
我从网上尝试了一些例子,但我失败了
if i am using bitmap.creatbitmap
with matrix i am getting error 如果我将
bitmap.creatbitmap
与矩阵一起使用,我会报错
Please suggest me which is better 请建议我哪个更好
Thanks in advance 提前致谢
Aswan 阿斯旺
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);
If you want your turning to be animated, then see my answer to "animating and rotating an image..." . 如果您希望对转弯进行动画处理,请参阅我对“动画和旋转图像...”的回答 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.