NSImageView 模糊
我在使用核心动画的视图中有一个 NSImageView 。在使用核心动画之前,图像看起来不错,但现在模糊且质量低下。如果我让 NSImageView 有边框,问题就会消失,但我需要它没有边框。其他人也发生过这种情况吗?
背景中的图像没有边框,前面的图像带有边框。
谢谢
编辑:我忘了提及该图像是一个图标文件(ICNS),因此它有各种大小。有边框的视图加载正确的尺寸,透明的视图加载最小的尺寸并拉伸它。
I have an NSImageView in a view that utilizes Core Animation. Prior to using Core Animation the image looks fine but now its blurry and low quality. If I let NSImageView have a bezel border the issue goes away but I need it to have no border. Had this happened to anyone else?
Imgae in the background with no border, same image in the front with a border.
Thanks
EDIT: I forgot to mention that the image is an icon file (ICNS) so it has various sizes. The bordered view loads the correct size and the transparent one loads the smallest and stretches it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
虽然不是我想要的方式,但我设法解决了这个问题。问题似乎是 NSImageView 绘制图像的方式,因此我创建了一个自定义 NSView 子类,它支持我在原始图像视图中使用的相同绑定。我不确定为什么一开始会发生模糊,但在 NSView 中手动绘制图像似乎可以解决问题。
Although not the way I wanted to, I managed to create a fix for the issue. The issue seemed to be the way that
NSImageView
was drawing the image so I created a custom NSView subclass with support for the same bindings I used in my original image view. Im not sure why the blurry-ness happend in the beginning, but drawing the image by hand in an NSView seems to do the trick.您的图像可能以非像素对齐的方式绘制。您是否尝试过将其移动半个像素?
Apple 在其“Cocoa Tips and Tricks”示例代码的
BlurryView
应用程序中对此进行了很好的演示。Cocoa 提示和技巧
Your image may be drawing in a non-pixel-aligned way. Have you tried shifting it by a half pixel?
Apple has a good demonstration of this in the
BlurryView
app in their "Cocoa Tips and Tricks" sample code.Cocoa Tips and Tricks