Why Bitmap size is bigger in memory than on disk in Android?

非 Y 不嫁゛ 提交于 2019-12-03 05:51:00

问题


I have a 2448x3264 image on my SD card that consumes 1,667,072 bytes but when I load it as a Bitmap and calculate its size using getRowBytes()*getHeight() I end up with 15,980,544 bytes.

Why does this happen and how can I calculate the actual size of the file?


回答1:


That is because the image is compressed when it is on disk (stored in a JPG, PNG, or similar format). Once you load the image into memory, it is no longer compressed and takes up as much memory as is necessary for all the pixels (typically width * height * 4 for RGBA_8888, or width * height * 2 for RGB_565).



来源:https://stackoverflow.com/questions/11461061/why-bitmap-size-is-bigger-in-memory-than-on-disk-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!