Share via


BitmapFrame.Create 方法

定義

根據提供的引數建立新的 BitmapFrame

多載

Create(Stream)

使用指定的縮圖、 BitmapFrameStream

Create(Uri)

使用指定的縮圖、 BitmapFrameUri

Create(BitmapSource)

使用指定的縮圖、 BitmapFrameBitmapSource

Create(Uri, RequestCachePolicy)

使用指定的 BitmapFrame,從指定的 Uri 建立 RequestCachePolicy

Create(BitmapSource, BitmapSource)

使用指定的縮圖,從指定的 BitmapFrame 建立新的 BitmapSource

Create(Stream, BitmapCreateOptions, BitmapCacheOption)

使用指定的 BitmapFrameStream,從指定的 BitmapCreateOptions 建立新的 BitmapCacheOption

Create(Uri, BitmapCreateOptions, BitmapCacheOption)

使用指定的 BitmapFrameUri,從指定的 BitmapCreateOptions 建立 BitmapCacheOption

Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy)

使用指定的 BitmapFrameUriBitmapCreateOptions,從指定的 BitmapCacheOption 建立 RequestCachePolicy

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

使用指定的縮圖、BitmapMetadataColorContext,從指定的 BitmapSource 建立新的 BitmapFrame

Create(Stream)

使用指定的縮圖、 BitmapFrameStream

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

用來建構 StreamBitmapFrame

傳回

來自指定之 BitmapFrameStream

備註

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

適用於

Create(Uri)

使用指定的縮圖、 BitmapFrameUri

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 的來源。

傳回

來自指定之 BitmapFrameUri

範例

下列程式碼範例示範如何從指定的 Uri 建構 BitmapFrame

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)

使用指定的縮圖、 BitmapFrameBitmapSource

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

用來建構這個 BitmapFrameBitmapSource

傳回

來自指定之 BitmapFrameBitmapSource

適用於

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,從指定的 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 建立的 BitmapSource

適用於

Create(Stream, BitmapCreateOptions, BitmapCacheOption)

使用指定的 BitmapFrameStream,從指定的 BitmapCreateOptions 建立新的 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 的快取選項。

傳回

使用指定的 BitmapFrameStream,從 BitmapCreateOptions 建立的 BitmapCacheOption

備註

如果您想要在建立點陣圖之後關閉 bitmapStream ,請使用快 OnLoad 取選項。 預設快 OnDemand 取選項會保留資料流程的存取權,直到需要點陣圖,並由垃圾收集行程處理清除為止。

適用於

Create(Uri, BitmapCreateOptions, BitmapCacheOption)

使用指定的 BitmapFrameUri,從指定的 BitmapCreateOptions 建立 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 的快取選項。

傳回

使用指定的 BitmapFrameUri,從 BitmapCreateOptions 建立的 BitmapCacheOption

適用於

Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy)

使用指定的 BitmapFrameUriBitmapCreateOptions,從指定的 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 的快取需求。

傳回

使用指定的 BitmapFrameUriBitmapCreateOptions,從指定的 BitmapCacheOption 建立的 RequestCachePolicy

備註

Create(Uri, BitmapCreateOptions, BitmapCacheOption, RequestCachePolicy).NET Framework 3.5 版引進。 如需詳細資訊,請參閱版本和相依性

適用於

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

使用指定的縮圖、BitmapMetadataColorContext,從指定的 BitmapSource 建立新的 BitmapFrame

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

用來建構這個 BitmapFrameBitmapSource

thumbnail
BitmapSource

產生之 BitmapFrame 的縮圖影像。

metadata
BitmapMetadata

要與這個 BitmapFrame 建立關聯的中繼資料。

colorContexts
ReadOnlyCollection<ColorContext>

與這個 BitmapFrame 相關聯的 ColorContext 物件。

傳回

來自指定之 BitmapSourceBitmapFrame,其具有指定的縮圖、BitmapMetadataColorContext

適用於