为什么在 iPhone 开发中大量使用 png 图像?
我们在iPhone和iPad上开发是不是都必须使用png图片呢?使用 png 图像时我们会获得什么优势?
Is it true that we have to use png images for development in iPhone and iPad. What is the advantage we would gain when using png images?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
Apple 表示 Xcode 将在构建过程中优化 PNG。
本文准确解释了它的作用,以及为什么 PNG 在 iPhone 上比其他格式更受青睐。换句话说,使用任何其他格式都会损失性能,因为转换必须在运行时完成。
http://iphonedevelopment.blogspot.com/2008/10/iphone-optimized -pngs.html
Apple has said that Xcode will optimize PNGs during the build process.
This article explains exactly what it is doing, and why PNGs are preferred over other formats on the iPhone. In other words, you will lose performance by using any other formats, as the conversion must be done at runtime.
http://iphonedevelopment.blogspot.com/2008/10/iphone-optimized-pngs.html
您不必使用 png。您可以使用 gif、jpeg 等。如果您使用 png,xcode 将为 iOS 加载程序优化它们(更改 png 中某些数据的字节顺序;我对此不太清楚),从而加快加载图像的速度。
You dont have to use png. You can use gif, jpeg, and others. If you use png, xcode will optimize them for the iOS loader (changes the byte-order of some data in the png; I'm not clear on this exactly) resulting in faster loading images.
PNG支持alpha透明度(GIF只支持透明像素,不支持半透明)并且质量很好(不像JPEG)。
它还支持无损压缩。
PNG supports alpha transparency (GIF only support transparent pixels, not semi-transparent) and the quality is good (not like JPEG).
It also supports loseless compression.
这个类似的问题讨论了这个: When to use PNG or JPG in iPhone 开发?
png 是一种无损格式,因此对于设计、按钮等...对于 iphone/ipad,您在 Photoshop(或其他)中看到的内容将与使用压缩的 jpeg 完全一致。
该帖子还表示,由于 png 未压缩,因此显示时使用的处理器较少。
This similar question goes over this: When to use PNG or JPG in iPhone development?
Pngs are a lossless format so for design, buttons, etc... for iphone/ipad what you see in photoshop (or whatever) is going to be exactly what you get as opposed to jpegs which use compressions.
That post also said that pngs use less processor to be displayed since they are uncompressed.
使用 PNG 图像的主要优点是它们非常轻。如您所知,内存管理是 iPhone 和 iPad 开发中的一个非常大的问题,这就是我们使用它们的原因。有关更多详细信息请参阅此处。
The main advantage of using the PNG images is they are very light weight. And as you know memory management is a very big issue in iPhone and iPad development, that's why we use them. For more detailed information see here.