Saving PNG files from NSImage
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