有多少图片在ios中制作GIF图片的阵列

问题描述:

我还在制作60张图片数组到GIF图片大小为320 * 320。通常情况下,我在github上使用了第三方库NSGIF,但在使用80张图像进行GIF图像处理时仍然出现应用程序内存警告和崩溃。有多少图片在ios中制作GIF图片的阵列

NSDictionary *fileProperties = @{(__bridge id)kCGImagePropertyGIFDictionary: @{ 
             (__bridge id)kCGImagePropertyGIFLoopCount: @0, // 0 means loop forever 
             } 
           }; 

NSDictionary *frameProperties = @{(__bridge id)kCGImagePropertyGIFDictionary: @{ 
              //(__bridge id)kCGImagePropertyGIFDelayTime: @0.02f, // a float (not double!) in seconds, rounded to centiseconds in the GIF data 
              (__bridge id)kCGImagePropertyGIFDelayTime: @0.06f, 
              } 
            }; 

NSURL *documentsDirectoryURL = [[NSFileManager defaultManager] URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:nil]; 
NSString *savePath = [documentsDirectoryURL URLByAppendingPathComponent:@"animated.gif"]; 

CGImageDestinationRef destination = CGImageDestinationCreateWithURL((__bridge CFURLRef)savePath, kUTTypeGIF, FrameArr.count, NULL); 
CGImageDestinationSetProperties(destination, (__bridge CFDictionaryRef)fileProperties); 

for (NSUInteger i = 0; i < ImageArray.count; i++) { 
    @autoreleasepool { 
     UIImage *CaptureImage = [ImageArray objectAtIndex:i]; 

     CGImageDestinationAddImage(destination, CaptureImage.CGImage, (__bridge CFDictionaryRef)frameProperties); 
    } 
} 
if (!CGImageDestinationFinalize(destination)) { 
} 
else 
{ 
    //[shareBtn setHidden:NO]; 
} 
CFRelease(destination); 

我想打80个加图像GIF ..

+0

在你的问题中添加一些代码。 – KAR

+0

请张贴一些代码。 –

这实际上取决于持续时间和您所创建的GIF的帧率。使用GIF,您可以将帧速降低到8-10 fps,仍然可以看到不错的效果。

否则,你可以随时选择不同的图书馆,并希望它有更好的表现

+0

我尝试将fps设置为10来制作GIF,但不会改变我的痛苦使GIF – Keyur

+0

请将我推荐给其他库名称... – Keyur