• 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: NSImage/NSImageView/GIF Saving an Animated GIF from NSImageView
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


References: 
 >NSImage/NSImageView/GIF Saving an Animated GIF from NSImageView (From: Michael Robinson <email@hidden>)

  • Prev by Date: Re: Using NSAnimation
  • Next by Date: Re: Code signing and verification
  • Previous by thread: NSImage/NSImageView/GIF Saving an Animated GIF from NSImageView
  • Next by thread: How to tell if app launched via login item (versus manual launch)
  • Index(es):
    • Date
    • Thread