-1

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

1 Answers1

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