osmdroid 中 canvastranslatex- rotatedBitmapgetWidth 2 y - rotatedBitmapgetHeight 2; 给出Xy的具体获得方法Xy为图标的坐标值 如何获得图标的中心点坐标
要获得图标的中心点坐标,可以使用以下方法:
- 假设图标左上角的坐标为(left,top),图标的宽度为width,高度为height。
- 图标的中心点坐标为(centerX,centerY),其中centerX = left + (width / 2),centerY = top + (height / 2)。
因此,根据给定的图标坐标值X和Y,可以通过以下方式获得图标的中心点坐标:
int x = X - (rotatedBitmap.getWidth() / 2);
int y = Y - (rotatedBitmap.getHeight() / 2);
int centerX = x + (rotatedBitmap.getWidth() / 2);
int centerY = y + (rotatedBitmap.getHeight() / 2);
这样,centerX和centerY就是图标的中心点坐标。
原文地址: https://www.cveoy.top/t/topic/hJDy 著作权归作者所有。请勿转载和采集!