Why is image size and the memory required to display it different?

-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?

Sweeper

Posted 2015-11-23T13:18:02.817

Reputation: 115

And where do you see that its size is about a hundred kB? – Run CMD – 2015-11-23T13:20:33.207

In its properties window – Sweeper – 2015-11-23T13:21:25.900

You mean, on disk? – Run CMD – 2015-11-23T13:21:58.380

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 – 2015-11-23T14:27:30.643

Answers

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!

Ben

Posted 2015-11-23T13:18:02.817

Reputation: 319

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.

Germar

Posted 2015-11-23T13:18:02.817

Reputation: 206

The Q asks how this is happening. – Run CMD – 2015-11-23T13:31:14.290

1@ClassStacker I know. And my answer is with compression – Germar – 2015-11-23T13:34:35.187

Yess... JPEG/JPG and PNG's use lossy compression methods – pun – 2015-11-23T13:39:12.473

1@The_IT_Guy_You_Don't_Like PNGs use lossy compression methods? Who told you this nonsense? – Run CMD – 2015-11-23T13:40:28.920

@The_IT_Guy_You_Don't_Like jpeg uses a lossy compression. PNG is lossless – Germar – 2015-11-23T13:41:54.357

Well not a complete nonsense as PNG supports lossless compression but it is lossless position-wise, not necessarily color-wise – pun – 2015-11-23T13:44:45.843

@ClassStacker you also might want to read this

– pun – 2015-11-23T14:21:43.330

@The_IT_Guy_You_Don't_Like What are you trying to say? How does the link contribute to the discussion? And what is a compression which is lossless position-wise, but not colour-wise? – Run CMD – 2015-11-23T14:28:33.793

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.

David Schwartz

Posted 2015-11-23T13:18:02.817

Reputation: 58 310

You mean to store an 80x80 square it just needs to store one pixel of green and some metadata saying it's 80x80? – Sweeper – 2015-11-23T13:50:14.127

@Sweeper It can do that to store it. But it can't do that to display it. – David Schwartz – 2015-11-23T14:01:07.530