I use the following code snippet for zooming an image
case MotionEvent.ACTION_POINTER_DOWN: oldDist = distance(event);
break;
//------------------------------------------------
case MotionEvent.ACTION_MOVE: matrix.set(savematrix);
float newD = distance(event);
scale = (newD / oldDist);
Log.w("Image" , "Zoom scale = "+scale+" "+newD+"
"+oldDist );
setBackgroundColor(Color.BLACK);
matrix.postScale(scale , scale);
setImageMatrix(matrix);
break;
//------------------------------------------------
IF this is the first time I zoom in
07-05 18:45:08.730: WARN/Image(30045): Zoom scale = 2.648121
247.40099 93.4251
07-05 18:45:08.740: WARN/Image(30045): Zoom scale = 2.6525576
247.81546 93.4251
07-05 18:45:45.670: WARN/Image(30045): touch end scale 2.6525576 X,Y
250.0 , 304.0 Offset 418.0 , 783.0
07-05 18:45:48.070: WARN/Image(30045): touch end scale 2.6525576 X,Y
819.5 , 331.0 Offset 418.0 , 783.0
07-05 18:45:48.080: WARN/Image(30045): my Draw Line 239.76859 , 383.40353
454.46704 , 393.5824 scale: 2.6525576 matrix
Matrix{[2.6525576, 0.0, -418.0][0.0, 2.6525576, -783.0][0.0, 0.0, 1.0]}
pointA.x = ((x - 32.0f + Offset.x) / scale);
(250.0 - 32 + 418.0) / 2.6525576 = 239.76859
When I Zoom again
07-05 18:47:00.270: WARN/Image(30045): Zoom scale = 1.5983747
143.24193 89.61724
07-05 18:47:00.270: WARN/Image(30045): Zoom scale = 1.6022164
143.58621 89.61724
07-05 18:47:18.290: WARN/Image(30045): touch end scale 1.6022164 X,Y
73.5 , 294.0 Offset 732.0 , 1004.5
07-05 18:47:20.370: WARN/Image(30045): touch end scale 1.6022164 X,Y
975.5 , 371.0 Offset 732.0 , 1004.5
07-05 18:47:20.380: WARN/Image(30045): my Draw Line 482.76877 , 766.75037
1045.7389 , 814.8088 scale: 1.6022164 matrix
Matrix{[4.2499714, 0.0, -983.72644][0.0, 4.2499714, -1476.0354][0.0, 0.0, 1.0]}
BUT
pointA.x = ((x - 32.0f + Offset.x) / scale);
(73.5 - 32 + 732.0) / 2.6525576 = 482.76877
HOWEVER, 239.76859 and 482.76877 is the same point on the image.
So how does one get 482.76877 to 239.76859 ? ?
the first time the scale factor starts at 1.0 and
the Offset is 0.0
but the second time the scale factor starts at 2.6525576 and the Offset is
418.0
How does one take this into account ?
Thanks in advance
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en