NSButton和NSImageView中的图像模糊 [英] Images in NSButton and NSImageView Blurred
问题描述
我完全被困在这里;我正在修补一系列小图像并制作成按钮:
I am completely stumped here; I have a series of small images I'm tinkering with and making into buttons:
正如您所见,它们都非常脆且锋利,当我在预览"中打开png文件时保留了这些,而没有.
And as you can see they are all decently crisp and sharp, and retain this when I open the png files in Preview and what not.
但是,当我在Interface Builder的NSButtons
和NSImageViews
中使用它们时,将Scaling设置为None:
However, when I use them in NSButtons
and NSImageViews
in Interface Builder, setting Scaling to None:
图像变得非常模糊.我究竟做错了什么?我不知道从哪里开始,应该尝试什么.我应该回到图标上并尝试使其像素完美吗?它与抗锯齿或与此类似的事物有关吗?
The images become horribly blurred. What am I doing wrong? I don't know where to start and what to try; should I go back to the icons and try to make them pixel perfect? Does it have to do with anti-aliasing or something along those lines?
由于某种原因,即使我处于正常显示状态,似乎NSButtons和NSImageViews都在加载图像的高分辨率版本,这可以通过我添加到它们的浅蓝色笔划来识别.由于某些原因,Quartz Debug不会将这些图像识别为高分辨率图像,也没有红色.删除对@ 2x图像的引用确实可以解决问题...但是...
For some reason, it seems as if the NSButtons and NSImageViews are loading the high resolution versions of the images, even though I'm on a normal display, which can be identified by a slight light blue stroke I added to them. For some reason, Quartz Debug does not identify these as high resolution images and there's no red tint. Removing references to the @2x images does fix the problem... but...
推荐答案
如果您在NSImage
的第一部分的WWDC 2012
视频Advanced Tips and Tricks for High Resolution on OS X
中检出了会话245,则会发现原因.
If you check out session 245 in the WWDC 2012
videos Advanced Tips and Tricks for High Resolution on OS X
in the first section on NSImage
you'll find out why.
NSImage
没有高分辨率的概念-它仅使用最小像素大于其必须填充空间的图像-因此,如果NSImageView
尺寸大于1x图像,它将请使用2x图像,因为它有更多像素.
NSImage
doesn't have any concept of high resolution - it just uses the smallest image that has more pixels than the space it has to fill - so if your NSImageView
is bigger in dimension than your 1x image it will use the 2x image as it has more pixels.
这篇关于NSButton和NSImageView中的图像模糊的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!