In my cocoa app, how can I load/scale my .icns file? In this case, I want to load up my 16x16 image.
2 Answers
Load it as an NSImage
(+imageNamed:
), grab one of its NSImageRep
s (-representations
), then call setSize:NSMakeSize(16,16)
on it.
With 'file' being a NSString with the icns file path, use this to load the image:
NSImage* img = [[NSImage alloc] initWithContentsOfFile:file]
Then, the NSImage 'img' will contain the icns image. To resize it to 16x16, use this:
[img setSize: NSMakeSize(16,16)];