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

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


  • Follow-Ups:
    • Re: NSImage/NSImageView/GIF Saving an Animated GIF from NSImageView
      • From: Michael Robinson <email@hidden>
  • Prev by Date: Re: Testing apps on 10.*
  • Next by Date: How to tell if app launched via login item (versus manual launch)
  • Previous by thread: Re: Programatically Triggering an NSSearchField Search
  • Next by thread: Re: NSImage/NSImageView/GIF Saving an Animated GIF from NSImageView
  • Index(es):
    • Date
    • Thread