触摸点双指缩放后,对于坐标图像 [英] Touch point coordinates with respect to Image after pinch zoom

查看:230
本文介绍了触摸点双指缩放后,对于坐标图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何计算坐标相对于图像放大后的图像?
要放大我跟着网址的图片:<一href=\"https://github.com/MikeOrtiz/TouchImageView/blob/master/src/com/example/touch/TouchImageView.java\" rel=\"nofollow\">https://github.com/MikeOrtiz/TouchImageView/blob/master/src/com/example/touch/TouchImageView.java.

How to calculate the coordinates with respect to image after zoom the image? To zoom the image I followed the url: https://github.com/MikeOrtiz/TouchImageView/blob/master/src/com/example/touch/TouchImageView.java.

如果我们在特定的点触摸图像前放大则对应的值

if we touch the image at particular point before Zoom then corresponding values are

point:(3,2)
top left corner of image:(0,0)
top left corner of screen:(0,0)
scale factors:(1.25,0.98)

在变焦时,图像:

如果我们拖动图像,直至图像左上角在同一接触点(前捏)一致屏幕左上角的触摸图像完全相同然后

if we drag the image until the image top left corner coincides the screen top left corner and touch image exactly at same touch point(before pinch) then

point:(540,220)
top left corner of image:(0,0)
top left corner of screen:(0,0)
scale factors:(4.78,2.67)

如果我们拖动图像,直至图像右上角的屏幕右上角的触摸图像在同一接触点(前捏)正好不谋而合然后

if we drag the image until the image top right corner coincides with the screen top right corner and touch image exactly at same touch point(before pinch) then

point:(1080,340)
top left corner of screen:(0,0)
top left corner of image:(-2430,0)
scale factors:(4.78,2.67)

如果我们拖动图像,直到左下角与屏幕底部重合的图像在同一接触点的左上角和触摸图像完全相同(前捏),那么

if we drag the image until the image bottom left corner coincides with the screen bottom left corner and touch image exactly at same touch point(before pinch) then

point:(670,80)
top left corner of screen:(0,0)
top left corner of image:(0,-890)
scale factors:(4.78,2.67)

如果我们拖动图像,直至图像右下角的屏幕右下角和触摸图像在同一接触点(前捏)正好不谋而合然后

if we drag the image until the image bottom right corner coincides with the screen bottom right corner and touch image exactly at same touch point(before pinch) then

point:(456,274)
top left corner of screen:(0,0)
top left corner of image:(-2430,-890)
scale factors:(4.78,2.67)

如果我们在屏幕上设置图像[未设置任何角落]

if we set the image over the screen [ not to set the any corner]

point:(743,146)
top left corner of screen:(0,0)
top left corner of image:(-1280,-423)
scale factors:(4.78,2.67)

在上述所有情况下,我取得联系事件中的坐标

In all the above scenarios I am getting the coordinates in touch event as

x_cord=event.getX();
y_cord=event.getY();

我得到的接触点是相对于屏幕。

The touch points I am getting are with respect to the screen.

我怎么能根据图像计算出触摸点?

How can I calculate the touch points according to the Image?

感谢和放大器;商祺
迷你。

Thanks & Regards mini.

推荐答案

我们可以根据图像的大小计算相对点计算

We can calculate by calculating relative point according to the image size

float[] values = new float[9];
matrix.getValues(values);
x_coord = ((e.getX() - values[2])*scaleX )/values[0];
y_coord= ((e.gety() - values[5])*scaleY )/ values[4];

这篇关于触摸点双指缩放后,对于坐标图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆