Theocacao
Leopard
Design Element
Comment on "Proportional Scaling with NSImage"
by Blain — Oct 01
Oh! If you're releasing the original, nevermind. I meant speeding up drawing when the larger one might be needed as well.

If you add a NSBitmapImageRep of 500x500, and another at 64x64, will NSImage be smart enough to use the 64x64 version (the bitmap rep, not the cache rep) if you draw at that size?

Perfect timing for this question. Historian is using the carbon IconRefs for grabbing file icons (to allow for Finder-style hilighting and badges), and the code I used (I think it's from Uli, but I'll have to double-check) makes a single NSImage with an ImageRep for each size of icon that the IconRef has. I think that -iconForFileType: does the same. Point being that the 16*16 icon is visually different than a scaled down 128*128, so when I played around with image sizes, I could tell the difference.

If I recall, Cocoa does the Right Thing in handling, finding the closest match that's larger, then the closest match that's smaller. I'll have to double-check that. Point being, if you do have to deal with constantly scaling images, a large thumbnail will still be a significant speedup.
Back to "Proportional Scaling with NSImage"
Design Element

Copyright © Scott Stevenson 2004-2015