Use Render Target Bitmap
<Window x:Class="BitmapProgramming.UseRenderTargetBitmap"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="BitmapProgramming" Height="300" Width="300">
<Image x:Name="imageElement" />
</Window>
//File:Window.xaml.vb
Imports System
Imports System.Collections.Generic
Imports System.Text
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Data
Imports System.Windows.Documents
Imports System.Windows.Input
Imports System.Windows.Media
Imports System.Windows.Media.Imaging
Imports System.Windows.Shapes
Namespace BitmapProgramming
Public Partial Class UseRenderTargetBitmap
Inherits System.Windows.Window
Public Sub New()
InitializeComponent()
' Dimensions in physical pixels
' Pixel resolution (dpi)
Dim bmp As New RenderTargetBitmap(300, 150, 300, 300, PixelFormats.Pbgra32)
Dim e As New Ellipse()
e.Fill = Brushes.Red
e.Measure(New Size(96, 48))
e.Arrange(New Rect(0, 0, 96, 48))
bmp.Render(e)
imageElement.Source = bmp
End Sub
End Class
End Namespace
Related examples in the same category