0
votes

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?

Blurry image

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.

2
Are both of the views in the screenshot using Core Animation? - Peter Hosey
There both contained in the same view that uses Core Animation, The hierarchy is Content View (Window) -> My View (The one that uses Core Animation) and the NSImageView(s) - nosedive25
Are you giving both image views the same image object? What's the size of that image object? What are the frames of the image views? - Peter Hosey
The image is the same, set by CoreData in both. The frame of the blurry one is 211,281,195,195 (x,y,w,h) and the frame of the clear one is 345,214,29,198. The images size is 512Xx512. - nosedive25
29 points wide? Are you sure? Also, I know they're the same image, but are both image views getting the same NSImage object? - Peter Hosey

2 Answers

1
votes

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.

0
votes

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