In Cocoa application I've got 16x16 and 32x32 @2x
version of an image: . When the image is displayed in NSImageView Mac OS X always picks higher-resolution version (i.e. downscales the @2x
image on non-retina displays instead of using the 1:1 version).
(IB on the left = good, running app on the right = downscaled mess)
当然,我已将两个图像添加到项目中(如image.png
and [email protected] /cdn-cgi/l/email-protection
).
如果我删除@2x
来自应用程序包的图像,然后 OS X 将显示较低分辨率的图像。
无论 Xcode (4.6.2) 是否将它们组合成 .tiff ,该错误都会发生(并且我已经检查组合后的 .tiff 是否包含这两个图像)。
奇怪的是,这种情况只发生在这张特定的图像上。同一项目中的其他 1x/2x 图像可以正确显示,以匹配屏幕 DPI。
这怎么可能?!除了大小和文件名模式之外,图像是否还必须满足一些特殊标准?
谜团已解:OS X 不喜欢混合类型的 PNG。
$ file *.png
image.png: PNG image data, 16 x 16, 8-bit gray+alpha, non-interlaced
[email protected] /cdn-cgi/l/email-protection: PNG image data, 32 x 32, 8-bit colormap, non-interlaced
如果两个文件都被迫使用相同的颜色模式(即均为灰色或均为调色板),则 OS X 会正确选择图像。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)