tags:

views:

496

answers:

3

When GDI+ came out, I remember all the brouhaha about how it was the "new, faster, better" way to display stuff in Windows. But everytime I looked at it, it seemed to me that it was really just a COM wrapper around GDI.

Is that true? Or is GDI+ really an independent graphical library that simply shares some paradigms with GDI?

Personally, I'm not sure how it could be independent, but I never saw a definite statement one way or another.

+6  A: 

GDI+ is built over GDI, and adds several more features. For example, GDI+ adds support for transparency, anti-aliasing bitmap stretching, etc...

GDI+ is mainly a Object based API, and GDI is a function api. Most of the functionalities in GDI+ are not hardware optimized (there are handled by software), to contrast with GDI. For example, in GDI, BitBlt is handled directly by hardware. GDI+ bitmap painting functions are not.

GDI+ is a powerful API, but be careful with its performance.

GDI+ is available in C++, COM and .NET

decasteljau
+3  A: 

GDI+ is not COM. GDI+ has an underlying "flat" API that is callable from C (or any other language, therefore), and an object-oriented wrapper in C++ that just calls the flat API. There are also wrappers in .NET (System.Drawing) and Delphi that also just call the flat API. It works completely different from GDI in that you don't set objects (pens, brushes, fonts) to a device context, but rather pass them to drawing functions. It does not have much in common with GDI. I don't know though if the implementation of GDI+ uses GDI - but it likely doesn't, because it has so many features that are just not available in GDI.

Unfortunately, it is slower than GDI. It's very powerful though.

As decasteljau pointed out in the meantime, the performance issues might come from the fact that it is not rendered in hardware, unlike OpenVG or WPF. I recently used XNA because of that for a graphical realtime application.

OregonGhost
+1  A: 

Many GDI functions are accelerated by the graphics hardware, and some GDI+ routines may use GDI underneath. But most of GDI+ is independant of GDI.

An important, and telling, example is text rendering. In GDI+ text rendering is done completely in software; the anti-aliasing, glyph pixel-fitting and other effects is done without the video card.

alt text

Microsoft's Chris Jackson had an interesting blog post where he profiled the speed difference between text rendering in GDI and GDI+:

...my GDI code path was rendering approximately 99,000 glyphs per second, while my GDI+ code path was rendering approximately 16,000 glyphs per second.

Another example is line drawing. GDI+ supports anti-aliased line/polygon and circle/ellipse drawing, while GDI does not:

alt textalt text

alt text

Ian Boyd