如何跳过压缩一张 PNG?

发布于 2024-08-17 14:26:16 字数 157 浏览 3 评论 0原文

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

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

(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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

向日葵 2024-08-24 14:26:16

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

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

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

  1. 在项目窗口中选择文件。
  2. 选择“文件”->“获取信息”。
  3. 在常规选项卡上,将文件类型从 image.png 更改为 file

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

You can read more about Xcode's PNG compression here:
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.

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.

  1. Select the file in the project window.
  2. Choose File->Get Info.
  3. On the General tab, change File Type from image.png to file.

(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.)

无人问我粥可暖 2024-08-24 14:26:16

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

在 XCode 的身份和类型检查器中将文件类型从 Default - PNG Image 更改为 Data。参见下文:

以前:

在此处输入图像描述

现在:

在此处输入图像描述

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.

Change the file type from Default - PNG Image to Data in Identity and Type inspector in XCode. See below:

Was:

enter image description here

Now:

enter image description here

神妖 2024-08-24 14:26:16

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

转到:“Targets”-“YourProject Name”。

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

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

输入图片此处描述

For all you guys using Xcode 6.4 and above:

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.

enter image description here

你曾走过我的故事 2024-08-24 14:26:16
1.Goto your build setting 
2.Search flag Compress PNG files and set it to NO.(default is YES).

在此之后,将避免 PNG 图像的压缩。
只是为了了解更多信息

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文