NSImage/NSImageView/GIF Saving an Animated GIF from NSImageView
NSImage/NSImageView/GIF Saving an Animated GIF from NSImageView
- Subject: NSImage/NSImageView/GIF Saving an Animated GIF from NSImageView
- From: Michael Robinson <email@hidden>
- Date: Wed, 26 Nov 2008 18:29:54 +1300
Hi list,
I'd like to be able to use an NSImageView to display a default animated
GIF image. The image may be replaced by the user.
I have been using the code below to save / load images from / into the
image view. I would like to know how, if it is possible, one saves an
animated gif, preserving the animation.
Also, the animation is lost when the program saves then reloads the
image - is it possible to save (using aCoder) with animation preserved?
Thanks!
To save image to file:
if([lbLoading image] != nil){
NSData * tiffData = [[lbLoading image]
TIFFRepresentation];
NSBitmapImageRep *bits = [NSBitmapImageRep
imageRepWithData:tiffData]; // get a rep from your image, or grab from a
view
NSData *data;
[bits is]
NSString *fullPath = [NSString
stringWithFormat:@"%@/%@%@.gif",path,@"loading",[self uniqueID]];
data = [bits representationUsingType: NSGIFFileType
properties: nil];
[data writeToFile: fullPath atomically: NO];
[files addObject:fullPath];
}
When the program saves its data:
[aCoder encodeObject:[lbLoading image] forKey:@"lbLoading"];
And at load:
[lbLoading setImage:[aDecoder decodeObjectForKey:@"lbLoading"]];
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden