語言

BitmapDecoder.Create 方法

定義

利用指定的 BitmapDecoder 和 BitmapCreateOptions來建立 。BitmapCacheOption

多載

Create(Stream, BitmapCreateOptions, BitmapCacheOption)

利用指定的 BitmapDecoder 和 Stream從 a BitmapCreateOptions 生成 。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

參數

bitmapStream
Stream

識別要解碼的位圖檔案串流。

createOptions
BitmapCreateOptions

識別此解碼器的 。BitmapCreateOptions

cacheOption
BitmapCacheOption

識別此解碼器的 。BitmapCacheOption

傳回

BitmapDecoder A 從 a Stream 透過指定的 BitmapCreateOptions 和 BitmapCacheOption。

範例

以下範例示範如何使用此 Create 方法為特定影像建立解碼器。 第一 BitmapFrame 張影像作為對照的來源 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)

備註

如果你想在解碼器建立後關閉快OnLoad取,可以使用bitmapStream快取選項。 預設 OnDemand 快取選項保留對串流的存取權,直到需要位圖,清理則由垃圾回收器處理。

另請參閱

適用於

Create(Uri, BitmapCreateOptions, BitmapCacheOption)

利用指定的 BitmapDecoder 和 Uri從 a BitmapCreateOptions 生成 。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

參數

bitmapUri
Uri

解碼點陣圖的部分 Uri 。

createOptions
BitmapCreateOptions

識別此解碼器的 。BitmapCreateOptions

cacheOption
BitmapCacheOption

識別此解碼器的 。BitmapCacheOption

傳回

BitmapDecoder A 從 a Uri 透過指定的 BitmapCreateOptions 和 BitmapCacheOption。

例外狀況

bitmapUri 是 null。

該類別 bitmapUri ID 指定了不受支援的格式類型。

範例

以下範例示範如何使用此 Create(Uri, BitmapCreateOptions, BitmapCacheOption) 方法為特定影像建立解碼器。 第一 BitmapFrame 張影像作為對照的來源 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)

另請參閱

適用於

Create(Uri, BitmapCreateOptions, BitmapCacheOption, 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

參數

bitmapUri
Uri

就是建立 的 BitmapDecoder 位圖位置。

createOptions
BitmapCreateOptions

用來創造這個的 BitmapDecoder選項。

cacheOption
BitmapCacheOption

用來建立此 BitmapDecoder的快取選項。

uriCachePolicy
RequestCachePolicy

此 BitmapDecoder快取需求。

傳回

BitmapDecoder A,從aUri中利用指定的BitmapCreateOptionsBitmapCacheOption、和RequestCachePolicy。

備註

Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy) 於 .NET Framework 3.5 版本中引入。

適用於