Re: Saving an image to disk
Re: Saving an image to disk
- Subject: Re: Saving an image to disk
- From: Scott Anguish <email@hidden>
- Date: Mon, 19 Dec 2005 16:03:19 -0500
On Dec 19, 2005, at 3:51 PM, Eamon Ford wrote:
This is sort of a newbie question, but how do I save an NSImage as
a regular tiff image to the disk? I'm using this code to initialize
the image (and "rep" is an NSBitmapImageRep):
NSData * tiffImage = [rep TIFFRepresentation];
NSImage * screenshot = [[NSImage alloc] initWithData:tiffImage];
But I don't even know if this is the best way to do it.
It is a newbie question, but I'm not sure the doc covers it well
conceptually.
You can get the TIFF data for an image by asking for
TIFFRepresentation from an NSImage (as you are), and then
writeToFile:atomically: the NSData instance.
You could add a category to NSImage that implements a
writeTIFFToFile:atomically: that encapsulates this behavior..
If you need a different representation than TIFF, then you'll need
to look at NSBitmapImageRep's representationUsingType:properties:
method.
_______________________________________________
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