BitmapImage Class
Provides a specialized BitmapSource that is optimized for loading images using Extensible Application Markup Language (XAML).
Assembly: PresentationCore (in PresentationCore.dll)
XMLNS for XAML: http://schemas.microsoft.com/winfx/2006/xaml/presentation, http://schemas.microsoft.com/netfx/2007/xaml/presentation
BitmapImage primarily exists to support Extensible Application Markup Language (XAML) syntax and introduces additional properties for bitmap loading that are not defined by BitmapSource.
BitmapImage implements the ISupportInitialize interface to optimize initialization on multiple properties. Property changes can only occur during object initialization. Call BeginInit to signal that initialization has begun and EndInit to signal that initialization has completed. After initialization, property changes are ignored.
BitmapImage objects created using the BitmapImage constructor are automatically initialized and property changes are ignored.
The following code examples demonstrate how to use a BitmapImage in Extensible Application Markup Language (XAML) and code.
<!-- Property Tag XAML Syntax --> <Image Width="200" Margin="5" Grid.Column="1" Grid.Row="1" > <Image.Source> <BitmapImage UriSource="sampleImages/bananas.jpg" /> </Image.Source> </Image>
<!-- Property Tag XAML Syntax --> <Image Width="200" Margin="5" Grid.Column="1" Grid.Row="1" > <Image.Source> <BitmapImage UriSource="sampleImages/bananas.jpg" /> </Image.Source> </Image>
' Create the image element. Dim simpleImage As New Image() simpleImage.Width = 200 simpleImage.Margin = New Thickness(5) ' Create source. Dim bi As New BitmapImage() ' BitmapImage.UriSource must be in a BeginInit/EndInit block. bi.BeginInit() bi.UriSource = New Uri("/sampleImages/cherries_larger.jpg", UriKind.RelativeOrAbsolute) bi.EndInit() ' Set the image source. simpleImage.Source = bi
More Code
| How to: Apply a Transform to a BitmapImage | This example demonstrates how to apply a Transform to a BitmapImage. |
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.