Is decreasing size of .png files have some effect to resulted Bitmap in memory

后端 未结 3 644
名媛妹妹
名媛妹妹 2021-01-19 21:57

I\'m writing game with a large amount of PNG pictures. All worked fine. Than I added new activity with WebView and got memory shortage. After that I made some e

3条回答
  •  轮回少年
    2021-01-19 22:06

    Memory usage of a Bitmap object in Android is related to the image resolution, not the original format (jpg, png, etc...) or filesize. It needs about 3 bytes pr pixel (1 byte pr color channel).

    Anyway, if you are using BitmapFactory to decode a image, a smaller source-file requires less memory when decoding the inputstream.

    You can test this yourself by using the Dalvik debugger (ddms). Goto the Sysinfo tab an select Memory usage from the dropdown. You will see how much memory your app i using.

提交回复
热议问题