BitmapDecoder.Create Methode

Definitie

Hiermee maakt u een BitmapDecoder met behulp van de opgegeven BitmapCreateOptions en BitmapCacheOption.

Overloads

Create(Stream, BitmapCreateOptions, BitmapCacheOption)

Hiermee maakt u een BitmapDecoder van een Stream met behulp van de opgegeven BitmapCreateOptions en BitmapCacheOption.

public:
 static System::Windows::Media::Imaging::BitmapDecoder ^ Create(System::IO::Stream ^ bitmapStream, System::Windows::Media::Imaging::BitmapCreateOptions createOptions, System::Windows::Media::Imaging::BitmapCacheOption cacheOption);
public static System.Windows.Media.Imaging.BitmapDecoder Create(System.IO.Stream bitmapStream, System.Windows.Media.Imaging.BitmapCreateOptions createOptions, System.Windows.Media.Imaging.BitmapCacheOption cacheOption);
static member Create : System.IO.Stream * System.Windows.Media.Imaging.BitmapCreateOptions * System.Windows.Media.Imaging.BitmapCacheOption -> System.Windows.Media.Imaging.BitmapDecoder
Public Shared Function Create (bitmapStream As Stream, createOptions As BitmapCreateOptions, cacheOption As BitmapCacheOption) As BitmapDecoder

Parameters

bitmapStream
Stream

De bestandsstroom waarmee de bitmap wordt geïdentificeerd om te decoderen.

createOptions
BitmapCreateOptions

Identificeert de BitmapCreateOptions voor deze decoder.

cacheOption
BitmapCacheOption

Identificeert de BitmapCacheOption voor deze decoder.

Retouren

Een BitmapDecoder van een Stream met behulp van de opgegeven BitmapCreateOptions en BitmapCacheOption.

Voorbeelden

In het volgende voorbeeld ziet u hoe u de Create methode gebruikt om een decoder voor een bepaalde afbeelding te maken. De eerste BitmapFrame van de afbeelding wordt gebruikt als de bron van een Image besturingselement.

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];
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)

Opmerkingen

Gebruik de OnLoad cacheoptie als u de bitmapStream decoder wilt sluiten nadat de decoder is gemaakt. De standaardcacheoptie OnDemand behoudt de toegang tot de stream totdat de bitmap nodig is en het opschonen wordt verwerkt door de garbagecollector.

Zie ook

Van toepassing op

Create(Uri, BitmapCreateOptions, BitmapCacheOption)

Hiermee maakt u een BitmapDecoder van een Uri met behulp van de opgegeven BitmapCreateOptions en BitmapCacheOption.

public:
 static System::Windows::Media::Imaging::BitmapDecoder ^ Create(Uri ^ bitmapUri, System::Windows::Media::Imaging::BitmapCreateOptions createOptions, System::Windows::Media::Imaging::BitmapCacheOption cacheOption);
public static System.Windows.Media.Imaging.BitmapDecoder Create(Uri bitmapUri, System.Windows.Media.Imaging.BitmapCreateOptions createOptions, System.Windows.Media.Imaging.BitmapCacheOption cacheOption);
static member Create : Uri * System.Windows.Media.Imaging.BitmapCreateOptions * System.Windows.Media.Imaging.BitmapCacheOption -> System.Windows.Media.Imaging.BitmapDecoder
Public Shared Function Create (bitmapUri As Uri, createOptions As BitmapCreateOptions, cacheOption As BitmapCacheOption) As BitmapDecoder

Parameters

bitmapUri
Uri

De Uri bitmap die moet worden gedecodeerd.

createOptions
BitmapCreateOptions

Identificeert de BitmapCreateOptions voor deze decoder.

cacheOption
BitmapCacheOption

Identificeert de BitmapCacheOption voor deze decoder.

Retouren

Een BitmapDecoder van een Uri met behulp van de opgegeven BitmapCreateOptions en BitmapCacheOption.

Uitzonderingen

De bitmapUri is null.

Hiermee bitmapUri geeft u een klasse-id op van een niet-ondersteund indelingstype.

Voorbeelden

In het volgende voorbeeld ziet u hoe u de Create(Uri, BitmapCreateOptions, BitmapCacheOption) methode gebruikt om een decoder voor een bepaalde afbeelding te maken. De eerste BitmapFrame van de afbeelding wordt gebruikt als de bron van een Image besturingselement.

BitmapDecoder uriBitmap = BitmapDecoder.Create(
   new Uri("sampleImages/waterlilies.jpg", UriKind.Relative),
   BitmapCreateOptions.None,
   BitmapCacheOption.Default);

// Create an image element;
Image uriImage = new Image();
uriImage.Width = 200;
// Set image source.
uriImage.Source = uriBitmap.Frames[0];
Dim uriBitmap As BitmapDecoder = BitmapDecoder.Create(New Uri("sampleImages/waterlilies.jpg", UriKind.Relative), BitmapCreateOptions.None, BitmapCacheOption.Default)

' Create an image element;
Dim uriImage As New Image()
uriImage.Width = 200
' Set image source.
uriImage.Source = uriBitmap.Frames(0)

Zie ook

Van toepassing op

Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy)

Hiermee maakt u een BitmapDecoder van een Uri met behulp van de opgegeven BitmapCreateOptions, BitmapCacheOption en RequestCachePolicy.

public:
 static System::Windows::Media::Imaging::BitmapDecoder ^ Create(Uri ^ bitmapUri, System::Windows::Media::Imaging::BitmapCreateOptions createOptions, System::Windows::Media::Imaging::BitmapCacheOption cacheOption, System::Net::Cache::RequestCachePolicy ^ uriCachePolicy);
public static System.Windows.Media.Imaging.BitmapDecoder Create(Uri bitmapUri, System.Windows.Media.Imaging.BitmapCreateOptions createOptions, System.Windows.Media.Imaging.BitmapCacheOption cacheOption, System.Net.Cache.RequestCachePolicy uriCachePolicy);
static member Create : Uri * System.Windows.Media.Imaging.BitmapCreateOptions * System.Windows.Media.Imaging.BitmapCacheOption * System.Net.Cache.RequestCachePolicy -> System.Windows.Media.Imaging.BitmapDecoder
Public Shared Function Create (bitmapUri As Uri, createOptions As BitmapCreateOptions, cacheOption As BitmapCacheOption, uriCachePolicy As RequestCachePolicy) As BitmapDecoder

Parameters

bitmapUri
Uri

De locatie van de bitmap waaruit de BitmapDecoder bitmap is gemaakt.

createOptions
BitmapCreateOptions

De opties die worden gebruikt om dit BitmapDecoderte maken.

cacheOption
BitmapCacheOption

De cacheoptie die wordt gebruikt om deze BitmapDecoderte maken.

uriCachePolicy
RequestCachePolicy

De cachevereisten hiervoor BitmapDecoder.

Retouren

Een BitmapDecoder van een Uri met behulp van de opgegeven BitmapCreateOptions, BitmapCacheOption en RequestCachePolicy.

Opmerkingen

Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy) wordt geïntroduceerd in de .NET Framework versie 3.5.

Van toepassing op