NSImage imageNamed: for Mac Mini returns a small icon instead of high resolution

When using the method NSImage imageNamed:to get the icon for the current computer, if I work on a Mac Mini, I get a low-resolution image. If I run the same code from my MacBook, I get the high-resolution icon as I expected.

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 this on my MacBook everything works fine and I get the 512x512 icon on my computer. When I run it on my Mac Mini, I get a 32x32 icon that has been enlarged to 512x512.

Any ideas on how I can get the high resolution version?

+3
source share
1

, /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/

Mac mini com.apple.macmini.icns. , 512x512 ( , Snow Leopard).

-representations NSLog, , 512x512.

:

10.6 AppKit NSImage CGImage.

Snow Leopard , CGImageRef:

NSImage* image = [NSImage imageNamed:NSImageNameComputer];
NSRect imageRect = NSMakeRect(0, 0, 512, 512);
CGImageRef cgImage = [image CGImageForProposedRect:&imageRect context:nil hints:nil];

NSImage CGImageRef API CGImageDestination * png.

+3

Source: https://habr.com/ru/post/1721151/


All Articles