压缩图像会使图像使用更少的内存吗? [英] Does compressing an image make the image use less memory?

查看:191
本文介绍了压缩图像会使图像使用更少的内存吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个关于系统(特别是网络浏览器)处理压缩图片的架构/概念问题。



我们正在处理一个图库网络应用在工作,在一个页面上有十一个1920x1080图像,你可以在iPad上滑动。我们发现它非常慢,我几乎肯定是因为iPad在内存中和在页面上同时有这么多的大图像有麻烦。



有人建议我们更多地压缩图像;他们目前是PNG,他们想将它们重新压缩为JPG。显然,文件大小会更小,但除非iPad(和其他人)有一种直接渲染压缩图像到屏幕(帧缓冲区)的方法,我想他们必须解压缩图像到内存渲染。在这种情况下,似乎压缩不会影响渲染它们的性能。 (除了轻微增加的处理能力,将它们更多解压缩。)



我的理解和假设是否正确?



更多信息 - 在你告诉我之前阅读这篇文章是我的开发者,而不是用户:



使用更少的空间和使用更少的内存是不一样的。我们没有存储的问题,我们在渲染的性能方面有问题。



当我们从方程中删除图像时,性能是好的;所以我相当肯定的瓶颈是图像,而不是代码。



问题是压缩使图像使用更少的内存,因为其他人想压缩图像更多以获得性能。据我理解压缩的架构,你仍然需要解压缩到内存中的原始大小才能使用它,因此压缩不会影响内存使用;

解决方案


压缩图像会使图像使用更少的内存吗? p>

否,如果在显示器上显示,图像将使用相同的内存量(唉像素)。



压缩适用于图像的容器,通常是文件或临时内存缓冲区,但在屏幕上它使用相同的。



这是因为您需要分配要显示的每个像素。



对于24位的1920x1080图像,它将使用1920 x 1080 x 3字节(每个字节一个字节


应该重新压缩吗?


当显示内存时,内存空间不会减少,但可以更快地加载到内存。



现在,应用程序需要决定是否只在拍摄图片时解压缩图片(这将导致延迟)或解压缩所有图片,并且能够立即显示它们。这个决定是基于应用程序的,所以你需要检查具体的应用程序。


This is sort of an architectural/conceptual question regarding how a system (specifically a web browser) handles compressed images.

We're dealing with an "image gallery" web app at work that has eleven 1920x1080 images on a page that you can swipe through on an iPad. We're finding it to be extremely slow and I'm almost certain it's because the iPad is having trouble with having so many large images in memory and on the page at the same time.

Some have suggested we compress the images more; they're currently PNGs, and they want to recompress them to JPG. Obviously the file size will be smaller, but unless the iPad (and others) have a way of directly rendering a compressed image to the screen (frame-buffer), I'd think they'd have to decompress the image into memory before rendering. In that case, it seems like the compression wouldn't affect the performance of rendering them. (Other than the slight added processing power of decompressing them "more".)

Is my understanding and assumptions correct? Should we resize, or recompress the images?

Thanks

More information- read this before you tell me "yeah compressed images are smaller" - I'm a developer, not a user:

Using less space is not the same as using less memory. We're not having a problem with storage, we're having a problem with performance of rendering. The code is simple and just animates between one div and the next to give the "swipe" effect to the gallery.

When we remove the images from the equation, the performance is fine; so I'm fairly certain the bottleneck is the images, not the code.

The question being asked is "does compression make the image use less memory" because others want to compress the images more to gain performance. As far as I understand the architecture of compression though, you still have to decompress it to its original size in memory to use it and thus the compression does not affect memory usage; only storage and transmission.

解决方案

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.

这篇关于压缩图像会使图像使用更少的内存吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆