xcode 如何跳过压缩一个 PNG?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2051947/
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-14 19:03:50  来源:igfitidea点击:

How can I skip compressing one PNG?

iphonexcodecompressionpngitunesartwork

提问by Steven Fisher

(Note: I have solved this problem, but it took long enough that I'm posting question/answer here.)

(注意:我已经解决了这个问题,但我在这里发布问题/答案花了很长时间。)

The Xcode build process "optimizes" my PNGs when building. This isn't usually a problem, but iTunesArtwork being processed in this way causes corrupts it so that iTunes not to be able to show it. How can I prevent this?

Xcode 构建过程在构建时“优化”了我的 PNG。这通常不是问题,但以这种方式处理的 iTunesArtwork 会导致它损坏,因此 iTunes 无法显示它。我怎样才能防止这种情况?

采纳答案by Steven Fisher

You can read more about Xcode's PNG compression here: http://iphonedevelopment.blogspot.com/2008/10/iphone-optimized-pngs.html

您可以在此处阅读有关 Xcode PNG 压缩的更多信息:http: //iphonedevelopment.blogspot.com/2008/10/iphone-optimized-pngs.html

While you can turn off PNG optimization/compression entirely using "Compress PNG Files" in your project settings (it's visible only if the project's Base SDK is set to a device SDK, not a simulator SDK), you don't want to do this! Read the link above for details on why, but the gist of it is that the optimization lets the iPhone skip some math that slows down PNG display.

虽然您可以在项目设置中使用“压缩 PNG 文件”完全关闭 PNG 优化/压缩(仅当项目的基础 SDK 设置为设备 SDK,而不是模拟器 SDK 时才可见),但您不想这样做!阅读上面的链接以了解原因的详细信息,但其要点是优化让 iPhone 跳过一些减慢 PNG 显示速度的数学运算。

Xcode will only optimize PNG image files that it knows about. To prevent a specific PNG from being optimized, you change its file type so Xcode no longer knows it's a PNG.

Xcode 只会优化它知道的 PNG 图像文件。为了防止优化特定的 PNG,您可以更改其文件类型,以便 Xcode 不再知道它是 PNG。

  1. Select the file in the project window.
  2. Choose File->Get Info.
  3. On the General tab, change File Type from image.pngto file.
  1. 在项目窗口中选择文件。
  2. 选择“文件”->“获取信息”。
  3. 在“常规”选项卡上,将“文件类型”从 更改image.pngfile

(This is actually the default when you add a file without an extension, which is presumably why iTunesArtwork doesn't have one. But if you're pedantic like me you checked the File Type setting and fixed it.)

(这实际上是您添加没有扩展名的文件时的默认设置,这大概是 iTunesArtwork 没有扩展名的原因。但如果您像我一样迂腐,您可以检查文件类型设置并修复它。)

回答by Sanandrea

Found another very simple method to disable compression for a single png file. I think this is a better approach than the accepted answer because you don't have to change type (or extension) of file in the local file-system but only in XCode.

找到另一种非常简单的方法来禁用单个 png 文件的压缩。我认为这是比接受的答案更好的方法,因为您不必更改本地文件系统中的文件类型(或扩展名),而只能在 XCode 中更改。

Change the file type from Default - PNG Imageto Datain Identity and Type inspector in XCode. See below:

从更改文件类型Default - PNG Image,以Data在身份和XCode中键入检查。见下文:

Was:

曾是:

enter image description here

在此处输入图片说明

Now:

现在:

enter image description here

在此处输入图片说明

回答by MB_iOSDeveloper

For all you guys using Xcode 6.4 and above:

对于所有使用 Xcode 6.4 及更高版本的人:

Go to: "Targets" - "YourProject Name".

转到:“目标”-“您的项目名称”。

Next go to the "Build Settings" tab. Just below the Tab name click the "Basic" and "Combined" Button.

接下来转到“构建设置”选项卡。在选项卡名称正下方单击“基本”和“组合”按钮。

Next scroll down to the "Packaging" seperator and you will find "Compress PNG Files" set to "Yes" by default.

接下来向下滚动到“打包”分隔符,您会发现“压缩 PNG 文件”默认设置为“是”。

enter image description here

在此处输入图片说明

回答by python

1.Goto your build setting 
2.Search flag Compress PNG files and set it to NO.(default is YES).

After this compression of PNG images will be avoided. Just For more info

在这种压缩 PNG 图像之后将被避免。只是为了更多信息