If I create NSImage through something like:
NSImage *icon = [NSImage imageNamed:NSImageNameUser];
it has only one view, a NSCoreUIImageRep , which seems private.
I would like to archive this image as NSData , but if I ask for TIFFRepresentation , I will get a small icon when the real NSImage that I originally created was apparently a vector and scaled to fit my images well.
I kind of hoped that images made this way would have an NSPDFImageRep that I could use.
Any ideas how I can get the NSData (vector version prefix or, in the worst case, large-scale version of the bitmap) of this NSImage ?
UPDATE
We talked with some people on Twitter , and they suggested that the real source of these images are icns files with several resolutions (probably not a vector), I could not find their location on the disk, but it’s interesting to hear no less.
In addition, they proposed creating an NSImage system and manually turning it into a high level NSImage. I am doing it now and it works for my needs. My code is:
+ (NSImage *)pt_businessDefaultIcon { // Draws NSImageNameUser into a rendered bitmap. // We do this because trying to create an NSData from // [NSImage imageNamed:NSImageNameUser] directly results in a 32x32 image. NSImage *icon = [NSImage imageNamed:NSImageNameUser]; NSImage *renderedIcon = [[NSImage alloc] initWithSize:CGSizeMake(PTAdditionsBusinessDefaultIconSize, PTAdditionsBusinessDefaultIconSize)]; [renderedIcon lockFocus]; NSRect inRect = NSMakeRect(0, 0, PTAdditionsBusinessDefaultIconSize, PTAdditionsBusinessDefaultIconSize); NSRect fromRect = NSMakeRect(0, 0, icon.size.width, icon.size.width);; [icon drawInRect:inRect fromRect:fromRect operation:NSCompositeCopy fraction:1.0]; [renderedIcon unlockFocus]; return renderedIcon; }
(tried to post this as my answer, but I don't have enough reputation?)