• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1989
  • Last Modified:

How to speed up GDI+ in windows 7 / XP ?

Dear experts!

I have a application which use GDI+ to draw graphic objects which move on screen. It use GDI+ . I was very unpleasant surprise to understand that GDI+ work with Win 7, but there is no more hardware support. The result is that my app works without producing errors, but moving of the objects are not smooth, they jump due to fact that GDI+ is 5-10 times slower. Very very bad as my application core engine use GDI+ to paint a objects – gradient, crawl text, roll text and others

One solution is to rewrite the application. Which  technology then I should use and how long it will be supported ? But this is VERY worst solution …

Other solution is to find what to do to speed GDI+. For both XP and Win 7 – please give me any ideas, link to useful information? May be there especially models of MB or video cards which still support GDI + ? Please help … I’m desperate … I write the application a whole 1 year while GDI+ was the best, then 1 year I improve my solution and after 1 year now I should rewrite it totally which is VERY hard .. :-( :-( :-(. And worst is that even I do rewrite, there will be again HIGE testing and errors due to fact from life that first 1 years almost any application have bugs due to many reasons, included the errors by Windows or other components which do not depend of my work.

My app use VB6 and MS C++ 6. Interesting is that in the past - before 3 years GDI+ was enoght fast, now it is not enoght ... after much more CPU power and much more power in video cards ...

May be there is specific video cards models which support GDI+ at bigger speed?
  • 3
  • 2
1 Solution
satsumoSoftware DeveloperCommented:
Interesting response from this discussion thread, especially the last paragraph -
In Vista, Microsoft stopped using XP Driver Model (XPDM) display drivers in scenarios in which the Desktop Window Manager (DWM) is running. Because of this, it meant that all GDI operations – which used to be hardware accelerated by XPDM drivers – became software-only (meaning, not hardware accelerated). Applications render via GDI to a software buffer, which is then blt’d via the DWM.

In Windows 7, Microsoft modified the use of GDI in a couple important ways. First, the GDI back buffer maintained by DWM was moved from system memory into hardware aperature memory. This improves blt speed. Second, WDDM 1.1 drivers can hardware-accelerate a certain number of limited GDI operations (eg. solid color fill, etc). So, as long as you have a WDDM 1.1 driver, GDI is sort-of “reaccelerated”.  The degree to which WDDM 1.1 cards can hardware accelerate depends on fill rate, etc.

There’s a bug in GDI+ (which you’re describing above) that causes it to do readback from the hardware in a certain number of scenarios. The best way to use GDI+ in Windows 7 is to render with GDI+ to a DIB section and then blt the final result. You might want to give that a try before doing anything else.
dvplayltdAuthor Commented:
To satsumo

First, I’m really appreciate for you take time to answer me. I review your profile and understand that you are really professional in graphics.
If I’ll write new application I should use Direct2D – correct? Where is warranty that it will not be droped after 2 or 3 years? Just ask, do not wait answer.
However first I’ll try to find a solution without change my code.

Let focus on current GDI+ options. I think that I use (GDI+ to a DIB section and then blt the final result)  I do the test under Win XP and it look with enough speed. Now I’ll do test on same computers with Win 7. So I have follow questions:

1.      I can turn off Desktop Window Manager – will this increase speed ? Note that my application will work at dedicated server used only with my application, so the customers will install all which I require.

2.      How to check does Win 7 have WDDM 1.1 ? This WDDM 1.1 is function of drivers of the video card, or it is part of Windows? May be it is included in Win 7 SP1 ?

3.      In one case I should use a specific Matrox video card. It have drivers only for XP, and they work for Win 7 too, but I do not think they are optimized. Does this produce speed for GDI+ to become slower?

4.      I read a post in 2010 years from tom hardware site  that ATi Radeon cards drivers have a bug which make them  5-7 times slower in 2D on which GDI+ depends, they confirm that and answer that will fix it . Can you recommend me video card which are fine with 2D drawing?

5.      Can you have other idea which you may give me to increase speed under Win 7 (and XP too). What I shall turn off which are beautiful in screen, but consume recourses, especially GDI recourses? This is not on  this topic, but recently I understand that Win 7 have turn on by default defragment of HDD 1 times a week , and it took me some time to find that this is reason why my server producing signal from files for TV channels crash at exactly time every week … it try to read BIG video files while they have been defragment … ¿

Look that there difference in speed between CPU like Core 2 DUO P 2.66 FSB 1333 and Core 2 DUO P 3.0 FSB1333 . Unfortunately I do not have any of new i5 or i7 CPU … in test which I read on WEB I see that they are faster with 10-20 % then my CPU , do you think this may produce difference? GDI+ uses well more cores, or not?
satsumoSoftware DeveloperCommented:
Hello dvplayltd,

I'll try to answer your questions from the best of my knowledge.  For some of them the only way to know for sure is to test with the actual hardware.

1.  From my reading of that reply, if you turn of the DWM and you have XP drivers, Windows will use them.  Either Vista or 7.  If those drivers were faster, than you should get that speed back.

2.  Vista uses WDDM 1, 7 uses WDDM 1.1 and 8 will use WDDM 1.2.  They also support the driver models from previous version of Windows.  The models that gets used depends on the drivers, the hardware and the configuration of the OS.

3. If the Matrox card only has drivers for XP then Windows will either uses them, or replaces the hardware functions with software.  If the DWM is running, the XP drivers won't be used and GDI+ will be running in software.  If you turn off DWM then it should use the drivers properly.

4.  nVidia cards are good, as are Matrox.  There's no way of guaranteeing that any hardware will have drivers that support every feature consistently.  Early in the life of Vista, nVidia's drivers fell behind ATI's for certain accelerated 3D operations.  Base level graphics card are cheap and probably fast enough for what you want.  You could buy a couple of different makes, have some spares.

5.  This is a big question, although it's not really GDI resources that are a problem.  It's sounds like turning of WDM is a good idea.  Apart from that turn off anything that affects memory and processor, graphical or not.  For myself I turn off lots of services and try not to install things like .NET

GDI is single threaded and GDI+ is too.  Both will block another thread in certain situations.  There's not much advantage having multiple cores in either case.  DirectX does support multithreading.

Direct 2D or not?  It's truly impossible to predict what MS will do. GDI as the base level of graphics has survived a long time.  Direct 2D is a new thing and it might go the same way as GDI+ eventually.  In its favour, Direct X has been around for a long time although it has changed significantly in that time.  Moving between different version of DX requires rewriting parts of the code, and versions of DX are fixed to particular OS.  There have been 2D parts of DirectX in the past and they have been deprecated.

Direct 2D is lower level than GDI+, porting your code would mean quite a lot of work.  I think the deciding factor should be speed.  Does the speed required justify the extra work to use Direct X?  You might also consider that DirectX is a less common skillset than GDI, anyone who maintains the code will have to know it.

Long answer, I hope its helpful.
satsumoSoftware DeveloperCommented:
Ah, that reminds me, there's no Direct2D in XP.  It can use DirectX up to version 9.
dvplayltdAuthor Commented:
10x. I will start my reserach with have in mind you suggection Thank you!

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now