When using NSImage
's imageNamed:
method to get the icon for the current computer, if I'm running on a Mac Mini, then I get a low resolution image. If I run the same code from my MacBook, then I get a high-res icon like I'd expect.
My code is as follows:
NSImage *image;
image = [NSImage imageNamed:@"NSComputer"];
[image setSize: NSMakeSize(512,512)];
NSData * tiffData = [image TIFFRepresentation];
NSBitmapImageRep *bitmap = [NSBitmapImageRep imageRepWithData:tiffData];
data = [bitmap representationUsingType:NSPNGFileType properties:nil];
mime = @"image/png";
When I run that on my MacBook, everything works great and I get a 512x512 icon of the my computer. When I run it on my Mac Mini, i get a 32x32 icon that's been upscaled to 512x512.
Any ideas on how I can get the high-res version?
I believe that image comes from
/System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/
The Mac mini icon is named
com.apple.macmini.icns
. You may want to check if that file contains a 512x512 icon on your machine (it does on mine, running Snow Leopard)'For debugging purposes, you should also send the output of
-representations
toNSLog
to verify that the icon does or does not have a 512x512 version.Edit:
The 10.6 AppKit Release Notes has quite a bit on the updated relationship between NSImage and CGImage.
On Snow Leopard, you can get the full resolution image by converting to a CGImageRef:
From there, you can create a new NSImage from the CGImageRef, or use the CGImageDestination* APIs to write a png file.