开发者

How to draw bitmap and circle at the same point in android

开发者 https://www.devze.com 2023-03-22 18:01 出处:网络
I am trying to draw bitmap and circle at the same point using the following code. But circle and bitmap drawn at different places.

I am trying to draw bitmap and circle at the same point using the following code. But circle and bitmap drawn at different places.

canvas.drawBitmap(reSized, 0, 0, null);  
pcanvas.drawCircle(stDropCurPoint.x, stDropCurPoint.y, 3, mPaint);  
canvas.drawBitmap(bitmap, 0, 0,null);  
canvas.save();  
canvas.drawBitmap(bmp, stDropCurPoint.x, stDropCurPoint.y, null);  
canvas.restore();

My bitmap "bmp" width and height are 50*50 . I am tryi开发者_JS百科ng to draw a circle of radius 3. Kindly let me know how to draw circle and bitmap at the same point . Thanks in advance.


As the bitmaps x and y coordinates refer to the top left of the image, you might want to offset it half its width and height to center it to the stDropCurPoint.

canvas.drawBitmap(bmp, stDropCurPoint.x - bmp.getWidth()/2, stDropCurPoint.y - bmp.getHeight()/2, null); 
0

精彩评论

暂无评论...
验证码 换一张
取 消