简体   繁体   中英

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

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?

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).

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