Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.
This topic has not yet been rated - Rate this topic

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 static BitmapDecoder Create (
	Stream bitmapStream,
	BitmapCreateOptions createOptions,
	BitmapCacheOption cacheOption
)
public static BitmapDecoder Create (
	Stream bitmapStream, 
	BitmapCreateOptions createOptions, 
	BitmapCacheOption cacheOption
)
public static function Create (
	bitmapStream : Stream, 
	createOptions : BitmapCreateOptions, 
	cacheOption : BitmapCacheOption
) : BitmapDecoder
You cannot use methods in XAML.

Parameters

bitmapStream

The file stream that identifies the bitmap to decode.

createOptions

Identifies the BitmapCreateOptions for this decoder.

cacheOption

Identifies the BitmapCacheOption for this decoder.

Return Value

A new BitmapDecoder.

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.

Stream imageStream = new FileStream("sampleImages/waterlilies.jpg",
   FileMode.Open, FileAccess.Read, FileShare.Read);

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

// Create an image element;
Image streamImage = new Image();
streamImage.Width = 200;
// Set image source using the first frame.
streamImage.Source = streamBitmap.Frames[0];

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0
Did you find this helpful?
(1500 characters remaining)

Community Additions

© 2013 Microsoft. All rights reserved.