简体   繁体   中英

How to clean up a bitmap?

I'm creating a new empty transparent Bitmap and making some modifications to it.

Is there a way to clean up this (make transparent and empty again) without creating new instance of Bitmap ?

UPDATE: Thanks for your help. I have found answer.

// Fills the bitmap's pixels with the specified Color. 
bitmap.eraseColor(somecolor);

Try this:

myBitmap.eraseColor(android.graphics.Color.TRANSPARENT);

The constant int value of TRANSPARENT is 0x00000000.

Your Bitmap must be a mutable Bitmap.

when your bitmap like this

Bitmap bitmap=.......

then convert it into mutable bitmap by using below

Bitmap mutableBitmap = bitmap.copy(Bitmap.Config.ARGB_8888, true);

then mutableBitmap.eraseColor(somecolor);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM