简体   繁体   中英

How to achieve smooth drawing with C# (like Paint .NET)?

How Paint .NET can draw so fast using C#? Sample: The elipse perimeter is drawn while the mouse is beeing dragged without any visible delay. At a simple windows form application in C# If you use the MouseMove event of a Picturebox and draw a elipse based on the mouse position, there will be a lot of delay and flickering! So, how they do it so smoothly?

我对Paint.Net代码没有特别的了解,但很可能它使用的是Double Buffering ,并且可能是在自定义绘图表面上手动实现的,而不是预打包控件中的简单实现。

Paint.NET在调用Invalidate()后调用Update(),强制立即同步WM_PAINT。

To get smooth drawing you should:

  • Use Double Buffering (http://msdn.microsoft.com/en-us/library/b367a457.aspx)
  • Use a dedicated toolkit for rendering (OpenGL/DirectDraw etc)

The best way to go in this case is with Double Buffering - it's supported 'out of the box' in the .NET framework, requires very little work, and will eliminate flickering.

They probably use WPF. It is much much faster than forms.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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