I'm trying to move a small image from the left side to the screen to the right side.
I set the styles for the usercontrol to:
this.SetStyle(ControlStyles.Opaque, true);
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
In my OnPaint
handler I draw the object to a BufferedGraphics
instance, which is my off-screen buffer, and then BitBlt the result to the e.Graphics
reference using a single call.
So it seems I did everything by the book, to have ultra-smooth flicker-free drawing, and STILL i can see the object stuttering a little.
So there are bascily two possibilities left: either the Timer that is calling .Invalidate(DirtyRect)
is not firing exactly at a constant interval, causing the object appear to stutter, or BitBlt doesn't work as expected.
Does anyone have any idea what could be the problem?
UPDATE: On second thought, it looks more like tearing, than stuttering or flickering. Because sometimes the object seems to miss the last few pixels. I will look into the possibilities to draw on VSYNC.