您应该能够使用这些例程将屏幕坐标转换为位图坐标:
/**
* Convert points from screen coordinates to point on image
* @param point screen point
* @param view ImageView
* @return a Point on the image that corresponds to that which was touched
*/
private Point convertPointForView(Point point, ImageView view) {
Point outPoint = new Point();
Matrix inverse = new Matrix();
view.getImageMatrix().invert(inverse);
float[] convertPoint = new float[] {point.x, point.y};
inverse.mapPoints(convertPoint);
outPoint.x = (int)convertPoint[0];
outPoint.y = (int)convertPoint[1];
return outPoint;
}
/**
* Convert a rect from screen coordinates to a rect on the image
* @param rect
* @param view
* @return a rect on the image that corresponds to what is actually shown
*/
private Rect convertRectForView(Rect rect, ImageView view) {
Rect outRect = new Rect();
Matrix inverse = new Matrix();
view.getImageMatrix().invert(inverse);
float[] convertPoints = new float[] {rect.left, rect.top, rect.right, rect.bottom} ;
inverse.mapPoints(convertPoints);
outRect = new Rect((int)convertPoints[0], (int)convertPoints[1], (int)convertPoints[2], (int)convertPoints[3]);
return outRect;
}