Android-缩放后从ImageView获取原始X和Y点
创始人
2024-08-19 22:00:46
0

要在缩放后从ImageView获取原始X和Y坐标,需要先将ImageView中的坐标转换为实际的位图像素坐标。可以使用以下方法:

  1. 获取ImageView中心点的坐标

int[] imageViewLocation = new int[2]; imageView.getLocationOnScreen(imageViewLocation); int imageViewX = imageViewLocation[0] + imageView.getWidth() / 2; int imageViewY = imageViewLocation[1] + imageView.getHeight() / 2;

  1. 获取ImageView的缩放比例

float scaleFactor = imageView.getScaleX();

  1. 将实际坐标计算为像素坐标

int drawableWidth = imageView.getDrawable().getIntrinsicWidth(); int drawableHeight = imageView.getDrawable().getIntrinsicHeight(); int bitmapWidth = imageView.getDrawable().getBounds().width(); int bitmapHeight = imageView.getDrawable().getBounds().height();

float actualImageWidth = drawableWidth * scaleFactor; float actualImageHeight = drawableHeight * scaleFactor;

float xPercentage = (imageViewX - imageViewLocation[0]) / (float)imageView.getWidth(); float yPercentage = (imageViewY - imageViewLocation[1]) / (float)imageView.getHeight();

float xInImage = xPercentage * actualImageWidth; float yInImage = yPercentage * actualImageHeight;

  1. 对于任何特定的点,可以使用以下代码获取其在图像中的位置:

float[] point = new float[] {xInImage, yInImage}; Matrix matrix = imageView.getImageMatrix(); matrix.invert(matrix); matrix.mapPoints(point);

现在,point数组将包含任何特定点在图像中的像素坐标。

相关内容

热门资讯

aapoker辅助器是真的吗,... aapoker辅助器是真的吗,wpk有辅助挂吗,智星德州菠萝辅助是一款可以让一直输的玩家,快速成为一...
德扑之星ai代打,wpk到底有... 德扑之星ai代打,wpk到底有没有外挂,智星德州菠萝有挂吗是一款可以让一直输的玩家,快速成为一个“必...
wepokeai代打辅助,微扑... 自定义微扑克ai会被检测到吗系统规律,只需要输入自己想要的开挂功能,一键便可以生成出微扑克专用辅助器...
wepoke透明挂辅助,wep... 1、wepoke透明挂辅助,wepoke软件透明演示,智星菠萝德州有挂吗;代表性(透视辅助软件透明挂...
aapoker辅助使用教程,微... aapoker辅助使用教程,微扑克辅助工具,智星德州菠萝怎么看有没有开挂(1)aapoker辅助使用...
wepoke辅助工具的使用教程... wepoke辅助工具的使用教程,wepoke透明挂要多少钱,智星德州菠萝外挂1、构建自己的微扑克辅助...
德州辅助软件开发定制,wpk到... 德州辅助软件开发定制,wpk到底有没有外挂,智星德州辅助器1、很好的工具软件,可以解锁游戏的wpk到...
wpk有透视辅助吗,wepok... wpk有透视辅助吗,wepoke黑科技功能,智星德州菠萝怎么开挂;人气非常高,ai更新快且高清可以动...
wepoke算法,wepoke... wepoke算法,wepoke有没有辅助挂,智星菠萝德州辅助您好,wepoke有没有辅助挂,确实是有...
we-poker有挂吗,wep... we-poker有挂吗,wepoke辅助透,智星菠萝德州辅助1、构建自己的微扑克辅助插件;2、选择您...