I'm trying to have smooth animations on a C# form application.
What I basically need to do is to call some drawing functions to create the layout of the UI.
I already looked online and tried many alternatives but none of these have been completely successful in terms of visible fli开发者_如何转开发ckering.
I've set the form properties to:
this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer, true);
this.DoubleBuffered = true;
Then I have a separate thread to draw one of the menus, I'm composing the image in memory within a bitmap and then printing the result on screen.
Bitmap curBitmap = new Bitmap(200, 700);
Graphics tempGraph1;
tempGraph1 = Graphics.FromImage(curBitmap);
tempGraph1.FillRectangle(s1.color, r1);
tempGraph1.FillEllipse(s1.color, e1);
tempGraph1.FillEllipse(Brushes.White, c1);
formGraphT1.DrawImage(curBitmap, 0, timer1_count);
So even by just having one single DrawImage call per cycle, some flickering is still noticeable. Feels like the fps rate is limited somewhere or like double buffering doesn't actually occur. Any thoughts?
Thanks, .A
Have you tried calling SuspendLayout/ResumeLayout before and after drawing ?
精彩评论