Drawing a part of a Drawable on a Canvas

Tutorials concerning the OpenGL® ES cross-platform API for full-function 2D and 3D graphics on the Google-Android platform.

Drawing a part of a Drawable on a Canvas

Postby Risike » Mon May 25, 2009 11:40 am


I would like to draw a part of an image (png) I have in the "drawable" folder on a canvas.
But there is only a drawBitmap method to draw some parts of an image.

How can I do this please ?
Posts: 3
Joined: Wed May 13, 2009 1:23 pm


Postby cokoyan » Sun Jul 12, 2009 6:53 pm

you need to load the compete image and extract one part like this :

Bitmap theSpriteSheet = BitmapFactory.loadBitmap(...);
Bitmap theSpritePart = Bitmap.createBitmap( theSpriteSheet, x,y,width,height);

theSpritePart contain only a part of the sprite sheet.
Approxymatly it's like this if I understand correctly our request ^^
Junior Developer
Junior Developer
Posts: 13
Joined: Sat Jul 04, 2009 7:05 pm


Return to Android 2D/3D Graphics - OpenGL Tutorials

Who is online

Users browsing this forum: No registered users and 3 guests