-1

I am busy with creating an GUI which should have some animations in it. My idea was to use an animated gif as background with controls on top. This all is working fine until I wanted to add an timer to update some values each second, then the timer does not work. If I set enabled setting of the picture box to false the timer is running. For me it sounds like having some performance issues, although 140mb of ram and only a few percent of CPU is used.

Both the picture box and timer are the standard from Visual Studio 2019, where I program in C#. The animated gif is 50mb and is in the Systems.Windows.Forms.PictureBox. The timer I have used is the standard timer: System.Windows.Forms.Timer

Is there an timer that does work in combination with the animated gif? Or is there a picture box which can process animated gifs with better performance? Or should I step out from an animated gif to something else?

Currently the code is nothing more then changing the text of a button: Currently it is nothing more then changing the text of an button:

private void button1_Click(object sender, EventArgs e)
    {
        button1.Text = "1234";
    }
    private void timer1_Tick(object sender, EventArgs e)
    {
        button1.Text = "test";
    }
    private void button3_Click(object sender, EventArgs e)
    {
        timer1.Start();
    }

Settings of the timer and animated gifs etc are in the proporties of that container.

Thanks in advance.

Edit: allready tried compressing the gif, with this the image is still around 40m and has the same problem. Smaller will result in too much loss of quality. An real small animated gif does not give the issue. So is there a workaround to use the big animated gif? :)

To give an idea what I would like to achieve: https://motionarray.com/stock-motion-graphics/hud-video-frame-345823 This I would like to use with buttons and sliders on top.

1 Answers1

0

Firstly, I'd suggest trying to compress your animated gif down. 50MB is large, and a quick Google search will show you many different sites that will compress it down to something smaller. Having a gif that size in your program is giving you performance issues.

I quickly recreated a small example with an animated gif with two buttons and a timer control, and the timer was ticking fine without the background messing up its animation. Make sure you have the timer set to disabled in the Properties tab, and then simply set the timer to enabled when you want it to start ticking.

private void button1_Click(object sender, EventArgs e)
{
    button1.Text = "1234";
}

private void timer1_Tick(object sender, EventArgs e)
{
    button1.Text = "test";
}

private void button3_Click(object sender, EventArgs e)
{
    timer1.Enabled = true;
}
Rhys Wootton
  • 182
  • 8
  • Thanks for you answer. I allready tried to compres the animated gif and then still the size was around 40mb, lower will reduce the quality too much. The problem is I think the length: 30 seconds. If I change the animated gif to a real small one it does work. But I am fixed to that longer and biffer animated gif. – renebiemans Aug 01 '20 at 10:20
  • Is there anyway you can trim the length of the gif down? Or possibly speed up the animation to make its duration smaller? I think the reason you aren't getting it to work efficiently is because the gif is using a large amount of resources. – Rhys Wootton Aug 01 '20 at 10:29