android 拖动缩放窗口大小,android – 如果我移动并通过捏合,拖动和缩放调整图像大小,我怎么知道我的图像在哪里触摸过...

您可以使用应用于图像的相同变换矩阵来获取该点.您希望将屏幕坐标系之间的点转换为图像的坐标系,从而反转原始矩阵的效果.

具体来说,您希望使用用于将图像转换到屏幕上的矩阵的反转,将用户在屏幕上单击的x,y坐标转换为原始图像中的对应点.

假设矩阵包含应用于图像的变换的一些伪代码:

// pretend user clicked the screen at {20.0,15.0}

float x = 20.0;

float y = 15.0;

float[] pts[2];

pts[0] = x;

pts[1] = y;

// get the inverse of the transformation matrix

// (a matrix that transforms back from destination to source)

Matrix inverse = new Matrix();

if(matrix.invert(inverse)) {

// apply the inverse transformation to the points

inverse.mapPoints(pts);

// now pts[0] is x relative to image left

// pts[1] is y relative to image top

}@H_502_28@

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值