Saving raw NSImage data to files
Saving raw NSImage data to files
- Subject: Saving raw NSImage data to files
- From: Nicko van Someren <email@hidden>
- Date: Sat, 27 Dec 2003 20:17:07 +0000
The application I'm writing can embed images in a document. When the
user brings in an image from a file (using the Open panel) I can use
-initWithContentsOfFile: and if the user drags something in, which
might be a file or one of the other plethora of clipping formats from
elsewhere, I just hand it over to the -initWithPasteboard: method of
NSImage. The problem comes when I want to save the document. What I'd
really like is some way to save out the data that was used to create
the image, not some TIFF representation of it.
If I got the data from a file I can just take a copy of the file but if
I got the data from a pastebaord it seems very tedious. Is there some
straight forward way to retrieve the data on which NSImage based
itself?
The best I've come up with so far is to look at the result of the
-representations message before anything has been draw and then, based
on the type of the first object in the array I have to call a different
method in each to get the representation data. This is broken in two
ways. Firstly because it seems like bad class design; surely
NSImageRep should have a method that returns the raw representation,
rather than having to call -EPSRepresentation, -PICTRepresentation, or
-PDFRepresentation depending on the class, and some method I've never
heard of if Apple end up supporting a new type I don't yet know.
Secondly if the data came from something like a JPEG image I can't get
back the raw form, I can only get the TIFF re-compressed.
So, can anyone out there tell me the right way to get the original data
back out on an NSImage?
Nicko
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.