WPF is the new 'presentation' direction for Microsoft that was introduced as part of Vista and Framework 3.0. WPF will eventually take over all of the graphics for Microsoft technology, and that will include our faithful friend since before .NET, GDI+ (Graphical Device Interface).
For the time being, there will continue to be GDI+ code out there for two reasons:
- Legacy applications ... like death and taxes, they will always be with us
- Specific details only supported by GDI+
That second category is the one Microsoft can help with directly. Through their continuing upgrades, these details are getting to be fewer and fewer all the time. The team that continues to support GDI at Microsoft is the same one developing WPF, so they're well aware of all of the issues. Since GDI+ is still fully supported, if you want to learn more about it, About Visual Basic has a complete tutoral: GDI+ Graphics in Visual Basic .NET.
GDI goes back a long way. The original reason for creating it was to let Windows support specific, pixel oriented hardware - monitors and printers. That's why GDI is a raster (pixel by pixel) based technology that depends on software rather than a vector (calculated lines and shapes) that leverages the use of hardware (graphics cards with their GPU - Graphics Processing Units.
The other legacy graphics technology at Microsoft is DirectX. You won't see it going away very soon because WPF actually uses DirectX. DirectX was created in 1995 to get game developers to create computer games for Windows. It offers the support for animation and 3D rasterization (converting vector images into the pixels still required by hardware) that GDI+ lacks. DirectX runs directly on the graphics hardware and doesn't load down your computer processor, so this advantage is also shared by WPF.
A First Example - WPF Graphics
There are two basic ways to dealing with simple 2D graphics in WPF:
In very simple terms, a Shape is easier to use while a Geometry is more flexible and powerful. The Path class bridges the two and we'll talk about all three of these things in the rest of this article. On the next page, we start with Shape.