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.