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 (Cocoa-dev@lists.apple.com)

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to