BitmapDecoder.Create Méthode

Définition

Crée un BitmapDecoder à l’aide de l’élément spécifié BitmapCreateOptions et BitmapCacheOption.

Surcharges

Nom Description
Create(Stream, BitmapCreateOptions, BitmapCacheOption)

Crée un à partir d’un BitmapDecoderStream à l’aide de l’élément spécifié BitmapCreateOptions et BitmapCacheOption.

Create(Uri, BitmapCreateOptions, BitmapCacheOption)

Crée un à partir d’un BitmapDecoderUri à l’aide de l’élément spécifié BitmapCreateOptions et BitmapCacheOption.

Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy)

Crée un à partir d’un BitmapDecoderUri à l’aide de l’élément spécifié BitmapCreateOptionset BitmapCacheOptionRequestCachePolicy.

Create(Stream, BitmapCreateOptions, BitmapCacheOption)

Crée un à partir d’un BitmapDecoderStream à l’aide de l’élément spécifié BitmapCreateOptions et 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

Paramètres

bitmapStream
Stream

Flux de fichiers qui identifie la bitmap à décoder.

createOptions
BitmapCreateOptions

Identifie le BitmapCreateOptions décodeur pour ce décodeur.

cacheOption
BitmapCacheOption

Identifie le BitmapCacheOption décodeur pour ce décodeur.

Retours

A BitmapDecoder à partir d’un Stream à l’aide de l’élément spécifié BitmapCreateOptions et BitmapCacheOption.

Exemples

L’exemple suivant montre comment utiliser la Create méthode pour créer un décodeur pour une image donnée. La première BitmapFrame de l’image est utilisée comme source d’un Image contrôle.

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)

Remarques

Utilisez l’option de OnLoad cache si vous souhaitez fermer la bitmapStream fermeture après la création du décodeur. L’option de cache par défaut OnDemand conserve l’accès au flux jusqu’à ce que la bitmap soit nécessaire et que le nettoyage soit géré par le garbage collector.

Voir aussi

S’applique à

Create(Uri, BitmapCreateOptions, BitmapCacheOption)

Crée un à partir d’un BitmapDecoderUri à l’aide de l’élément spécifié BitmapCreateOptions et 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

Paramètres

bitmapUri
Uri

De Uri la bitmap à décoder.

createOptions
BitmapCreateOptions

Identifie le BitmapCreateOptions décodeur pour ce décodeur.

cacheOption
BitmapCacheOption

Identifie le BitmapCacheOption décodeur pour ce décodeur.

Retours

A BitmapDecoder à partir d’un Uri à l’aide de l’élément spécifié BitmapCreateOptions et BitmapCacheOption.

Exceptions

bitmapUri a la valeur null.

Spécifie bitmapUri un ID de classe d’un type de format non pris en charge.

Exemples

L’exemple suivant montre comment utiliser la Create(Uri, BitmapCreateOptions, BitmapCacheOption) méthode pour créer un décodeur pour une image donnée. La première BitmapFrame de l’image est utilisée comme source d’un Image contrôle.

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)

Voir aussi

S’applique à

Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy)

Crée un à partir d’un BitmapDecoderUri à l’aide de l’élément spécifié BitmapCreateOptionset 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

Paramètres

bitmapUri
Uri

Emplacement de la bitmap à partir de laquelle le BitmapDecoder fichier est créé.

createOptions
BitmapCreateOptions

Options utilisées pour créer ce BitmapDecoderfichier .

cacheOption
BitmapCacheOption

Option de cache utilisée pour créer ce BitmapDecoderfichier .

uriCachePolicy
RequestCachePolicy

Conditions de mise en cache requises pour cela BitmapDecoder.

Retours

A BitmapDecoder à partir d’un Uri à l’aide de l’élément spécifié BitmapCreateOptions, BitmapCacheOption et RequestCachePolicy.

Remarques

Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy) est introduit dans .NET Framework version 3.5.

S’applique à