|UIImage *shacho = [UIImage imageNamed:@"shacho.png"];|
|UIImage *bucho = [UIImage imageNamed:@"bucho.jpeg"];|
|NSString *path = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"animated.gif"];|
|CGImageDestinationRef destination = CGImageDestinationCreateWithURL((CFURLRef)[NSURL fileURLWithPath:path],|
|NSDictionary *frameProperties = [NSDictionary dictionaryWithObject:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:2] forKey:(NSString *)kCGImagePropertyGIFDelayTime]|
|NSDictionary *gifProperties = [NSDictionary dictionaryWithObject:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:0] forKey:(NSString *)kCGImagePropertyGIFLoopCount]|
|CGImageDestinationAddImage(destination, shacho.CGImage, (CFDictionaryRef)frameProperties);|
|CGImageDestinationAddImage(destination, bucho.CGImage, (CFDictionaryRef)frameProperties);|
|NSLog(@"animated GIF file created at %@", path);|
No, it doesn't. I've not tested on device yet. I am using this code to create a titanium module. When I've compiled this code through the xcode 4.3 it showed "Build Succedded", but when I commented the code from "CGImageDestinationRef destination = CGImageDestinationCreateWithURL..." not only showed that message, but also ran the simulator. I've noticed that my module worked when I've commented that code too.
Oh I see. I'm not familiar with the Titanium and its plugins so I can't say this code is valid for a Titanium module. I think it's fine though...
I'm a little bit confused with your situation, so let me clear things:
Are they true or not? Also, give me any kind of error messages you got.
As you can see you have to link ImageIO.framework and MobileCoreServices.framework (both of them are provided by iOS runtime) when build, but nothing else.
@akisute I know this is a pretty old post but when I save images like this they playback super duper slow. I have tried to use
but the frames still play very very slow. Any thoughts?
made an adaptation for swift 2 and NSImage: https://gist.github.com/ScottBuchanan/c63129cc2c5bb824fbac21c2d389ed22
I have a problem with this piece of code, when I use this snippet to generate one gif with two static image, it works fine. But when I use ffmpeg to transform this gif to mp4, this mp4 file has a problem that one image is at beginning position and another is at the end. So when I loop this video, it acts strange.