UIImages的图像大小,1024 x 1024? [英] image size for UIImages, 1024 x 1024?

查看:110
本文介绍了UIImages的图像大小,1024 x 1024?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Apples docs state:

Apples docs state:


您应该避免创建大小超过1024 x
1024的UIImage对象。除了大量的内存这样的图像会消耗掉b $ b,在OpenGL ES中将图像用作纹理
或者将图像绘制到视图或图层时,可能会遇到问题。如果您执行基于代码的
操作,例如通过将大小超过1024 x 1024
像素的图像绘制到位图支持的图形上下文,则此大小
限制不适用。事实上,
可能需要以这种方式调整图像大小(或将其分成几个
较小的图像),以便将其绘制到您的一个视图中。

You should avoid creating UIImage objects that are greater than 1024 x 1024 in size. Besides the large amount of memory such an image would consume, you may run into problems when using the image as a texture in OpenGL ES or when drawing the image to a view or layer. This size restriction does not apply if you are performing code-based manipulations, such as resizing an image larger than 1024 x 1024 pixels by drawing it to a bitmap-backed graphics context. In fact, you may need to resize an image in this manner (or break it into several smaller images) in order to draw it to one of your views.

我认为这意味着如果我们使用非方形图像,我们应该将它们分解成更小的图像?是否有任何具体的文件或解释,或者是否有任何经验提示?

I assume this means that if we are working with non-square images, we should break them into smaller images? Is there any specific documentation or explanations on this, or does anyone have any any tips from experience?

感谢阅读。

推荐答案

在A5之前的iOS上设备,最大的OpenGL ES纹理大小是2048x2048(Apple的文档在这方面是错误的,说它是1024x1024)。这意味着你不能拥有比任何一个维度都大的图像。较新的iOS设备(iPhone 4S,iPad 2,iPad 3)的最大纹理尺寸为4096x4096。

On the pre-A5 iOS devices, the maximum OpenGL ES texture size was 2048x2048 (Apple's documentation is incorrect in this regard by saying it's 1024x1024). What that means is that you can't have an image larger than that in either dimension. The newer iOS devices (iPhone 4S, iPad 2, iPad 3) have a maximum texture size of 4096x4096.

这并不意味着你必须有方形图像,只是图像的宽度或高度不得超过2048(在较新的设备上再次为4096)。如果您尝试这样做,我相信您的图片将呈现为黑色。

It does not mean that you have to have square images, just that an image must not have its width or height exceed 2048 (again, 4096 on newer devices). If you try to do so, I believe your image will just render as black.

这曾经是所有未被CATiledLayer支持的UIViews的限制,但我相信他们现在自动平铺足够大的视图。如果您需要处理大于2048x2048的图像,则需要将其托管在CATiledLayer等中。

This used to be a limitation for all UIViews not backed by a CATiledLayer, but I believe they now do tiling on large enough views automatically. If you need to work with an image larger than 2048x2048, you'll need to host it in a CATiledLayer or the like.

内存警告值得关注,虽然。图像以未压缩的形式存储在内存中,无论其来源如何,因此您需要查看每2048x2048图像16,777,216字节(RGBA每像素4个字节)。如果你不小心,这可以很快加起来。

The memory cautions are worth paying attention to, though. Images are stored in their uncompressed form in memory, no matter their source, so you're looking at 16,777,216 bytes per 2048x2048 image (4 bytes per pixel for RGBA). That can add up pretty quickly, if you're not careful.

这篇关于UIImages的图像大小,1024 x 1024?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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