This documentation is archived and is not being maintained.

BitmapImage Class

Provides a specialized BitmapSource that is optimized for loading images using Extensible Application Markup Language (XAML).

Namespace:  System.Windows.Media.Imaging
Assembly:  PresentationCore (in PresentationCore.dll)

Public NotInheritable Class BitmapImage _
	Inherits BitmapSource _
	Implements ISupportInitialize, IUriContext
Dim instance As BitmapImage
<BitmapImage .../>

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" >
      <BitmapImage UriSource="sampleImages/bananas.jpg" />
<!-- Property Tag XAML Syntax -->
<Image Width="200"  Margin="5" Grid.Column="1" Grid.Row="1" >
      <BitmapImage UriSource="sampleImages/bananas.jpg" />
' 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.UriSource = New Uri("/sampleImages/cherries_larger.jpg", UriKind.RelativeOrAbsolute)
' 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.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

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.

.NET Framework

Supported in: 3.5, 3.0