使用 BitmapEncoder 生成时如何使 GIF 循环重复 [英] How do I make a GIF repeat in loop when generating with BitmapEncoder
问题描述
我能够使用 BitmapEncoder(C#、WinRT)来创建动画 gif.但是,我一直无法弄清楚如何使 GIF 循环返回并从头开始?
I am able to use BitmapEncoder (C#, WinRT) to create an animated gif. However, I haven't been able to figure out how to make the GIF loop back and start from scratch?
没有尝试太多,因为我不知道该尝试什么.搜索了更多要在 GIF 上设置的属性,但找不到任何相关内容.
Didn't try much because I am not sure what to try. Searched for more properties to set on the GIF, but could not find anything relative.
推荐答案
好吧,终于搞清楚了.显然,您需要将以下元数据添加到 GIF 以使其循环:
Okay, finally been able to figure it out. Apparently you need to add the following metdata to the GIF to get it to loop:
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 代码作为字节数组放入其中.
If you don't have an Iso8859 in your project, simply place the ascii code for "NETSCAPE2.0" as a byte array in there.
这篇关于使用 BitmapEncoder 生成时如何使 GIF 循环重复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!