由网友(野性沾了眉丶)分享简介:我如何可以旋转的位图(而不是视图或帆布)围绕其中心点当用户触摸并拖动它?我曾尝试对堆栈溢出的例子负载,没有出现一起工作。到目前为止,我有:双R = Math.atan2(POSX - dial.getWidth()/ 2,dial.getHeight()/ 2 - 波西);旋转=(int)的Math.toDeg...
我如何可以旋转的位图(而不是视图或帆布)围绕其中心点当用户触摸并拖动它?
我曾尝试对堆栈溢出的例子负载,没有出现一起工作。
到目前为止,我有:
双R = Math.atan2(POSX - dial.getWidth()/ 2,dial.getHeight()/ 2 - 波西);
旋转=(int)的Math.toDegrees(r)的;
解决方案
创建矩阵
则设置为通过的 setRotate(度)
。然后使用创建新的位图时,这个矩阵: Bitmap.createBitmap(..)
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)
. Then use this matrix when creating new Bitmap: Bitmap.createBitmap(..)
相关推荐
最新文章