-1

I learned from a stack overflow post that the memory required to display an image and the image size is equal to

4 * image dimensions

I have some 800x800 images and I see that its size is about a hundred KB, which I think is quite small. But according to the formula above, it needs more than 2MB to display it!

The SO post says that because the bitmap is using ARGB colors, each pixel requires 4 bytes of storage space. So that's why the formula is 4 * image dimensions. But I see that only 100KB of space is required to store the image!

Does the computer use a different method to store the image? Does 1 pixel still needs 4B to be stored? How is this happening?

  • And where do you see that its size is about a hundred kB? – Run CMD Nov 23 '15 at 13:20
  • In its properties window – Sweeper Nov 23 '15 at 13:21
  • You mean, on disk? – Run CMD Nov 23 '15 at 13:21
  • It's a fact that the answer you quote gives a bad recommendation. RGB888 is you first choice if you don't need transparency, not ARGB. Especially on a mobile device. It saves 25% memory as compared to ARGB and also, if you stack Android Views, adding transparency will slow down things. – Run CMD Nov 23 '15 at 14:27
3

IrfanView can help to quickly view the used memory:
(see the memory calculation)

enter image description here

WIDTH x HEIGHT x (BITS PER PIXEL) = memory needed to load the full image

Cheers!

2

Your image is compressed (e.g. with jpeg or png). If you'd store the image in an uncompressed format (tiff without zip compression) you would get that size on disk, too.

  • The Q asks how this is happening. – Run CMD Nov 23 '15 at 13:31
  • 1
    @ClassStacker I know. And my answer is with compression – Germar Nov 23 '15 at 13:34
  • Yess... JPEG/JPG and PNG's use lossy compression methods – pun Nov 23 '15 at 13:39
  • 1
    @The_IT_Guy_You_Don't_Like PNGs use lossy compression methods? Who told you this nonsense? – Run CMD Nov 23 '15 at 13:40
  • @The_IT_Guy_You_Don't_Like jpeg uses a lossy compression. PNG is lossless – Germar Nov 23 '15 at 13:41
2

The memory required to store an image can be less than the memory required to display it. For example, if the image is an 80x80 green rectangle, you can store it as the equivalent of "80 by 80 green rectangle". But to display it, you need 1600 green dots, each of which is going to take up some space.

  • You mean to store an 80x80 square it just needs to store one pixel of green and some metadata saying it's 80x80? – Sweeper Nov 23 '15 at 13:50
  • @Sweeper It can do that to store it. But it can't do that to display it. – David Schwartz Nov 23 '15 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.