Re: PNGs
Re: PNGs
- Subject: Re: PNGs
- From: Troy Stephens <email@hidden>
- Date: Fri, 16 Sep 2005 10:48:16 -0700
On Sep 16, 2005, at 10:19 AM, Rick Langschultz wrote:
I was wondering if there are any resources for composing PNG images
in Cocoa.
Yes. Cocoa provides for writing bitmapped images to several standard
file types, including PNG.
You can draw your desired content to an NSImage using any of Cocoa's
drawing APIs, then create an NSBitmapImageRep from the NSImage using
NSBitmapImageRep's -initWithFocusedViewRect: initializer, and finally
write the resultant NSBitmapImageRep as a PNG file like so:
NSData *pngData = [bitmapImageRep
representationUsingType:NSPNGFileType properties:nil];
[pngData writeToFile:@"/tmp/test.png" atomically:YES];
The "Reducer" code sample from WWDC 2005 provides one example of
doing this kind of image processing and saving:
http://developer.apple.com/samplecode/Reducer/Reducer.html
See in particular the -saveButtonClicked: method in MainController.m,
and the BitmapImageRepFromNSImage() function at the bottom of
ImageReducer.m.
--
Troy Stephens
Cocoa Frameworks
Apple Computer, Inc.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
References: | |
| >PNGs (From: Rick Langschultz <email@hidden>) |