简体   繁体   中英

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) . Then use this matrix when creating new Bitmap: Bitmap.createBitmap(..)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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