Android中点击ImageView,获取点击的点在Bitmap上对应的坐标

该博客转载了两篇文章,出处分别为https://blog.youkuaiyun.com/afei__/article/details/80155303和https://www.cnblogs.com/bug01/p/11186649.html ,涉及移动开发领域。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

 

@Override
public void onSingleTap(MotionEvent e) {
    // 获取触摸点的坐标 x, y
    float x = e.getX();
    float y = e.getY();
    // 目标点的坐标
    float dst[] = new float[2];
    // 获取到ImageView的matrix
    Matrix imageMatrix = imageView.getImageMatrix();
    // 创建一个逆矩阵
    Matrix inverseMatrix = new Matrix();
    // 求逆,逆矩阵被赋值
    imageMatrix.invert(inverseMatrix);
    // 通过逆矩阵映射得到目标点 dst 的值
    inverseMatrix.mapPoints(dst, new float[]{x, y});
    float dstX = dst[0];
    float dstY = dsy[1];
    // 判断dstX, dstY在Bitmap上的位置即可
}

出处:https://blog.youkuaiyun.com/afei__/article/details/80155303

转载于:https://www.cnblogs.com/bug01/p/11186649.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值