I am writing a simple control in C # that works like a box with pictures, except that the image constantly scrolls up (and appears again from below). The animation effect is controlled by a timer (System.Threading.Timer), which copies from the cached image (in two parts) to a hidden buffer, which is then displayed on the control surface in its Paint event.
The problem is that this scroll animation effect is slightly jerky when working with a high frame rate of 20 frames per second (at lower frame rates, the effect is too small to be perceived). I suspect that this rage is caused by the fact that the animation is in no way synchronized with the refresh rate of the monitor, which means that each frame remains on the screen for a variable duration, and not exactly 25 milliseconds.
Is there any way to make this animation scroll smoothly?
You can download the sample application here (run it and click "start"), and the source code is here . It does not look terribly jerky, but if you look at it carefully, you will see hiccups.
WARNING : this animation creates a rather strange optical illusion effect that can make you a little sick. If you watch it for a while and then turn it off, it will look as if your screen is stretched vertically.
UPDATE : as an experiment, I tried to create an AVI file with my scroll bitmaps. The result was less dramatic than my WinForms animation, but still unacceptable (and it still hurt me to watch it for too long). I think that I was faced with the fundamental problem of not synchronizing with the refresh rate, so I may have to keep people sick of my appearance and personality.
source share