Re: Saving PNG files from NSImage

2011-08-29 Thread Marco Tabini
Hi Martin— On 2011-08-29, at 8:18 AM, Martin Linklater wrote: > 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 hou

Re: Saving PNG files from NSImage

2011-08-29 Thread Martin Linklater
Thanks for the info guys. The method below is working great. On 29 Aug 2011, at 14:38, Marco Tabini wrote: > Hi Martin— > > On 2011-08-29, at 9:11 AM, Martin Linklater wrote: > >> Thanks Marco. When I call representationUsingType I get this: >> > > You need to first convert the representatio

Re: Saving PNG files from NSImage

2011-08-29 Thread Mike Abdullah
This code is making the assumption that [reps objectAtIndex:0] is a bitmap image rep. NSImage makes no such guarantees. Points: - Walk through all the image reps, looking for the best bitmap - If no bitmap exists, you'll have to create one by drawing the image into a bitmap context - If you're w

Re: Saving PNG files from NSImage

2011-08-29 Thread Andy Lee
I don't know if this would be the most efficient way, but if you can get your image as a CGImageRef you can use the functions below. They work for me. You might want to handle errors better. There are tips at for getting a CGImageRef.

Re: Saving PNG files from NSImage

2011-08-29 Thread Martin Linklater
Thanks Marco. When I call representationUsingType I get this: -[NSCGImageSnapshotRep representationUsingType:properties:]: unrecognized selector sent to instance 0x100220610 2011-08-29 14:08:16.161 TexLifter[69386:407] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', r

Saving PNG files from NSImage

2011-08-29 Thread Martin Linklater
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