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

前端 未结 3 1542
南旧
南旧 2021-02-14 18:11

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

相关标签:
3条回答
  • 2021-02-14 18:29

    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.


    (source: microsoft.com)

    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:


    (source: microsoft.com)

    (source: microsoft.com)


    (source: microsoft.com)

    0 讨论(0)
  • 2021-02-14 18:31

    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

    0 讨论(0)
  • 2021-02-14 18:41

    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.

    0 讨论(0)
提交回复
热议问题