开发者

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

开发者 https://www.devze.com 2023-01-17 03:32 出处:网络
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.

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?

开发者_JS百科

Thanks.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消