* Reset branch for WPF changes * Convert BMP to PNG; fix link-out-of-scope err * Add snippets for WPF... 6794 files!!!! * Add missing snippets * update file updated between migration * Fix paths to include * update breadcrumb and toc * fix index links * fix index links * fix index links * fix markdown
2.3 KiB
title, ms.date, helpviewer_keywords, ms.assetid
| title | ms.date | helpviewer_keywords | ms.assetid | |||
|---|---|---|---|---|---|---|
| How to: Draw an Image Using ImageDrawing | 03/30/2017 |
|
df28ab41-25fb-4ab3-b51d-7f695b24f55e |
How to: Draw an Image Using ImageDrawing
This example shows how to use an xref:System.Windows.Media.ImageDrawing to draw an image. An xref:System.Windows.Media.ImageDrawing enables you display an xref:System.Windows.Media.ImageSource with a xref:System.Windows.Media.DrawingBrush, xref:System.Windows.Media.DrawingImage, or xref:System.Windows.Media.Visual. To draw an image, you create an xref:System.Windows.Media.ImageDrawing and set its xref:System.Windows.Media.ImageDrawing.ImageSource%2A?displayProperty=nameWithType and xref:System.Windows.Media.ImageDrawing.Rect%2A?displayProperty=nameWithType properties. The xref:System.Windows.Media.ImageDrawing.ImageSource%2A?displayProperty=nameWithType property specifies the image to draw, and the xref:System.Windows.Media.ImageDrawing.Rect%2A?displayProperty=nameWithType property specifies the position and size of each image.
Example
The following example creates a composite drawing using four xref:System.Windows.Media.ImageDrawing objects. This example produces the following image:
[!code-csharpDrawingMiscSnippets_snip#ImageDrawingExample] [!code-xamlDrawingMiscSnippets_snip#ImageDrawingExample]
For an example showing a simple way to display an image without using xref:System.Windows.Media.ImageDrawing, see Use the Image Element.
