0

I am drawing a scatter plot with the help of GDI. But, when there are many lines, it takes about two seconds to draw. I looked into using SlimDX and SharpDX and utilized their 2D. It only decreased the time by half. Is there any better tools that I can use to speed up the drawing? I am simply utilizing g.DrawLine. I also heard that there is a tool that lets me draw a scatter on memory and put it on a screen. If you have ideas, it will be greatly appreciated. Thank you.

  • 4
    Please share the code you use to plot. Otherwise it's difficult to help. – Irshad Dec 08 '15 at 03:46
  • You shouldn't be asking for libraries on SO. Nevertheless, try http://vgdotnet.com/ - it is awesome. It's a winforms scalable vector graphics library. You can do very awesome animations with it too. Sort of like WPF for winforms. – Enigmativity Dec 08 '15 at 03:53
  • Sometimes it is _how_ you draw rather than _what_ API you use to draw determines performance. I can think of many games claiming hardware-assisted rendering via Direct3D with sub-par performance. Maybe your code is just un-optimised –  Dec 08 '15 at 04:27
  • Why not use the Chart control? Also define 'many'! – TaW Dec 08 '15 at 17:18
  • Also see here for [simple examples](http://stackoverflow.com/questions/27337825/picturebox-paintevent-with-other-method/27341797?s=2|0.0381#27341797) of drawing onto a Control surface and into a Bitmap! – TaW Dec 08 '15 at 18:27
  • This is my first time using StackOverflow. I will make a note of that I should not be asking for libraries next time. – JEONG MIN LEE Dec 09 '15 at 01:45

1 Answers1

1

[Are] there any better tools that I can use to speed up the drawing?

First, use g.DrawLines instead of g.DrawLine. This means there is one transition from user code to graphics code instead of one per line.

Second, select a bitmap into the graphics object, draw into that then write the bitmap to the display. See how to draw a line on a image? for an example of drawing a line on a bitmap. This means the lines are drawn once then refreshing the display is a single fast Bit Blit.

Using DirectX ports (e.g. SharpDX, and SlimDX) is possible but probably overkill unless you are dealing with extremely complex scatter plots. These are (generally) more geared toward 3D vector or 2D Bit Blit based graphics.

Community
  • 1
  • 1
akton
  • 14,148
  • 3
  • 43
  • 47