• 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
CGImageDestinationSetProperties does not work for animated GIF
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

CGImageDestinationSetProperties does not work for animated GIF


  • Subject: CGImageDestinationSetProperties does not work for animated GIF
  • From: Patrick Haruksteiner <email@hidden>
  • Date: Sun, 23 Nov 2008 21:24:02 +0100

Hello,

I'm exporting an animted GIF and want to set properties like the loop count or if a global colormap is used. It seems that I have a problem with CGImageDestinationSetProperties. Setting the frame related properties like the delay time for the frames works fine, but the image related properties like loop count or global colormap seem not to be written to the file. (see my code below)
Anybody an idea?


Cheers,
Patrick


NSMutableDictionary *gifFrameProperties = [[NSMutableDictionary dictionaryWithCapacity:1] retain]; //fp0
NSMutableDictionary *gifImageProperties = [[NSMutableDictionary dictionaryWithCapacity:6] retain]; //ip0 to ip5
//image resolution
[gifImageProperties setObject:[NSNumber numberWithFloat:resolution] forKey:(NSString *) kCGImagePropertyDPIWidth]; //ip0
[gifImageProperties setObject:[NSNumber numberWithFloat:resolution] forKey:(NSString *) kCGImagePropertyDPIHeight]; //ip1
//color model
[gifImageProperties setObject:(NSString *) kCGImagePropertyColorModelRGB forKey:(NSString *) kCGImagePropertyColorModel]; //ip2
//use global colormap
[gifImageProperties setObject:[NSNumber numberWithBool:globalColormap] forKey:(NSString *) kCGImagePropertyGIFHasGlobalColorMap]; //ip3
if(loop){ //fp4
[gifImageProperties setObject:[NSNumber numberWithFloat:loopCount] forKey:(NSString *) kCGImagePropertyGIFLoopCount]; //loop animation, 0 = indefinitly
}
NSDictionary *finalGIFImageProperties = [NSDictionary dictionaryWithObject:gifImageProperties forKey:(NSString *) kCGImagePropertyGIFDictionary];


//delay between frames
[gifFrameProperties setObject:[NSNumber numberWithFloat:spf] forKey:(NSString *)kCGImagePropertyGIFDelayTime]; //fp0
NSDictionary *finalGIFFrameProperties = [NSDictionary dictionaryWithObject:gifFrameProperties forKey:(NSString *) kCGImagePropertyGIFDictionary];


//we have to know the image count before we add the images in the loop
imageCount = totalDuration / spf;
imageDestination = CGImageDestinationCreateWithURL((CFURLRef) filePathURL, kUTTypeGIF, imageCount, NULL);


int imagesWritten = 0;
//t loop runs can be 1 image off due to int cast in imageCount calculation -> doublecheck condition
for(t = 0.0; imagesWritten < imageCount && t <= totalDuration; t += spf){
imageRef = [self createImageForTimeStamp:t];
CGImageDestinationAddImage(imageDestination, imageRef, (CFDictionaryRef)finalGIFFrameProperties); //setting frame related properties workes fine here
imagesWritten++;
}


//seems this does not work...
CGImageDestinationSetProperties(imageDestination, (CFDictionaryRef)finalGIFImageProperties);


CGImageDestinationFinalize(imageDestination) //writing the image works fine too - only the properties are missing...


_______________________________________________

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: CGImageDestinationSetProperties does not work for animated GIF
      • From: Rob Keniger <email@hidden>
  • Prev by Date: Re: NSXMLElement -stringValue and whitepsace
  • Next by Date: is core data for me?
  • Previous by thread: Where are the Companion Guides?
  • Next by thread: Re: CGImageDestinationSetProperties does not work for animated GIF
  • Index(es):
    • Date
    • Thread