How to achieve smooth drawing using C # (e.g. Paint.NET)?

How can Paint.NET draw so fast using C #? Example: the perimeter of an ellipse is drawn while dragging the mouse without visible delay. In a simple Windows form application in C # If you use the MouseMove event in a Picturebox and draw an ellipse depending on the position of the mouse, there will be many delays and flickers! So how do they do it so smoothly?

+4
source share
4 answers

They are probably using WPF. It is much faster than forms.

0
source

I have no special knowledge of Paint.Net code, but most likely it uses Double Buffering and may have been implemented manually rather than a simplified implementation in pre-packaged controls.

+4
source

Paint.NET calls Update () after calling the Invalidate () function, which forces an immediate, synchronous WM_PAINT.

+4
source

To get a smooth pattern, you must:

  • Use a double buffer (http://msdn.microsoft.com/en-us/library/b367a457.aspx)
  • Use dedicated rendering tools (OpenGL / DirectDraw, etc.)

The best way in this case is with double buffering - it is supported “out of the box” in the .NET platform, it requires very little work and eliminates flickering.

+2
source

Source: https://habr.com/ru/post/1395277/


All Articles