I am currently using this gitup touchimageview https://github.com/MikeOrtiz/TouchImageView library.... After zoom,based on the zoom percentage I want to map the longpress coordinates to original image coordinates. Any help will be appreciated
Asked
Active
Viewed 564 times
1 Answers
0
Try to get matrix of ImageView
:
float[] values = new float[9];
getImageMatrix().getValues(values);
With this array, you have position of top-left corner in terms of image on indexes 2 and 5. For example, when values[2], values[5]
is -10,-10 it means, that left top corner of screen is 10,10 pixel of image. So, you can get coordinate of long press:
float imageX = (pressX - values[2])/scale;
float imageY = (pressY - values[5])/scale;
Recently I work with zoomed images, and use this library: https://github.com/chrisbanes/PhotoView I think its a bit better, it have some predifined touches with image coordinates, and is still improved (last commit ~2 months ago)

Tomasz Czura
- 2,414
- 1
- 14
- 18
-
1) `getImageMatrix()` 2) invert returned `Matrix` 3) call `mapPoints` on inverted `Matrix`, for a reverse mapping skip step 2) – pskink Jun 18 '16 at 17:39
-
Can you please share me detailed tutorial of this solution? – premkumar k Jun 24 '16 at 06:31