Apple

Scale NSImage up into NSImageView

Interpolated image

Imagine having a 10*10 NSImage you want to scale up in an NSImageView to like 100*100. The result will look pretty blurred. That’s caused by the image interpolation of NSImageView which is interpolating the image.

This might be fine for most things like photos, when scaling them down or up. But my situation were different, I wanted to zoom into it to visualise the pixels.

It took me many hours to find out that most proposed solutions like setting the magnificationFilter to kCAFilterNearest on the NSImageView’s layer are just not working. Maybe they do, somehow, I couldn’t make them work. If someone knows how, I would be glad to learn.

Not interpolated image

So back to the topic, once I figured out that interpolation was done by the NSImageView I simply implemented my own NSImageView and disabled the image interpolation on it’s current NSGraphicsContext.

For me it’s just fine, because I planed anyway to extend NSImageView for my needs. I hope this will save someone some time.

Leave a Reply

Your email address will not be published. Required fields are marked *

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close