iOS - 基于设备的不同图像或缩放相同的图像? [英] iOS - Different images based on device OR scaling the same image?

查看:132
本文介绍了iOS - 基于设备的不同图像或缩放相同的图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

开发人员似乎总是为不同的设备创建不同的图像资源,并根据设备加载它们。但是,为最大分辨率设备(iPad)创建图像,然后为iPhone 6,5等缩小图像是否有任何缺点?

It seems that developers always create different image assets for different devices and load them based on the device. But are there any drawbacks to just creating images for the largest resolution device (iPad) and then scaling that image down for iPhone 6, 5, etc?

我使用SpriteKit,所以我只创建不同大小的SKSpriteNodes并对它们应用相同的纹理并缩放它以适合节点。

I use SpriteKit, so I would just create SKSpriteNodes of different sizes and apply the same texture to them and scale it to fit the node.

我知道可以考虑性能(为旧设备加载大图像)。但除此之外,还有什么吗?这些图像会出现像素化/模糊吗?

I know that performance can be something to consider (loading large images for older devices). But that aside, is there anything else? Would these images appear more pixelated/blurry?

推荐答案

完美/纯粹的答案是为每个设备使用单独的图像和代码解析度。

The perfect/purist answer would be to use separate images and code for each device resolution.

然而,从您自己的时间和理智的角度来看,考虑到分辨率和屏幕尺寸的数量不会很快减少,使用有限的设置是有意义的。那么为什么要浪费时间准备多个图像,除非xcode这样做更简单。

However from your own time and sanity perspective, it makes sense to use a limited set given that the number of resolutions and screen sizes is not going to get less any time soon. So why waste hours preparing multiple images unless it can be made simpler to do so by the likes of xcode.

对于方形或固定宽高比的图像,我认为您只需要一张图像。对于像背景这样的图像存在问题,无论分辨率如何,至少需要满足不同方面的分辨率:所以单独的宽高比图像是必不可少的(如3:2和16:9),除非你不介意挤压,拉伸或裁剪图像。

For images which are square or fixed aspect ratios I think you only need one image. There is the issue for images like backgrounds where regardless of resolution you will need to cater at least for different aspect rations: so separate aspect ratio images are essential (like 3:2 and 16:9) unless you don't mind squashing, stretching or cropping the images.

如果您发现测试中的性能受损,您可以随时添加较低分辨率的图像。

If you find performance suffers in testing, you can always add lower resolution images later.

就像素化而言,这是你无法避免的。如果您考虑从x3到x1分辨率时发生的情况,则必须将3x3像素混合到1x1中。在高分辨率下,任何单个像素宽(如线)或在几个像素上具有快速颜色变化的东西将受到最大影响。你可以在网上看到很多关于此的文章。

In terms of pixelation, that is something you can not avoid. If you think about what is happening when you go from a x3 to an x1 resolution, you are having to blend 3x3 pixels into 1x1. At high resolution, anything which is a single pixel wide (like a line) or has rapid color change over a few pixels will suffer most. There are many articles online about this you can look at.

避免像素化的唯一方法是使用矢量图像,但这需要特殊的软件才能加载矢量图像并将它们渲染成UIImages。

The only way to avoid pixelation would be to use vector images, but that would require special software to load vector images and render them into UIImages.

缩小时,每张图片都会受到不同的影响。一个想法可能是为x2图像,你缩小1为iPhone 3和向上1到x3为iPhone 6+。这将以原始分辨率覆盖大多数当前设备,并且可能提供不太明显的像素化。

Every image will suffer differently when you scale down. A thought might be to go for x2 images which you scale down 1 for iPhone 3 and up 1 to x3 for iPhone 6+. That would cover the majority of current devices at native resolution and perhaps offer less noticeable pixelation.

这篇关于iOS - 基于设备的不同图像或缩放相同的图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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