Does compressing an image make the image use less memory? [closed]

被刻印的时光 ゝ 提交于 2019-12-05 14:50:32

Does compressing an image make the image use less memory?

No, the image will use the same amount of memory (alas pixels) if displayed on a monitor for example.

Compression applies to the container of the image, usually a file or a temporary memory buffer, but on screen it uses the same.

This is because you need to allocate each pixel to be displayed.

For an 1920x1080 image in 24-bits it will use 1920 x 1080 x 3 bytes (one byte for each color component in RGB -> 1 byte = 8 bits), or 6,220,800 bytes (roughly 6 mb).

Should you re-compress?

It will not take less space in memory when displayed but can be faster to load into memory. But that's about it.

Now the application need to decide if it will decompress it only when shoing the image (which will cause a lag) or decompress all and be able to display them instantly. This decision is application based so you will need to the check the specific application.

I can't speak for iOS specifically, but the best one might do is offload the decompression to a GPU, and that takes some fairly intricate architectural work. So I think it's unlikely that using a higher compression ratio will actually improve your application's performance.

However, splitting the images into smaller tiles is a common solution that I'd recommend you try.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!