Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rotate image along with touch to fix point in android

I am trying to rotate image in image view coresponding with touch to fix pivote pint of image . i have seen many of example but i dont clear with all of it .somebody have idea ..how can do it this this ?

like image 941
dharam Avatar asked Nov 14 '22 04:11

dharam


1 Answers

Since there is no code or details provided about where the bitmap is drawn i assume its at the center of the screen. You can rotate the canvas on center point like this

double rotationAngleRadians = Math.atan2(currentX - centerX, centerY - currentY);
rotationAngleDegrees = (int) Math.toDegrees(rotationAngleRadians );

canvas.rotate(rotationAngleDegrees , centerX, centerY);
like image 177
Ronnie Avatar answered Dec 09 '22 18:12

Ronnie