Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use Bitmap or Drawable to store in ImageCache on Android?

I implemented a ImageCache. But I'm curious about what type to store in it will cost less.

Now I use BitmapFactory to get the images from the internet, so I get a Bitmap first. Should I convert to a Drawable to store in my ImageCache or just store the Bitmap is fine?

Any ideas?

Thanks.

like image 634
shiami Avatar asked Sep 21 '10 09:09

shiami


2 Answers

Just store the Bitmap. That's what you're caching and I'm not sure what you'd gain by shoving it into a BitmapDrawable first. It would definitely take more space as a Drawable since it contains the bitmap anyway. You don't really lose anything either way as both are convertible back and forth.

like image 183
colithium Avatar answered Sep 23 '22 20:09

colithium


Everything depends on if you want to cache an image with different state like a selector (pressed, focused, etc). The bitmap will not contain this information compare to caching the drawable.

like image 36
Gomino Avatar answered Sep 23 '22 20:09

Gomino