Re: newbie question on creating .png files
Re: newbie question on creating .png files
- Subject: Re: newbie question on creating .png files
- From: David Duncan <email@hidden>
- Date: Thu, 12 Feb 2009 11:08:18 -0800
On Feb 12, 2009, at 8:28 AM, Felix Franz wrote:
You can create a new NSBitmapImageRep using the TIFFRepresentation
and use representationUsingType:properties:
to get the PNG-data:
NSData* TIFFData = [img TIFFRepresentation];
NSBitmapImageRep* bitmapImageRep = [NSBitmapImageRep
imageRepWithData:TIFFData];
NSData* PNGData = [bitmapImageRep
representationUsingType:NSPNGFileType properties:nil];
[PNGData writeToFile: @"JAN01.png" atomically: YES];
While this might be fine for a one-off application where performance
and memory usage doesn't matter, this is really not the best way to
convert an NSImage into a PNG. In fact, imageRepWithData: should work
with any file type that is supported by ImageIO, which natively
includes PNG, so you could pass in the original file data rather than
going through NSImage.
--
David Duncan
Apple DTS Animation and Printing
_______________________________________________
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