Hi all,
in one of my apps I'm saving some images like this:

***
NSImage *finalIcon = [[NSImage alloc] initWithSize:finalSize];

[finalIcon lockFocus];

// Some drawing on finalIcon here

NSBitmapImageRep *imgRep = [[NSBitmapImageRep alloc]
initWithFocusedViewRect:NSMakeRect(0, 0, finalSize.width,
finalSize.height)];
[finalIcon unlockFocus];

NSData *data = [imgRep representationUsingType:NSPNGFileType
properties:nil];
[data writeToFile:path atomically:NO];
***


On a Retina MacBook this code is creating an image with double size (that
is imgRep.pixelsWide and imgRep.pixelsHigh are 2x finalSize.width and
finalSize.height)

What's the right approach to preserve original image size?

I need 1x image (or at least an image with doubled dpi but same pixel size
of the original one), as it's exported for the web and used on non-Retina
devices.

Thanks in advance.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to