Reputation: 3440
I have a winforms application developed in C#, which involves a lot of screen painting. The painting involves rendering of custom controls and other 2D objects. Now the problem is, it takes up approximately 4 to 5 seconds to paint the entire screen. I had optimized the code to a level, where all required data is made available in the memory itself rather than reading it from the disk or network.
To further cut down the rendering time I was planning to go for the following options
Call directly GDI functions exposed by Win32API, instead of using the GDI classes provided by .NET
Make use of DirectX as I heard that it is much efficient at rendering. My application doesnt involve any kind of 3D rendering.
Please help me to decide which option to go for? are there any options other than this, like any high performance third party components or libraries.
Upvotes: 0
Views: 994
Reputation: 210573
From personal experience:
GDI+ is only slower than GDI by a factor of < 2. It won't help much to switch from .NET (which uses GDI+) to pure GDI.
Direct2D is just as slow as GDI -- at least for drawing basic shapes. So unless you're doing something a lot more complicated, it probably won't help.
Your best bet is to probably cut down on the drawing, and to double-buffer the data.
If it doesn't work, you would probably want to generate the bitmap in memory (using a byte[]
or something, avoiding graphics APIs entirely), and to simply blit (copy) it directly to the screen. It's hard, but it almost always turns out to be the fastest.
Upvotes: 1