Search code examples
c#performancewinformsbitmapdraw

Is there an efficient way to draw 30 bitmaps per second in windows forms?


I'm working on a scientific project right now for the first time in my life and never had to deal with efficiency problems. Now I have the huge problem, that all the calculation of the heatmaps I have to draw works perfectly, but the bitmap drawer just can't handle drawing 30 bitmaps on to a picture box.
Does anyone know a different way of drawing a bitmap? It doesn't have to be to a picture box.
I know that there are similar questions, but they are all not for windows forms(I had to choose windows forms instead of WPF, because of reasons that take way to long to explain here).
This is one of my first posts on stack overflow, please excuse me if I made a Mistake.
Thank you in advance for the help.
Jonathan

Edit: The application is build to work with live data in 200Hz, because most screens can obviously not handle this I display only 30 FPS and record the dater in 200Hz, also to compensate the performance problem, but the performance is still really bad. If I had a better performing way of displaying the frames I would probably go for about 60FPS - 120FPS.
The images are all like a single frame of a video and 2x 500px900px pixels big(2 because I have two sensors at the same time that both give data for a complete heatmap). I create the bitmaps with skiasharp, because I've heard that this is the most efficient way of doing it.
I hope I answered all questions that were asked.


Solution

  • I was already drawing on a bitmap in memory, but the tip of Ken White gave me the idea to write the Bitmap to an image variable before I assign it and it worked for reasons I don't understand. The time one drawing call needs is reduced by about 50%. Thank you for the tip Ken White.