語言

BitmapFrame.Create 方法

定義

根據提供的論點建立新的 BitmapFrame 。

多載

名稱 Description
Create(Stream)

從給定BitmapFrame的 創造新的 Stream 。

Create(Uri)

從給定BitmapFrame的 創造新的 Uri 。

Create(BitmapSource)

從給定BitmapFrame的 創造新的 BitmapSource 。

Create(Uri, RequestCachePolicy)

從給定BitmapFrame的 創造 ,Uri且指定的 RequestCachePolicy。

Create(BitmapSource, BitmapSource)

從指定BitmapFrame縮圖中建立新BitmapSource資料。

Create(Stream, BitmapCreateOptions, BitmapCacheOption)

從給定的 產生一個BitmapFrame新 ,且 指定為 StreamBitmapCreateOptions。BitmapCacheOption

Create(Uri, BitmapCreateOptions, BitmapCacheOption)

從給定BitmapFrame且指定UriBitmapCreateOptions且 生成 。BitmapCacheOption

Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy)

從給定BitmapFrame的 創造 ,Uri且 具有指定的 BitmapCreateOptions、 BitmapCacheOption、 RequestCachePolicy和 。

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

從指定縮圖 BitmapFrame、 、 BitmapSource和 建立一個新 BitmapMetadata 。ColorContext

Create(Stream)

從給定BitmapFrame的 創造新的 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

參數

bitmapStream
Stream

Stream用 該 來構造 BitmapFrame。

傳回

BitmapFrame A 來自給定Stream的 。

備註

bitmapStream只有在OnLoad使用快取選項時,才能在框架建立後關閉。 預設 OnDemand 快取選項會保留串流直到需要該幀。 使用該 Create(Stream, BitmapCreateOptions, BitmapCacheOption) 方法來指定建立與快取選項。

適用於

Create(Uri)

從給定BitmapFrame的 創造新的 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

參數

bitmapUri
Uri

該 Uri 即為 的來源 BitmapFrame。

傳回

BitmapFrame A 來自給定Uri的 。

範例

以下程式碼範例示範如何從給定BitmapFrame的 構造 。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)

適用於

Create(BitmapSource)

從給定BitmapFrame的 創造新的 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

參數

source
BitmapSource

用來 BitmapSource 構造此 BitmapFrame的 。

傳回

BitmapFrame A 來自給定BitmapSource的 。

適用於

Create(Uri, RequestCachePolicy)

從給定BitmapFrame的 創造 ,Uri且指定的 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

參數

bitmapUri
Uri

就是建立 的 BitmapFrame 位圖位置。

uriCachePolicy
RequestCachePolicy

此 BitmapFrame快取需求。

傳回

BitmapFrame A 來自給定Uri,且指定RequestCachePolicy為 。

備註

Create(Uri, RequestCachePolicy) 於 .NET Framework 3.5 版本中引入。 欲了解更多資訊,請參閱 版本與相依關係。

適用於

Create(BitmapSource, BitmapSource)

從指定BitmapFrame縮圖中建立新BitmapSource資料。

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

參數

source
BitmapSource

是建構 的 BitmapFrame 來源。

thumbnail
BitmapSource

結果 BitmapFrame的縮圖圖。

傳回

BitmapFrame A 來自給定BitmapSource的指定縮圖。

適用於

Create(Stream, BitmapCreateOptions, BitmapCacheOption)

從給定的 產生一個BitmapFrame新 ,且 指定為 StreamBitmapCreateOptions。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

參數

bitmapStream
Stream

這條溪流就是從這裡 BitmapFrame 構成的。

createOptions
BitmapCreateOptions

用來創造這個的 BitmapFrame選項。

cacheOption
BitmapCacheOption

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

傳回

從給定BitmapFrame的 A Stream 中,具有指定的 BitmapCreateOptions 和 BitmapCacheOption。

備註

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

適用於

Create(Uri, BitmapCreateOptions, BitmapCacheOption)

從給定BitmapFrame且指定UriBitmapCreateOptions且 生成 。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

參數

bitmapUri
Uri

就是建立 的 BitmapFrame 位圖位置。

createOptions
BitmapCreateOptions

用來創造這個的 BitmapFrame選項。

cacheOption
BitmapCacheOption

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

傳回

從給定的 中 A BitmapFrame 具有指定的 Uri、 和 BitmapCreateOptions。BitmapCacheOption

適用於

Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy)

從給定BitmapFrame的 創造 ,Uri且 具有指定的 BitmapCreateOptions、 BitmapCacheOption、 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

參數

bitmapUri
Uri

就是建立 的 BitmapFrame 位圖位置。

createOptions
BitmapCreateOptions

用來創造這個的 BitmapFrame選項。

cacheOption
BitmapCacheOption

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

uriCachePolicy
RequestCachePolicy

此 BitmapFrame快取需求。

傳回

從給定的 中 A BitmapFrame 具有指定的 Uri、 BitmapCreateOptions、 和 BitmapCacheOption。RequestCachePolicy

備註

Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy) 於 .NET Framework 3.5 版本中引入。 欲了解更多資訊,請參閱 版本與相依關係。

適用於

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

從指定縮圖 BitmapFrame、 、 BitmapSource和 建立一個新 BitmapMetadata 。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

參數

source
BitmapSource

用來 BitmapSource 構造此 BitmapFrame的 。

thumbnail
BitmapSource

結果 BitmapFrame的縮圖圖。

metadata
BitmapMetadata

與此 BitmapFrame關聯的元資料。

colorContexts
ReadOnlyCollection<ColorContext>

與此ColorContext相關聯的物件。BitmapFrame

傳回

BitmapFrame從給定BitmapSource的 A 中取得,且具有指定的縮圖 BitmapMetadata, , ColorContext。

適用於