
What's New with Graphics and Multimedia in the WPF
WPF introduces Windows developers to new graphics features that have the following benefits:
Resolution and device-independent graphics. The WPF graphics system uses device-independent units to enable resolution and device independence. Each device independent pixel automatically scales with the dots-per-inch setting of your system.
Improved precision. The WPF coordinate system uses doubles instead of floats. Transformations and opacity values are also expressed by using doubles. WPF also supports a wider color gamut (scRGB) and provides integrated support for managing inputs from different color spaces.
Advanced graphics and animation support. WPF simplifies graphics programming by managing the scene graph for you; no more worrying about scene processing, rendering loops, and bilinear interpolation. WPF provides hit-testing support, an integrated animation system, and full alpha compositing support.
Hardware acceleration. The WPF graphics system is designed to take advantage of graphics hardware to minimize CPU usage.
2-D Shapes
WPF provides a library of commonly used, vector-drawn 2-D shapes, such as rectangles and ellipses, which the following illustration shows.
.png)
These intrinsic WPF shapes are not just shapes: they are programmable elements that implement many of the features that you expect from most common controls, which include keyboard and mouse input.
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="Window1" >
<Ellipse Fill="LightBlue" MouseUp="ellipseButton_MouseUp" />
</Window>
public partial class Window1 : Window
{
void ellipseButton_MouseUp(object sender, MouseButtonEventArgs e)
{
MessageBox.Show("Me, a simple ellipse, was mouse clicked!");
}
}
The following illustration shows the output for the preceding XAML markup and code-behind.
.png)
For more information, see Shapes and Basic Drawing in WPF Overview. For an introductory sample, see Shape Elements Sample.
2-D Geometries
When the 2-D shapes that WPF provides are not sufficient, you can use WPF support for geometries and paths to create your own. The following illustration shows how you can use geometries to create shapes, as a drawing brush, and to clip other WPF elements.
.png)
For more information, see Geometry Overview. For an introductory sample, see Geometries Sample.
2-D Effects
WPF provides a library of 2-D classes that you can use to create a variety of effects. The 2-D rendering capability of WPF provides the ability to paint UI elements with gradients, bitmaps, drawings, and videos; and to manipulate them by using rotation, scaling, and skewing. The following illustration gives an example of the many effects you can achieve by using WPF brushes.
.png)
For more information, see WPF Brushes Overview. For an introductory sample, see Brushes Sample.
3-D Rendering
WPF provides a set of 3-D rendering capabilities that integrate with 2-D graphics support in WPF in order for you to create more exciting layout, UI, and data visualization. At one end of the spectrum, WPF enables you to render 2-D images onto the surfaces of 3-D shapes, which the following illustration demonstrates.
.png)
For more information, see 3-D Graphics Overview. For an introductory sample, see 3-D Solids Sample.