C# 如何阻止动画 gif 不断循环 [英] C# How to stop animated gif from continually looping
本文介绍了C# 如何阻止动画 gif 不断循环的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的应用程序使用互联网时会调用一个事件.该事件更改了一个由 7 帧组成的动画 gif.如何让它只循环一次帧?
I have an event that gets called when my app uses the internet. The event changes an animated gif composed of 7 frames. How do I make it only loop through the frames only once?
private void trafficSendingActive(object sender, trafficEventArgs e)
{
txImage.Image = Properties.Resources.blip;
}
推荐答案
您可以使用 System.Drawing.ImageAnimator
来启动/停止 gif 动画
You could use the System.Drawing.ImageAnimator
to start/stop the gif animation
// start
System.Drawing.ImageAnimator.Animate(txImage.Image, OnFrameChanged);
// stop
System.Drawing.ImageAnimator.StopAnimate(txImage.Image, OnFrameChanged);
private void OnFrameChanged(object sender, EventArgs e)
{
// frame change
}
这篇关于C# 如何阻止动画 gif 不断循环的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文