简体   繁体   English

Android-围绕中心点旋转图像?

[英]Android - Rotate image around center point?

How can I rotate a bitmap (not a view or canvas) around its center point when the user touches it and drags it? 当用户触摸并拖动位图时,如何围绕其中心点旋转位图(而不是视图或画布)?

I have tried loads of examples on stack overflow and none appear to work. 我已经尝试了很多关于堆栈溢出的示例,但是似乎都没有。

So far I have: 到目前为止,我有:

double r = Math.atan2(posX - dial.getWidth() / 2, dial.getHeight() / 2 - posY);
rotation = (int) Math.toDegrees(r);

Create Matrix then set rotate via setRotate(degrees) . 创建Matrix然后通过setRotate(degrees)设置rotate。 Then use this matrix when creating new Bitmap: Bitmap.createBitmap(..) 然后在创建新的位图时使用此矩阵: Bitmap.createBitmap(..)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM