BitmapDecoder.Create Metod
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Skapar en BitmapDecoder med hjälp av angivet BitmapCreateOptions och BitmapCacheOption.
Överlagringar
| Name | Description |
|---|---|
| Create(Stream, BitmapCreateOptions, BitmapCacheOption) |
Skapar en BitmapDecoder från en Stream med hjälp av angivet BitmapCreateOptions och BitmapCacheOption. |
| Create(Uri, BitmapCreateOptions, BitmapCacheOption) |
Skapar en BitmapDecoder från en Uri med hjälp av angivet BitmapCreateOptions och BitmapCacheOption. |
| Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy) |
Skapar en BitmapDecoder från en Uri med hjälp av angiven BitmapCreateOptions, BitmapCacheOption och RequestCachePolicy. |
Create(Stream, BitmapCreateOptions, BitmapCacheOption)
Skapar en BitmapDecoder från en Stream med hjälp av angivet BitmapCreateOptions och 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
Parametrar
- bitmapStream
- Stream
Den filström som identifierar bitmappen som ska avkodas.
- createOptions
- BitmapCreateOptions
Identifierar BitmapCreateOptions för den här avkodaren.
- cacheOption
- BitmapCacheOption
Identifierar BitmapCacheOption för den här avkodaren.
Returer
A BitmapDecoder från en Stream med hjälp av angivet BitmapCreateOptions och BitmapCacheOption.
Exempel
I följande exempel visas hur du använder Create metoden för att skapa en avkodare för en viss bild. Den första BitmapFrame av bilden används som källa för en Image kontroll.
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)
Kommentarer
Använd cachealternativet OnLoad om du vill stänga bitmapStream när avkodaren har skapats. Standardalternativet OnDemand cache behåller åtkomsten till dataströmmen tills bitmappen behövs och rensningen hanteras av skräpinsamlaren.
Se även
Gäller för
Create(Uri, BitmapCreateOptions, BitmapCacheOption)
Skapar en BitmapDecoder från en Uri med hjälp av angivet BitmapCreateOptions och 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
Parametrar
- createOptions
- BitmapCreateOptions
Identifierar BitmapCreateOptions för den här avkodaren.
- cacheOption
- BitmapCacheOption
Identifierar BitmapCacheOption för den här avkodaren.
Returer
A BitmapDecoder från en Uri med hjälp av angivet BitmapCreateOptions och BitmapCacheOption.
Undantag
bitmapUri är null.
bitmapUri Anger ett klass-ID för en formattyp som inte stöds.
Exempel
I följande exempel visas hur du använder Create(Uri, BitmapCreateOptions, BitmapCacheOption) metoden för att skapa en avkodare för en viss bild. Den första BitmapFrame av bilden används som källa för en Image kontroll.
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)
Se även
Gäller för
Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy)
Skapar en BitmapDecoder från en Uri med hjälp av angiven BitmapCreateOptions, BitmapCacheOption och 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
Parametrar
- bitmapUri
- Uri
Platsen för bitmappen BitmapDecoder som skapas från.
- createOptions
- BitmapCreateOptions
De alternativ som används för att skapa den här BitmapDecoder.
- cacheOption
- BitmapCacheOption
Cachealternativet som används för att skapa den här BitmapDecoder.
- uriCachePolicy
- RequestCachePolicy
Cachelagringskraven för den här BitmapDecoder.
Returer
A BitmapDecoder från en Uri med hjälp av angivna BitmapCreateOptions, BitmapCacheOption och RequestCachePolicy.
Kommentarer
Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy) introduceras i .NET Framework version 3.5.