• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Saving image to disk in HiDPI / Retina MacBook
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Prev by Date: Re: reading preferences from com.apple.mail under 10.8
  • Next by Date: Re: 32-bit on 10.8
  • Previous by thread: Re: containerURLForSecurityApplicationGroupIdentifier
  • Next by thread: PocketSVG
  • Index(es):
    • Date
    • Thread