Język

BitmapDecoder.Create Metoda

Definicja

Tworzy obiekt BitmapDecoder przy użyciu określonych BitmapCreateOptions wartości i BitmapCacheOption.

Przeciążenia

Nazwa Opis
Create(Stream, BitmapCreateOptions, BitmapCacheOption)

Tworzy element BitmapDecoder na podstawie Stream obiektu przy użyciu określonych BitmapCreateOptions wartości i BitmapCacheOption.

Create(Uri, BitmapCreateOptions, BitmapCacheOption)

Tworzy element BitmapDecoder na podstawie Uri obiektu przy użyciu określonych BitmapCreateOptions wartości i BitmapCacheOption.

Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy)

Tworzy element BitmapDecoder na podstawie Uri obiektu przy użyciu określonych BitmapCreateOptionswartości i BitmapCacheOptionRequestCachePolicy .

Create(Stream, BitmapCreateOptions, BitmapCacheOption)

Tworzy element BitmapDecoder na podstawie Stream obiektu przy użyciu określonych BitmapCreateOptions wartości i 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

Parametry

bitmapStream
Stream

Strumień plików identyfikujący mapę bitową do dekodowania.

createOptions
BitmapCreateOptions

Określa dla tego dekodera BitmapCreateOptions .

cacheOption
BitmapCacheOption

Określa dla tego dekodera BitmapCacheOption .

Zwraca

A BitmapDecoder z Stream obiektu przy użyciu określonych BitmapCreateOptions wartości i BitmapCacheOption.

Przykłady

W poniższym przykładzie pokazano, jak za pomocą Create metody utworzyć dekoder dla danego obrazu. Pierwszy BitmapFrame z obrazów jest używany jako źródło kontrolki Image .

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)

Uwagi

OnLoad Użyj opcji pamięci podręcznej, jeśli chcesz zamknąć bitmapStream po utworzeniu dekodera. Domyślna OnDemand opcja pamięci podręcznej zachowuje dostęp do strumienia do momentu, gdy mapa bitowa będzie potrzebna, a czyszczenie jest obsługiwane przez moduł odśmiecanie pamięci.

Zobacz też

Dotyczy

Create(Uri, BitmapCreateOptions, BitmapCacheOption)

Tworzy element BitmapDecoder na podstawie Uri obiektu przy użyciu określonych BitmapCreateOptions wartości i 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

Parametry

bitmapUri
Uri

Mapa Uri bitowa do dekodowania.

createOptions
BitmapCreateOptions

Określa dla tego dekodera BitmapCreateOptions .

cacheOption
BitmapCacheOption

Określa dla tego dekodera BitmapCacheOption .

Zwraca

A BitmapDecoder z Uri obiektu przy użyciu określonych BitmapCreateOptions wartości i BitmapCacheOption.

Wyjątki

bitmapUri jest null.

Określa bitmapUri identyfikator klasy nieobsługiwanego typu formatu.

Przykłady

W poniższym przykładzie pokazano, jak za pomocą Create(Uri, BitmapCreateOptions, BitmapCacheOption) metody utworzyć dekoder dla danego obrazu. Pierwszy BitmapFrame z obrazów jest używany jako źródło kontrolki Image .

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)

Zobacz też

Dotyczy

Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy)

Tworzy element BitmapDecoder na podstawie Uri obiektu przy użyciu określonych BitmapCreateOptionswartości i BitmapCacheOptionRequestCachePolicy .

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

Parametry

bitmapUri
Uri

Lokalizacja mapy bitowej, z której jest tworzona BitmapDecoder .

createOptions
BitmapCreateOptions

Opcje używane do utworzenia tego elementu BitmapDecoder.

cacheOption
BitmapCacheOption

Opcja pamięci podręcznej używana do utworzenia tego elementu BitmapDecoder.

uriCachePolicy
RequestCachePolicy

Wymagania dotyczące buforowania dla tego BitmapDecoderelementu .

Zwraca

A BitmapDecoder z Uri obiektu przy użyciu określonej wartości BitmapCreateOptionsi BitmapCacheOptionRequestCachePolicy.

Uwagi

Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy) jest wprowadzana w programie .NET Framework w wersji 3.5.

Dotyczy