Iphone 上的所有 .png 文件都应该是 2 的幂吗?
当从 .png 创建 UIImage 文件以显示在标准 Iphone 应用程序的按钮、视图/单元格背景等上时,出于优化原因,所有这些文件都应该是 2 的幂吗?
When creating an UIImage file from a .png to be displayed on a button, view/cell background, etc. for a standard Iphone application, should all of them be in powers of 2 for optimization reasons?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
正如其他人所说,不,但您通常应该使用尺寸均匀的图像。这是因为当使用
center
属性定位视图时,它会将奇数尺寸的图像定位在某个半像素位置。这将导致图像显得模糊。只要您意识到这一点,它就不会给您带来任何问题,但为了安全起见,使用均匀尺寸仍然是一个好主意。
(这适用于 UIKit,不一定适用于 OpenGL)
As others have said, no - but you should generally use images with even dimensions. This is because when views are positioned with the
center
property, it'll position an odd-dimensioned image at some half-pixel position. This will cause the image to appear blurry.As long as you're aware of this it shouldn't really cause you any problems, but it's still a good idea to use even sizes just to be on the safe side.
(This applies for UIKit, not necessarily OpenGL)
Apple 对代表您添加到界面的所有图像(例如系统工具栏项目)使用奇数和任意尺寸。您可以做的最好的优化是减少合成的任何事情,这基本上意味着尽可能设置视图和图层的不透明属性。
如果您可以选择在静态背景上合成的透明 png 和已包含背景的不透明 png,则您有机会进行优化。当图像左右滑动或背景发生变化时,必须进行合成,否则选择不透明。
Apple uses odd and arbitrary dimensions for all the images it adds to the interface on your behalf, such as system toolbar items. The best optimization you can do is anything that reduces compositing, which basically means setting the opaque property of views and layers whenever possible.
If you have the choice between a transparent png that will be composited over a static background and an opaque png with the background already included, you have a chance to optimize. When the images will be sliding around or the background will change, you have to composite, otherwise choose opaque.
这是一篇关于 iPhone 图像优化的文章——基本上告诉您为什么使用 PNG 文件。除非您使用 OpenGLES,否则大小并不重要。
Here is an article on optimization of iPhone images -- basically tells you why to use PNG files. The size shouldn't matter unless you are using OpenGLES.
不,这几乎没有任何好处,我通常足以使用 Photoshop 的“保存为网络或设备”选项进行自己的优化。
请参阅 http://iphonedevelopment.blogspot.com/2008/10/ iphone-optimized-pngs.html 有关 iPhone 预优化 png 的详细说明。
No, this will have little or no benefit, I usually suffice at doing my own optimization using photoshop "Save for web or devices" option.
Please see http://iphonedevelopment.blogspot.com/2008/10/iphone-optimized-pngs.html for a detailed explanation about the iPhones pre-optimization of pngs.