而我真正想要的是通过带有 OnTouchListener 的对象的坐标(X,Y)显示位图的一部分(橙色正方形,中心有点)。
所以问题是我想绘制图像的一部分,就像它在图像上显示的那样(红色正方形“我想要显示的区域”)。
所以在这种情况下,例外结果是(位图的一部分):
目前我正在这样做:
public boolean onTouch(View view, MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_MOVE:
Bitmap mBitmap = Bitmap.createBitmap(sourceBitmap,view.getX() - view.getWidth(),view.getY()-view.getHeight(),250,250);
//other stuff to fill this portion of bitmap
break;
}
return true;
}
}
这是不正确的。
我怎样才能做到这一点?尝试了很多公式,但没有运气。有什么建议么?
PS 据我了解,event.getX() / event.getY()正在获得相对坐标(我不清楚,从带有触摸监听器的 imageview 对象中得到的坐标到底是什么(橙色正方形,中心点为圆点),我的意思是它获取此对象的中心或Top.Left角(X,Y))?