Calculation Formula for memory usage of Android Bitmap, androidbitmap
Android definition of each resolution
Calculation method when the image is stored in ARGB_8888 format
Memory usage = image length * Image Width * 4 bytes
Image length = original image Length
(Device DPI/folder DPI)
Image Width = Original Image Width(Device DPI/folder DPI)
The example is as follows:
The image size is 200*320. The device is a red-meter dpi of 320 and belongs to an xhdpi device.
Verify that an image is placed in hdpi and the output result is as follows:
DD/MainActivity (13014): dpi: 320 bitmap ByteCount: 456036
Image length = (320/240) * 200 = 266.67
Image Width = (320/240) * 320 = 426.67
Memory usage = 266.67*426.67*4 = 455116 is roughly the same as the actual value
Verification 2: The image is placed under xxhdpi and the code output is as follows:
D/MainActivity (13014): dpi: 320 bitmap ByteCount: 113316
Image length = (320/480) * 200 = 133.33
Image Width = (320/480) * 320 = 213.33
Memory usage = 133.33*213.33*4 = 113774 is roughly the same as the actual value.