Using Bitmap Class Object To Draw An Image

Bitmap Example1 in Android Development

This is a sample program to draw an image using Bitmap class object.

Underlying Algorithm:

Basic description of algorithm in step by step form:

1.) Create a Project DrawBitmap.
2.) To draw an image we will create a inner class BitmapView which will extends View :

 

 

 

3.) Put an image in res/drawable
4.) Run the application.

Steps to Create:

1.) Open Eclipse. Use the New Project Wizard and select Android Project Give the respective project name i.e. DrawBitmap. Enter following information:
Project name: DrawBitmap
Build Target: Android 2.3
Application name: DrawBitmap
Package name: com.sample.DrawBitmap
Create Activity: DrawBitmap

On Clicking Finish DrawBitmap code structure is generated with the necessary Android Packages being imported along with DrawBitmap.java. DrawBitmap class will look like following:

 

 

 

Output –The final output:

Comments 5

  1. Thanks so much for this tutorial. I’m very much a noob and am piecing my app together. I wasted several hours over this past weekend trying to find a clear basic tutorial explaining displaying a bitmap. Thanks again

  2. Thanks so much for this tutorial. I’m very much a noob and am piecing my app together. I wasted several hours over this past weekend trying to find a clear basic tutorial explaining displaying a bitmap. Thanks again

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">