什么占用较少的内存实际图像或绘制图像? [英] What consumes less memory an actual image or a drawn image?

查看:155
本文介绍了什么占用较少的内存实际图像或绘制图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在设计一个应用程式,我正在使用 PaintCode 建立一些图片。

I am designing an app and I am creating some images with PaintCode.

使用该程序,我得到我创建的每个图像的实际代码,从而允许我选择插入代码或使用实际图像。我想知道什么会消耗更少的内存,图像代码或实际的PNG?

Using that program I get the actual code for each image that I create, thus allowing me to choose to insert code or use an actual image. I was wondering what would consume less memory, the image code or an actual PNG?

我知道图像内存消耗是 width x height x 4 =内存中的字节,但我不知道由代码生成的图像是更有效的内存,更少的内存有效性还是打破了?

I know an image memory consumption is width x height x 4 = bytes in memory but I have no idea whether an image that is generated by code is more memory efficient, less memory efficient or breaks even?

这个决定是特别重要的给定不同的屏幕分辨率。它更容易在代码中创建一个图像,并将其扩展到任何我想要的大小,而不是每次去Photoshop。

This decision is particularly important given the different screen resolutions. its a lot easier to create an image in code and expand it to whatever size I want rather than go to Photoshop every time.

推荐答案

如果最终图像尺寸(点尺寸)与显示尺寸(点尺寸)相同,那么它根本没有区别。最终在应用中显示的是100x100位图。

It makes no difference at all, provided the final image size (in point dimensions) is the same as the display size (in point dimensions). What is ultimately displayed in your app is, say, a 100x100 bitmap. Those are the same number of bits no matter how they were obtained to start with.

内存被浪费的地方是持有一个大得多的图片

The place where memory gets wasted is from holding on to an image that is much larger (in point dimensions) than it is actually being displayed in the interface.

如果我从应用程序包中加载3MB的PNG,请将其缩小为100x100,然后将其绘制接口,并放弃原来的3MB PNG,结果是完全相同数量的内存在后备存储,就好像我绘制的100X100图形上下文的内容自己使用Core Graphics(这是PaintCode帮助你做的 - 它最终没有你自己不能做的)。

If I load a 3MB PNG from my app bundle, scale it down to 100x100, and draw it in the interface, and let go of the original 3MB PNG, the result is exactly the same amount of memory in the backing store as if I draw the content of a 100X100 graphics context from scratch myself using Core Graphics (which is what PaintCode helps you do - it ultimately does nothing you could not have done yourself).

PaintCode只是一个拐杖,谁是出于恐惧或无知或懒惰,或者因为他们已经有了他们想要重用的矢量艺术,不想自己编写Core Graphics代码。最终,它生成完全相同的核心图形代码,你会写。 Core Graphics绘制了一个位图(一个图形上下文)。

PaintCode is merely a crutch for people who, either out of fear or ignorance or laziness or because they already have vector art they want to reuse, do not want to write Core Graphics code themselves. Ultimately it generates exactly the same Core Graphics code you would have written. And Core Graphics draws into a bitmap (a graphics context).

这篇关于什么占用较少的内存实际图像或绘制图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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