How do I make a GIF repeat in loop when generating with BitmapEncoder

最后都变了- 提交于 2019-12-13 14:23:59

问题


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?

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.


回答1:


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);

If you don't have an Iso8859 in your project, simply place the ascii code for "NETSCAPE2.0" as a byte array in there.



来源:https://stackoverflow.com/questions/15465871/how-do-i-make-a-gif-repeat-in-loop-when-generating-with-bitmapencoder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!