小编And*_*re 的帖子

保存为 GIF 后图像质量下降

我正在开发一款 iOS 应用程序,它允许用户拍摄一系列照片 - 然后将照片放入动画中并导出为 MP4 和 GIF。

虽然 MP4 呈现源质量,但 GIF 颜色等级是可见的。

这是视觉比较:

动图:动图

MP4MP4

我用于导出为 GIF 的代码:

var dictFile = new NSMutableDictionary();
        var gifDictionaryFile = new NSMutableDictionary();
        gifDictionaryFile.Add(ImageIO.CGImageProperties.GIFLoopCount, NSNumber.FromFloat(0));

        dictFile.Add(ImageIO.CGImageProperties.GIFDictionary, gifDictionaryFile);

        var dictFrame = new NSMutableDictionary();
        var gifDictionaryFrame = new NSMutableDictionary();
        gifDictionaryFrame.Add(ImageIO.CGImageProperties.GIFDelayTime, NSNumber.FromFloat(0f));

        dictFrame.Add(ImageIO.CGImageProperties.GIFDictionary, gifDictionaryFrame);


        InvokeOnMainThread(() =>
    {
        var imageDestination = CGImageDestination.Create(fileURL, MobileCoreServices.UTType.GIF, _images.Length);

        imageDestination.SetProperties(dictFile);

        for (int i = 0; i < this._images.Length; i++)
        {
            imageDestination.AddImage(this._images[i].CGImage, dictFrame);

        }
        imageDestination.Close();
    });
Run Code Online (Sandbox Code Playgroud)

我用于导出为 MP4 的代码:

var videoSettings = new NSMutableDictionary(); …
Run Code Online (Sandbox Code Playgroud)

image-processing gif ios swift

4
推荐指数
1
解决办法
2133
查看次数

标签 统计

gif ×1

image-processing ×1

ios ×1

swift ×1