Draw portion of image on Canvas

♀尐吖头ヾ 提交于 2019-12-24 04:41:14

问题


I have an image of size 265x256 and I want to draw the top-left and right-bottom portion of size 16x16 at random location on Canvas Can someone please share the concept or code to do this


回答1:


I think you can use Canvas method

public void drawBitmap (Bitmap bitmap, Rect src, RectF dst, Paint paint)

where documentation states second argument src as

If the source rectangle is not null, it specifies the subset of the bitmap to draw.

So you can pass the rectangle of the source bitmap that you want to draw in the second argument.



来源:https://stackoverflow.com/questions/12946609/draw-portion-of-image-on-canvas

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!