【发布时间】:2017-05-06 20:41:41
【问题描述】:
我仍在将 60 个图像阵列制作为 320*320 大小的 GIF 图像。通常我在 github 上使用第三方库 NSGIF,但在使用 80 张图像处理 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..
【问题讨论】:
-
在您的问题中添加一些代码。
-
请贴一些代码。
标签: ios objective-c objective-c-blocks gif