JimBadger
JimBadger

Reputation: 129

Android Bitmap Drawing

Can you draw a Bitmap to a Canvas by telling it to draw Bitmap's X,Y at Canvas' X1,Y1? Rather than drawing Bitmap's 0,0 at Canvas X1, Y1?

Upvotes: 0

Views: 2825

Answers (1)

Konstantin Burov
Konstantin Burov

Reputation: 69228

That's truly possible the Canvas.drawBitmap(Bitmap bitmap, Rect src, RectF dst, Paint paint) is here to help. You can specify src region to draw. Look at Canvas docs for more.

Also you may use Bitmap.createBitmap(Bitmap source, int x, int y, int width, int height) to extract that part of original image you want to render. Then just render extracted Bitmap as ususal. More info about the method is available on Google's docs.

Upvotes: 2

Related Questions