Is GDI+ just a layer on top of GDI, or something n

2019-03-26 14:06发布

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.

标签: gdi+ gdi
3条回答
倾城 Initia
2楼-- · 2019-03-26 14:40

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.

查看更多
Ridiculous、
3楼-- · 2019-03-26 14:59

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 http://i.msdn.microsoft.com/ms533818.fontstext10(en-us,VS.85).png

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 text http://i.msdn.microsoft.com/ms536351.aboutgdip02_art33(en-us,VS.85).pngalt text http://i.msdn.microsoft.com/ms536351.aboutgdip02_art34(en-us,VS.85).png

alt text http://i.msdn.microsoft.com/ms536351.aboutgdip02_art36(en-us,VS.85).png

查看更多
男人必须洒脱
4楼-- · 2019-03-26 15:04

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

查看更多
登录 后发表回答