• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Image export/import question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Image export/import question


  • Subject: Re: Image export/import question
  • From: "M. Uli Kusterer" <email@hidden>
  • Date: Sun, 3 Oct 2004 15:19:45 +0200

At 8:29 Uhr -0400 03.10.2004, Sherm Pendley wrote:
Example code is always welcome.

I don't have any at hand, but in a nutshell it's pretty easy. Then add one or more file wrappers - which are NSFileWrapper instances - to an NSDictionary. Then use that dictionary to create a dictionary wrapper, which is also an NSFileWrapper instance.

Finally, use the directory wrapper's -writeToFile:atomically:updateFilenames: method to write the whole mess to disk.

Sherm,

I've never used NSFileWrapper, but something here sounds off. I think what he wants to do should actually be:

Create an NSFileWrapper for a directory. This will be your "file package", i.e. what your users see as a document. Add an NSFileWrapper for each image file to it (NSImage's -TIFFRepresentation is your friend). Then create NSData from your NSDictionary (use NSPropertyListSerialization for that), and add a file for that as well.

Return the directory's file wrapper from fileWrapperRepresentationOfType: in your NSDocument subclass and everything should be fine. loadFileWrapperRepresentation works analogously, you get an NSFileWrapper like the one you saved and can extract the data from it again.

Or, alternatively, he can put the images in his dictionary and just save the dictionary to a file, foregoing the use of NSFileWrapper.

But Peter, if you save a dictionary to a file, all objects in it need to be "property list types", which are NSString, NSNumber, NSValue, NSArray, NSDictionary or NSData. Since your images are NSImage, you'll have to turn your NSImage into NSData as described above. And of course, when reading your file, you'll have to replace the NSDatas in there with NSImages again.

The difference between the two approaches is that users can click an NSFileWrapper package in the Finder and right-click it to "show package contents", and then they'll be able to view the TIFF files in there. OTOH the dictionary approach only gets you a huge XML file, where the images are encoded in hexadecimal or something like that, and will thus take more disk space.
--
Cheers,
M. Uli Kusterer
------------------------------------------------------------
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de
_______________________________________________
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
  • Follow-Ups:
    • Re: Image export/import question
      • From: Sherm Pendley <email@hidden>
References: 
 >RE: RE: Re: Image export/import question (From: "Peter Karlsson" <email@hidden>)
 >Re: Image export/import question (From: Sherm Pendley <email@hidden>)

  • Prev by Date: Re: Any news about Cocoa Java ?
  • Next by Date: Re: Cocoa-dev Digest, Vol 1, Issue 104
  • Previous by thread: Re: Image export/import question
  • Next by thread: Re: Image export/import question
  • Index(es):
    • Date
    • Thread