开发者

Drawing a picture in android

I want to draw a picture (bmp,jpg,png) into the canvas (using the onDraw() method) of a class that extends the View class. I would like to be able to draw parts of the picture, not the whole at once.

I would really appreciate an exampl开发者_如何学Ce.


You must first realize where the image is located. It can be bundled in your application in res/ or assets/ directory; or it can be loaded from SD card or internet. That will determine the way you'll obtain a Bitmap object, representing your image. If you distribute the image along with your application, place it in res/ or assets/ directory of your project. The difference is how you refer to the file - when in res/ you use R.drawable. id-s, when in assets/ you use filename.

To draw a portion of a Bitmap object on a Canvas, call the drawBitmap method.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜