计算Bitmap占用的内存大小

2016-10-28  本文已影响0人  yuansip

参考资料

Android开发绕不过的坑:你的Bitmap究竟占多大内存?

相关因素

Bitmap 在内存当中占用的大小其实取决于:

计算公式

int realWidth = (int) (rawWidth * targetDensity / (float) rawDensity + 0.5f)
int realHeight = (int) (rawHeight * targetDensity / (float) rawDensity + 0.5f) 
int memory = realWidth * realHeight * bytes_for_current_colorMode;

BitmapFactory.Options:

If set to a value > 1, requests the decoder to subsample the original image, returning a smaller image to save memory.

上一篇下一篇

猜你喜欢

热点阅读