Re: NSImage/NSImageView/GIF Saving an Animated GIF from NSImageView
Re: NSImage/NSImageView/GIF Saving an Animated GIF from NSImageView
- Subject: Re: NSImage/NSImageView/GIF Saving an Animated GIF from NSImageView
- From: Michael Robinson <email@hidden>
- Date: Thu, 27 Nov 2008 09:19:05 +1300
I was wondering if anyone had any ideas on how to do this?
Thanks
Michael Robinson wrote:
<div class="moz-text-flowed" style="font-family: -moz-fixed">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"]];
</div>
_______________________________________________
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