• 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 PNG files from NSImage
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Saving PNG files from NSImage


  • Subject: Saving PNG files from NSImage
  • From: Martin Linklater <email@hidden>
  • Date: Mon, 29 Aug 2011 13:18:41 +0100

Hi - I'm writing a texture atlasser and so far I have created an NSImage and composited by sub-images onto it using:

-[NSImage drawAtPoint:fromRect:operation:fraction]

Now as I understand it the way to save the resulting NSImage to a PNG file is to get the images 'representations' and and save one of them to a file. Trouble is, my resulting NSImage only has one representation which is of type

NSCGImageSnapshotRep

This type seems to private for some reason and pretty much undocumented. Whenever I try to save this to PNG using various pieces of sample code I get runtime errors like this

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCGImageSnapshotRep representationUsingType:properties:]: unrecognized selector sent to instance 0x103107d30'

Can anyone point me in the right direction as to how to save my NSImage to a PNG file ? Or some documentation which actually describes how to convert the NSCGImageSnapshotRep into something I can save out ? I've spent a few hours on this now and I can't believe there isn't an easy solution I'm missing.

Thanks.


_______________________________________________

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

  • Follow-Ups:
    • Re: Saving PNG files from NSImage
      • From: Marco Tabini <email@hidden>
    • Re: Saving PNG files from NSImage
      • From: Andy Lee <email@hidden>
  • Prev by Date: Blocked in NSFileCoordinator
  • Next by Date: Re: Saving PNG files from NSImage
  • Previous by thread: Re: Blocked in NSFileCoordinator
  • Next by thread: Re: Saving PNG files from NSImage
  • Index(es):
    • Date
    • Thread