views:

155

answers:

2

Following situation:

I have an instance of my NSObject sublcassed object. One of it's properties is a NSImage. After instanciating the object I convert it with NSKeyedArchiver to data, send it over the network, unarchive it with NSKeyedUnarchiver and display the image in a NSImageView (setAnimates: YES). Until here there are no problems. The image can be displayed on the other machine. Now the problem:
If I send an animated gif, it won't animate. I don't know why... Any ideas why the animation stays away? Thank you!

UPDATE

If I open the animated image before archiving it the NSImageView animates it. The problem is maybe the archiving...

UPDATE 2

I tested the whole workflow without sending the data over the network, just archiving and unarchiving it again. As I suspected it is a problem with NSKeyed(Un)Archiver.
The animation gets lost. But what to do to prevent this?

A: 

By default, NSImage doesn't retain the original source image data. What's probably happening is that NSImage is archiving the static bitmap of one frame only and discarding the original content.

If you call [yourNSImageObject setDataRetained:YES] then the NSImage should hang on to the original data (in this case, the animated GIF). I'd suggest you try doing this when the image is first created, and then see what happens when it's archived/unarchived.

Rob Keniger
1) setDataRetained: is deprecated in Mac OS X v10.6.2) Unfortunately it does not work. :-/ (Animation is still getting lost...)
papr
+1  A: 

I would simply archive the original image data, instead of the image instance.

Peter Hosey