简体   繁体   English

使用绘图调用在C#中平滑动画

[英]smooth animation in C# with drawing calls

I'm trying to have smooth animations on a C# form application. 我正在尝试在C#表单应用程序上制作平滑的动画。

What I basically need to do is to call some drawing functions to create the layout of the UI. 我基本上需要做的是调用一些绘图函数来创建UI的布局。

I already looked online and tried many alternatives but none of these have been completely successful in terms of visible flickering. 我已经在网上查看并尝试了许多替代方法,但是就可见闪烁而言,这些方法都没有完全成功。

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. 因此,即使每个周期只有一个DrawImage调用,仍然会出现一些闪烁。 Feels like the fps rate is limited somewhere or like double buffering doesn't actually occur. 像fps速率这样的感觉受到限制,或者实际上根本没有发生双重缓冲。 Any thoughts? 有什么想法吗?

Thanks, .A 谢谢

您是否尝试过在绘图前后调用SuspendLayout / ResumeLayout

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM