BitmapDecoder.Create Метод

Определение

Создает BitmapDecoder с использованием заданных BitmapCreateOptions и BitmapCacheOption.

Перегрузки

Create(Stream, BitmapCreateOptions, BitmapCacheOption)

Создает BitmapDecoder из Stream с использованием заданных BitmapCreateOptions и BitmapCacheOption.

Create(Uri, BitmapCreateOptions, BitmapCacheOption)

Создает BitmapDecoder из Uri с использованием заданных BitmapCreateOptions и BitmapCacheOption.

Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy)

Создает BitmapDecoder из Uri с использованием заданных BitmapCreateOptions, BitmapCacheOption и RequestCachePolicy.

Create(Stream, BitmapCreateOptions, BitmapCacheOption)

Создает BitmapDecoder из Stream с использованием заданных 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 из 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 с использованием заданных 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 из Uri с использованием заданных BitmapCreateOptions и BitmapCacheOption.

Исключения

Значение параметра bitmapUrinull.

bitmapUri задает ИД класса неподдерживаемого типа формата.

Примеры

В следующем примере показано, как использовать 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)

Создает BitmapDecoder из 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 из Uri с использованием заданных BitmapCreateOptions, BitmapCacheOption и RequestCachePolicy.

Комментарии

Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy)представлен в платформа .NET Framework версии 3.5.

Применяется к