Day: 31st March 2018


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.

Apple Wtf

Did Apple smoke weed?

They finally released their space grey Magic Mouse 2 as well as their Magic Keyboard 2 and they charge 20 EUR for the keyboard and 30 EUR for the mouse extra just for the color?

What will come next, an ugly MacBook with optional design to not suck?

Software Engineering

PHP proper string to boolean casts

Casting a string to a boolean can be tricky but it’s actually super easy. First of all never use boolval or casts like (bool) $string. It will never work or won’t result in what you believe it will. There are good reasons why it’s like that and I’m aware that other languages cope that with ease.

Just use filter_var which can properly convert strings into booleans. filter_var can do a lot more, but for booleans I use it all the time. Also check out if your framework provides something cool, some does, some doesn’t.

Just a common mistake I’ve often seen. Cheers and have fun coding!

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.