【问题标题】:How many images Array to make GIF Images in ios在ios中制作GIF图像需要多少图像数组
【发布时间】: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


【解决方案1】:

这实际上取决于您正在创建的 gif 的持续时间和帧速率。使用 GIF,您可能可以将帧速率降低到 8-10 fps,但仍然可以看到一些不错的东西。

否则你总是可以选择不同的库并希望它有更好的性能

【讨论】:

  • 我尝试将 fps 设置为 10 来制作 GIF,但没有改变我制作 GIF 的痛苦
猜你喜欢
  • 2015-01-08
  • 2013-06-17
  • 1970-01-01
  • 1970-01-01
  • 2020-07-10
  • 2014-02-23
  • 1970-01-01
  • 2014-04-27
  • 2018-03-05
相关资源
最近更新 更多