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

前端 未结 1 1966
后悔当初
后悔当初 2021-02-01 06:48

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

1条回答
  •  离开以前
    2021-02-01 07:45

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

    0 讨论(0)
提交回复
热议问题