Saving image to disk in HiDPI / Retina MacBook
Saving image to disk in HiDPI / Retina MacBook
- Subject: Saving image to disk in HiDPI / Retina MacBook
- From: Nala Gnirut <email@hidden>
- Date: Thu, 02 Aug 2012 12:40:20 +0200
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 (email@hidden)
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:
This email sent to email@hidden