图像存档 VS 图像条

发布于 2024-07-05 07:39:02 字数 276 浏览 11 评论 0原文

我注意到很多游戏/应用程序(在移动版本上很常见)将大量图像打包到图像条中。 我认为这样做的优点是使程序更加整洁(文件系统方面)并减少(卸载)安装时间。 在应用程序运行时,整个图像条被分配并从 FS 复制到 RAM。 相反,图像可以存储在图像存档中,并在运行时解压到 RAM 中的多个图像结构中。

在我看来,图像条带方法的效率较低,因为缓存性能较差,而且即使使用最佳矩形打包算法,条带中存储的图像之间也会存在空白,导致 RAM 浪费。

与使用图像存档文件相比,使用图像条有哪些优点?

i've noticed that plenty of games / applications (very common on mobile builds) pack numerous images into an image strip.
I figured that the advantages in this are making the program more tidy (file system - wise) and reducing (un)installation time. During the runtime of the application, the entire image strip is allocated and copied from FS to RAM.
On the contrary, images can be stored in an image archive and unpacked during runtime to a number of image structures in RAM.

The way I see it, the image strip approach is less efficient because of worse caching performance and because that even if the optimal rectangle packing algorithm is used, there will be empty spaces between the stored images in the strip, causing a waste of RAM.

What are the advantages in using an image strip over using an image archive file?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

猫七 2024-07-12 07:39:02

如果片段中的图像可能同时出现(即都是动画的一部分),则缓存不会像您想象的那样是一个问题。
就打包算法而言,大多数通用算法都会产生类似的效率水平 - 为了大幅提高打包效率,您通常必须编写针对所涉及的数据集进行优化的算法。

正如任何类型的优化(缓存或打包)的通常情况一样,不要担心它,直到它被证明是一个问题,然后您需要在充分理解上下文的情况下解决问题。

Caching will not be as much of an issue as you think, if the images in the strip are likely to appear at the same time - i.e. are all part of an animation.
As far as packing algorithms are concerned, most generic algorithms produce similar levels of efficiency - to get huge increases in packing efficiency you normally have to write an algorithm that is optimised for the dataset involved.

As is usually the case with optimization of any kind - caching or packing - don't worry about it until it's been proved to be an issue, and then you need to approach the problem with a good understanding of the context.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文