xcode 在 iOS 中使用图像(png、jpg)的最佳格式是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13656065/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 02:13:35  来源:igfitidea点击:

What is best format to use images (png,jpg) in iOS?

iosxcodeuiimageviewuiimage

提问by Fabio

I'm using a background image, and I would like it to weigh little without losing quality.

我正在使用背景图像,我希望它的重量轻而不会降低质量。

I found this option in Xcode.

我在 Xcode 中找到了这个选项。

Project-> Packaging -> Compress PNG Files

Project-> Packaging -> Compress PNG Files

This would help me to improve file sizes?

这会帮助我改善文件大小吗?

回答by xlharambe

The format to use images is the PNG-24file format, since it provides the highest quality image per pixelin the lowest file size. Also, in ios development, png is favored because of the multiple formatting and optional editing.

使用图像的格式是PNG-24文件格式,因为它pixel以最小的文件大小提供最高质量的图像。此外,在 ios 开发中,png 由于多种格式和可选编辑而受到青睐。

Most importantly, PNG is a lossless compression formatt, that means it compresses images without losing any quality.

最重要的是,PNG 是一种无损压缩格式,这意味着它可以在不损失任何质量的情况下压缩图像。

回答by AlexWien

Png Supports transparency, While jpg does Not. Therefore they are favored by Apple.

Png 支持透明,而 jpg 不支持。因此,它们受到苹果的青睐。

回答by TieDad

PNG supports transparent background while jpg not. If you don't use a picture that need transparent background, then I think there is no significant difference between jpg and png.

PNG 支持透明背景,而 jpg 不支持。如果你不使用需要透明背景的图片,那么我认为jpg和png没有明显区别。

回答by Adam Johnson

As most of the others have said: for iOS development pngis the preferred option.

正如大多数人所说:iOS 开发png是首选。

To keep file size down, you can use PNG-8though the transparency can get a little funny, so be careful.

为了减小文件大小,您可以使用PNG-8尽管透明度会变得有点有趣,所以要小心。

回答by UID Pro Berlin

JPG is a file format witch uses a real compressing method without changing the color depth. It can reduce the file size dramatically, infinitely variable, but in the same way with loss of quality. Usually JPG is recommend on photos, because of there wide color profile. A JPG with 80% compression could have a small loss of visual quality which most people don't recognize at all.

JPG 是一种文件格式,使用真正的压缩方法而不改变颜色深度。它可以极大地减少文件大小,无限可变,但以同样的方式损失质量。通常推荐在照片上使用 JPG,因为它有广泛的色彩配置文件。压缩率为 80% 的 JPG 可能会稍微降低视觉质量,而大多数人根本无法识别。

You can use the PNG 24bit for photos as well, but with bigger file size.

您也可以将 PNG 24 位用于照片,但文件更大。

Additionally you can use PNG 8bit for graphics like logos or charts. There the color palette is reduced to 256 optimized/selected colors. The loss of visual quality is lower on graphics, because they already come with fewer colors.

此外,您可以将 PNG 8 位用于徽标或图表等图形。调色板减少到 256 种优化/选择的颜色。图形的视觉质量损失较低,因为它们已经带有较少的颜色。

In any case, it remains a case to decision, and yes I'm a designer.

无论如何,这仍然是一个需要决定的案例,是的,我是一名设计师。