Tuesday, August 21, 2012

android: loading and displaying images on canvas


copy and paste image into res\drawable folder in project folder
R.java in "gen" should include this image with an id. Note: filename to be all lower-case

// loading, assuming written in a View class
Bitmap bmp = BitmapFactory.decodeResource(this.getResources(), R.drawable.image_id); 
// displaying
canvas.drawBitmap(bmp, 50, 30, null);

No comments: