C# 使用BitmapEncoder生成时,如何在循环中重复GIF

C# 使用BitmapEncoder生成时,如何在循环中重复GIF,c#,windows,windows-runtime,animated-gif,C#,Windows,Windows Runtime,Animated Gif,我能够使用位图编码器(C#,WinRT)创建动画gif。然而,我还没有弄明白如何使GIF循环返回并从头开始 我没有尝试太多,因为我不知道该尝试什么。搜索了更多要在GIF上设置的属性,但找不到任何相关属性。好的,终于找到了。显然,您需要将以下metdata添加到GIF以使其循环: BitmapPropertySet properties = await encoder.BitmapProperties.GetPropertiesAsync("/appext/Data"); properties =

我能够使用位图编码器(C#,WinRT)创建动画gif。然而,我还没有弄明白如何使GIF循环返回并从头开始


我没有尝试太多,因为我不知道该尝试什么。搜索了更多要在GIF上设置的属性,但找不到任何相关属性。

好的,终于找到了。显然,您需要将以下metdata添加到GIF以使其循环:

BitmapPropertySet properties = await encoder.BitmapProperties.GetPropertiesAsync("/appext/Data");
properties = new BitmapPropertySet()
{
    {
        "/appext/Application",
        new BitmapTypedValue(Iso8859.Default.GetBytes("NETSCAPE2.0"), Windows.Foundation.PropertyType.UInt8Array)
    },
    { 
        "/appext/Data",
        new BitmapTypedValue(new byte[] { 3, 1, 0, 0, 0 }, Windows.Foundation.PropertyType.UInt8Array)
    },
};

await encoder.BitmapProperties.SetPropertiesAsync(properties);
如果项目中没有Iso8859,只需将“NETSCAPE2.0”的ascii代码作为字节数组放在其中即可