This documentation is archived and is not being maintained.

BitmapDecoder.Create Method (Stream, BitmapCreateOptions, BitmapCacheOption)

Creates a BitmapDecoder from a Stream by using the specified BitmapCreateOptions and BitmapCacheOption.

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

Public Shared Function Create ( _
	bitmapStream As Stream, _
	createOptions As BitmapCreateOptions, _
	cacheOption As BitmapCacheOption _
) As BitmapDecoder
Dim bitmapStream As Stream 
Dim createOptions As BitmapCreateOptions 
Dim cacheOption As BitmapCacheOption 
Dim returnValue As BitmapDecoder 

returnValue = BitmapDecoder.Create(bitmapStream, _
	createOptions, cacheOption)
You cannot use methods in XAML.


Type: System.IO.Stream

The file stream that identifies the bitmap to decode.

Type: System.Windows.Media.Imaging.BitmapCreateOptions

Identifies the BitmapCreateOptions for this decoder.

Type: System.Windows.Media.Imaging.BitmapCacheOption

Identifies the BitmapCacheOption for this decoder.

Use the OnLoad cache option if you wish to close the bitmapStream after the decoder is created. The default OnDemand cache option retains access to the stream until the bitmap is needed, and cleanup is handled by the garbage collector.

The following example demonstrates how to use the Create method to create a decoder for a given image. The first BitmapFrame of the image is used as the source of an Image control.

Dim imageStream As FileStream = New FileStream("sampleImages/waterlilies.jpg", FileMode.Open, FileAccess.Read, FileShare.Read)

Dim streamBitmap As BitmapDecoder = BitmapDecoder.Create(imageStream, BitmapCreateOptions.None, BitmapCacheOption.Default)

' Create an image element; 
Dim streamImage As New Image()
streamImage.Width = 200
' Set image source using the first frame.
streamImage.Source = streamBitmap.Frames(0)

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