C# How to stop animated gif from continually looping

后端 未结 4 1992
悲&欢浪女
悲&欢浪女 2020-12-11 05:20

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 on

相关标签:
4条回答
  • 2020-12-11 05:40

    You could always encapsulate the image/gif inside a Picturebox, and when you want the gif to stop, just set the Enabled property of the Picturebox to false.

    Just a thought.

    0 讨论(0)
  • 2020-12-11 05:40

    You can extract single frame from that GIF image (non - animated) when the progress event is done,

    txImage.Image = Image.FormFile("non-animated-frame-from-gif.jpg");
    

    You can use this website to extract frame from gif : http://gif-explode.com/

    0 讨论(0)
  • 2020-12-11 05:54

    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
    }
    
    0 讨论(0)
  • 2020-12-11 05:58

    You can just use pictureBox.Enabled = false; if you want to stop the GIF & pictureBox.Enabled = true; when you want it to run the GIF.

    0 讨论(0)
提交回复
热议问题