Files
docs-desktop/dotnet-desktop-guide/framework/wpf/graphics-multimedia/how-to-create-a-bitmap-from-a-visual.md
T
Andy De George da363692ff Initial WPF content migrated (#17)
* 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
2020-09-04 09:46:28 -07:00

25 lines
1.3 KiB
Markdown

---
title: "How to: Create a Bitmap from a Visual"
ms.date: "03/30/2017"
dev_langs:
- "csharp"
- "vb"
helpviewer_keywords:
- "bitmaps [WPF], rendering from visuals"
- "visuals [WPF], rendering to bitmaps"
ms.assetid: 103fc7f5-7306-4026-9d61-2005e79959f3
---
# How to: Create a Bitmap from a Visual
This example shows how you can create a bitmap from a <xref:System.Windows.Media.Visual>. A <xref:System.Windows.Media.DrawingVisual> is rendered with <xref:System.Windows.Media.FormattedText>. The <xref:System.Windows.Media.Visual> is then rendered to the <xref:System.Windows.Media.Imaging.RenderTargetBitmap> creating a bitmap of the given text.
## Example
[!code-csharp[ImagingSnippetGallery_procedural_snip#CreateRTBImage](~/samples/snippets/csharp/VS_Snippets_Wpf/ImagingSnippetGallery_procedural_snip/CSharp/RenderTargetBitmapExample.cs#creatertbimage)]
[!code-vb[ImagingSnippetGallery_procedural_snip#CreateRTBImage](~/samples/snippets/visualbasic/VS_Snippets_Wpf/ImagingSnippetGallery_procedural_snip/VB/RenderTargetBitmapExample.vb#creatertbimage)]
## See also
- <xref:System.Windows.Media.DrawingContext>
- [Imaging Overview](imaging-overview.md)
- [Drawing Objects Overview](drawing-objects-overview.md)
- [Using DrawingVisual Objects](using-drawingvisual-objects.md)