我正在尝试在ImageView上绘制一个圆形。圆形被绘制出来了,但坐标错误。
protected void onImageClicked(float x, float y, ImageView image) {
if (diff.isDifferenceClicked((int)x, (int) y)){
BitmapDrawable bmd = (BitmapDrawable) image.getDrawable();
Bitmap bm= bmd.getBitmap();
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(Color.RED);
paint.setStyle(Paint.Style.STROKE);
Canvas canvas = new Canvas(bm);
canvas.drawCircle(x, y, 25, paint);
image.setImageBitmap(bm);}
}
x和y分别是event.getX()
和event.getY()
,圆圈在位图的左上方绘制得更高。