开发者

smooth animation in C# with drawing calls

开发者 https://www.devze.com 2023-02-16 01:53 出处:网络
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'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 ?

0

精彩评论

暂无评论...
验证码 换一张
取 消