问题
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