菜鸟教程小白 发表于 2022-12-11 18:22:51

ios - 在ios中制作GIF图像需要多少个图像数组


                                            <p><p>我仍在将 60 个图像阵列制作为 320*320 大小的 GIF 图像。通常我在 github 上使用第三方库 NSGIF,但在使用 80 张图像处理 GIF 图像时仍然收到应用程序内存警告和崩溃。</p>

<pre><code>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 = [ URLForDirectory:NSDocumentDirectory inDomain:NSUserDomainMask appropriateForURL:nil create:YES error:nil];
NSString *savePath = ;

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

for (NSUInteger i = 0; i &lt; ImageArray.count; i++) {
    @autoreleasepool {
      UIImage *CaptureImage = ;

      CGImageDestinationAddImage(destination, CaptureImage.CGImage, (__bridge CFDictionaryRef)frameProperties);
    }
}
if (!CGImageDestinationFinalize(destination)) {
}
else
{
    //;
}
CFRelease(destination);
</code></pre>

<p>我想制作 80 多张图片到 GIF..</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>这实际上取决于您正在创建的 gif 的持续时间和帧速率。使用 GIF,您可能可以将帧速率降低到 8-10 fps,但仍然可以看到一些不错的东西。</p>

<p>否则你总是可以选择不同的库并希望它有更好的性能</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 在ios中制作GIF图像需要多少个图像数组,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/41262528/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/41262528/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 在ios中制作GIF图像需要多少个图像数组