Theocacao
Leopard
Design Element
Comment on "Proportional Scaling with NSImage"
by Blain — Sep 30
I was about to say, you could probably make things even faster by abstracting out the nsimage, and making a C-style function

NSRect scaleSizeProportionallyInRect(NSSize origionalSize, NSRect destinationRect);

In which case it'd also offset using destinationRect.origin

Given that the next step after -imageByScaling... would most likely be to draw this new image in another context, you'd save an entire drawing round by moving the images in directly. In the case of sending values as a DataSource, you could just use a makeSize, and let the table do the centering work.

Seperating out the NSSize/NSRect code also has the added utility in case you want to center&scale or otherwise fit in text or resize controls.

Still, very useful.
Back to "Proportional Scaling with NSImage"
Design Element

Copyright © Scott Stevenson 2004-2015