BitmapFrame.Create Metod

Definition

Skapar en ny BitmapFrame baserat på de angivna argumenten.

Överlagringar

Name Description
Create(Stream)

Skapar en ny BitmapFrame från en viss Stream.

Create(Uri)

Skapar en ny BitmapFrame från en viss Uri.

Create(BitmapSource)

Skapar en ny BitmapFrame från en viss BitmapSource.

Create(Uri, RequestCachePolicy)

Skapar en BitmapFrame från en given Uri med angiven RequestCachePolicy.

Create(BitmapSource, BitmapSource)

Skapar en ny BitmapFrame från en given BitmapSource med den angivna miniatyrbilden.

Create(Stream, BitmapCreateOptions, BitmapCacheOption)

Skapar en ny BitmapFrame från en given Stream med angivet BitmapCreateOptions och BitmapCacheOption.

Create(Uri, BitmapCreateOptions, BitmapCacheOption)

Skapar en BitmapFrame från en given Uri med angivet BitmapCreateOptions och BitmapCacheOption.

Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy)

Skapar en BitmapFrame från en given Uri med angiven BitmapCreateOptions, BitmapCacheOptionoch RequestCachePolicy.

Create(BitmapSource, BitmapSource, BitmapMetadata, ReadOnlyCollection<ColorContext>)

Skapar en ny BitmapFrame från en given BitmapSource med den angivna miniatyrbilden, BitmapMetadata, och ColorContext.

Create(Stream)

Skapar en ny BitmapFrame från en viss Stream.

public:
 static System::Windows::Media::Imaging::BitmapFrame ^ Create(System::IO::Stream ^ bitmapStream);
public static System.Windows.Media.Imaging.BitmapFrame Create(System.IO.Stream bitmapStream);
static member Create : System.IO.Stream -> System.Windows.Media.Imaging.BitmapFrame
Public Shared Function Create (bitmapStream As Stream) As BitmapFrame

Parametrar

bitmapStream
Stream

Som Stream används för att konstruera BitmapFrame.

Returer

A BitmapFrame från en viss Stream.

Kommentarer

bitmapStream Kan stängas när ramen har skapats endast när cachealternativet OnLoad används. Standardalternativet OnDemand cache behåller strömmen tills ramen behövs. Create(Stream, BitmapCreateOptions, BitmapCacheOption) Använd metoden för att ange alternativ för att skapa och cachelagrat.

Gäller för

Create(Uri)

Skapar en ny BitmapFrame från en viss Uri.

public:
 static System::Windows::Media::Imaging::BitmapFrame ^ Create(Uri ^ bitmapUri);
public static System.Windows.Media.Imaging.BitmapFrame Create(Uri bitmapUri);
static member Create : Uri -> System.Windows.Media.Imaging.BitmapFrame
Public Shared Function Create (bitmapUri As Uri) As BitmapFrame

Parametrar

bitmapUri
Uri

Det Uri som identifierar källan till BitmapFrame.

Returer

A BitmapFrame från en viss Uri.

Exempel

Följande kodexempel visar hur du skapar en BitmapFrame från en viss Uri.

int width = 128;
int height = width;
int stride = width/8;
byte[] pixels = new byte[height*stride];

// Try creating a new image with a custom palette.
List<System.Windows.Media.Color> colors = new List<System.Windows.Media.Color>();
colors.Add(System.Windows.Media.Colors.Red);
colors.Add(System.Windows.Media.Colors.Blue);
colors.Add(System.Windows.Media.Colors.Green);
BitmapPalette myPalette = new BitmapPalette(colors);

// Creates a new empty image with the pre-defined palette

BitmapSource image = BitmapSource.Create(
    width,
    height,
    96,
    96,
    PixelFormats.Indexed1,
    myPalette, 
    pixels, 
    stride);

FileStream stream = new FileStream("empty.tif", FileMode.Create);
TiffBitmapEncoder encoder = new TiffBitmapEncoder();
TextBlock myTextBlock = new TextBlock();
myTextBlock.Text = "Codec Author is: " + encoder.CodecInfo.Author.ToString();
encoder.Frames.Add(BitmapFrame.Create(image));
MessageBox.Show(myPalette.Colors.Count.ToString());
encoder.Save(stream);
Dim width As Integer = 128
Dim height As Integer = width
Dim stride As Integer = CType(width / 8, Integer)
Dim pixels(height * stride) As Byte

' Try creating a new image with a custom palette.
Dim colors As New List(Of System.Windows.Media.Color)()
colors.Add(System.Windows.Media.Colors.Red)
colors.Add(System.Windows.Media.Colors.Blue)
colors.Add(System.Windows.Media.Colors.Green)
Dim myPalette As New BitmapPalette(colors)

' Creates a new empty image with the pre-defined palette
Dim image As BitmapSource = System.Windows.Media.Imaging.BitmapSource.Create(width, height, 96, 96, PixelFormats.Indexed1, myPalette, pixels, stride)
Dim stream As New FileStream("empty.tif", FileMode.Create)
Dim encoder As New TiffBitmapEncoder()
Dim myTextBlock As New TextBlock()
myTextBlock.Text = "Codec Author is: " + encoder.CodecInfo.Author.ToString()
encoder.Frames.Add(BitmapFrame.Create(image))
MessageBox.Show(myPalette.Colors.Count.ToString())
encoder.Save(stream)

Gäller för

Create(BitmapSource)

Skapar en ny BitmapFrame från en viss BitmapSource.

public:
 static System::Windows::Media::Imaging::BitmapFrame ^ Create(System::Windows::Media::Imaging::BitmapSource ^ source);
public static System.Windows.Media.Imaging.BitmapFrame Create(System.Windows.Media.Imaging.BitmapSource source);
static member Create : System.Windows.Media.Imaging.BitmapSource -> System.Windows.Media.Imaging.BitmapFrame
Public Shared Function Create (source As BitmapSource) As BitmapFrame

Parametrar

source
BitmapSource

Det BitmapSource som används för att konstruera den här BitmapFrame.

Returer

A BitmapFrame från en viss BitmapSource.

Gäller för

Create(Uri, RequestCachePolicy)

Skapar en BitmapFrame från en given Uri med angiven RequestCachePolicy.

public:
 static System::Windows::Media::Imaging::BitmapFrame ^ Create(Uri ^ bitmapUri, System::Net::Cache::RequestCachePolicy ^ uriCachePolicy);
public static System.Windows.Media.Imaging.BitmapFrame Create(Uri bitmapUri, System.Net.Cache.RequestCachePolicy uriCachePolicy);
static member Create : Uri * System.Net.Cache.RequestCachePolicy -> System.Windows.Media.Imaging.BitmapFrame
Public Shared Function Create (bitmapUri As Uri, uriCachePolicy As RequestCachePolicy) As BitmapFrame

Parametrar

bitmapUri
Uri

Platsen för bitmappen BitmapFrame som skapas från.

uriCachePolicy
RequestCachePolicy

Cachelagringskraven för den här BitmapFrame.

Returer

A BitmapFrame från en given Uri med angiven RequestCachePolicy.

Kommentarer

Create(Uri, RequestCachePolicy) introduceras i .NET Framework version 3.5. Mer information finns i Versioner och beroenden.

Gäller för

Create(BitmapSource, BitmapSource)

Skapar en ny BitmapFrame från en given BitmapSource med den angivna miniatyrbilden.

public:
 static System::Windows::Media::Imaging::BitmapFrame ^ Create(System::Windows::Media::Imaging::BitmapSource ^ source, System::Windows::Media::Imaging::BitmapSource ^ thumbnail);
public static System.Windows.Media.Imaging.BitmapFrame Create(System.Windows.Media.Imaging.BitmapSource source, System.Windows.Media.Imaging.BitmapSource thumbnail);
static member Create : System.Windows.Media.Imaging.BitmapSource * System.Windows.Media.Imaging.BitmapSource -> System.Windows.Media.Imaging.BitmapFrame
Public Shared Function Create (source As BitmapSource, thumbnail As BitmapSource) As BitmapFrame

Parametrar

source
BitmapSource

Källan som BitmapFrame är konstruerad från.

thumbnail
BitmapSource

En miniatyrbild av den resulterande BitmapFrame.

Returer

A BitmapFrame från en given BitmapSource med den angivna miniatyrbilden.

Gäller för

Create(Stream, BitmapCreateOptions, BitmapCacheOption)

Skapar en ny BitmapFrame från en given Stream med angivet BitmapCreateOptions och BitmapCacheOption.

public:
 static System::Windows::Media::Imaging::BitmapFrame ^ Create(System::IO::Stream ^ bitmapStream, System::Windows::Media::Imaging::BitmapCreateOptions createOptions, System::Windows::Media::Imaging::BitmapCacheOption cacheOption);
public static System.Windows.Media.Imaging.BitmapFrame 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.BitmapFrame
Public Shared Function Create (bitmapStream As Stream, createOptions As BitmapCreateOptions, cacheOption As BitmapCacheOption) As BitmapFrame

Parametrar

bitmapStream
Stream

Dataströmmen som det här BitmapFrame är konstruerat från.

createOptions
BitmapCreateOptions

De alternativ som används för att skapa den här BitmapFrame.

cacheOption
BitmapCacheOption

Cachealternativet som används för att skapa den här BitmapFrame.

Returer

A BitmapFrame från en given Stream med angivet BitmapCreateOptions och BitmapCacheOption.

Kommentarer

Använd cachealternativet OnLoad om du vill stänga bitmapStream när bitmappen har skapats. Standardalternativet OnDemand cache behåller åtkomsten till dataströmmen tills bitmappen behövs och rensningen hanteras av skräpinsamlaren.

Gäller för

Create(Uri, BitmapCreateOptions, BitmapCacheOption)

Skapar en BitmapFrame från en given Uri med angivet BitmapCreateOptions och BitmapCacheOption.

public:
 static System::Windows::Media::Imaging::BitmapFrame ^ Create(Uri ^ bitmapUri, System::Windows::Media::Imaging::BitmapCreateOptions createOptions, System::Windows::Media::Imaging::BitmapCacheOption cacheOption);
public static System.Windows.Media.Imaging.BitmapFrame 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.BitmapFrame
Public Shared Function Create (bitmapUri As Uri, createOptions As BitmapCreateOptions, cacheOption As BitmapCacheOption) As BitmapFrame

Parametrar

bitmapUri
Uri

Platsen för bitmappen BitmapFrame som skapas från.

createOptions
BitmapCreateOptions

De alternativ som används för att skapa den här BitmapFrame.

cacheOption
BitmapCacheOption

Cachealternativet som används för att skapa den här BitmapFrame.

Returer

A BitmapFrame från en given Uri med angiven BitmapCreateOptions, och BitmapCacheOption.

Gäller för

Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy)

Skapar en BitmapFrame från en given Uri med angiven BitmapCreateOptions, BitmapCacheOptionoch RequestCachePolicy.

public:
 static System::Windows::Media::Imaging::BitmapFrame ^ 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.BitmapFrame 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.BitmapFrame
Public Shared Function Create (bitmapUri As Uri, createOptions As BitmapCreateOptions, cacheOption As BitmapCacheOption, uriCachePolicy As RequestCachePolicy) As BitmapFrame

Parametrar

bitmapUri
Uri

Platsen för bitmappen BitmapFrame som skapas från.

createOptions
BitmapCreateOptions

De alternativ som används för att skapa den här BitmapFrame.

cacheOption
BitmapCacheOption

Cachealternativet som används för att skapa den här BitmapFrame.

uriCachePolicy
RequestCachePolicy

Cachelagringskraven för den här BitmapFrame.

Returer

A BitmapFrame från en given Uri med angiven BitmapCreateOptions, BitmapCacheOption, och RequestCachePolicy.

Kommentarer

Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy) introduceras i .NET Framework version 3.5. Mer information finns i Versioner och beroenden.

Gäller för

Create(BitmapSource, BitmapSource, BitmapMetadata, ReadOnlyCollection<ColorContext>)

Skapar en ny BitmapFrame från en given BitmapSource med den angivna miniatyrbilden, BitmapMetadata, och ColorContext.

public:
 static System::Windows::Media::Imaging::BitmapFrame ^ Create(System::Windows::Media::Imaging::BitmapSource ^ source, System::Windows::Media::Imaging::BitmapSource ^ thumbnail, System::Windows::Media::Imaging::BitmapMetadata ^ metadata, System::Collections::ObjectModel::ReadOnlyCollection<System::Windows::Media::ColorContext ^> ^ colorContexts);
public static System.Windows.Media.Imaging.BitmapFrame Create(System.Windows.Media.Imaging.BitmapSource source, System.Windows.Media.Imaging.BitmapSource thumbnail, System.Windows.Media.Imaging.BitmapMetadata metadata, System.Collections.ObjectModel.ReadOnlyCollection<System.Windows.Media.ColorContext> colorContexts);
static member Create : System.Windows.Media.Imaging.BitmapSource * System.Windows.Media.Imaging.BitmapSource * System.Windows.Media.Imaging.BitmapMetadata * System.Collections.ObjectModel.ReadOnlyCollection<System.Windows.Media.ColorContext> -> System.Windows.Media.Imaging.BitmapFrame
Public Shared Function Create (source As BitmapSource, thumbnail As BitmapSource, metadata As BitmapMetadata, colorContexts As ReadOnlyCollection(Of ColorContext)) As BitmapFrame

Parametrar

source
BitmapSource

Det BitmapSource som används för att konstruera den här BitmapFrame.

thumbnail
BitmapSource

En miniatyrbild av den resulterande BitmapFrame.

metadata
BitmapMetadata

Metadata som ska associeras med den här BitmapFrame.

colorContexts
ReadOnlyCollection<ColorContext>

De ColorContext objekt som är associerade med den här BitmapFrame.

Returer

A BitmapFrame från en given BitmapSource med den angivna miniatyrbilden, BitmapMetadata, och ColorContext.

Gäller för