sajjoo
sajjoo

Reputation: 6614

refresh a bitmap or canvas in android

can anybody tell me how to refresh or reset a bitmap or canvas to draw another image on it?

actually i have a map binary file which contains bitmap tiles in bytes now problem is i have a buffer image with buffer image i get screen image to display. so when i move my screen image i need to refresh my buffer image and draw new tiles to display on screen.

here is code to display image.

bitmap = Bitmap.createBitmap(screenWidth * (int)mapState.getiBufferMult(), screenHeight * (int)mapState.getiBufferMult(), Config.RGB_565);
        canvas = new Canvas(bitmap);
        image = new ImageView(this);

this is not full source but i hope you guys can have idea.

thanks a lot

Upvotes: 1

Views: 5546

Answers (1)

Jonathan Starr
Jonathan Starr

Reputation: 254

If you generate the bitmap that you want, you can say image.setImageBitmap(yourBitmap);

The Bitmap class also offers methods to modify an existing bitmap or replace just part of it.

If you are using the same bitmap and modifying it, call invalidate () on the ImageView when you have the bitmap ready.

Upvotes: 2

Related Questions