BitmapCreateOptions 列舉


指定點陣圖影像的初始設定選項。Specifies initialization options for bitmap images.

此列舉具有 FlagsAttribute 個屬性允許以位元方式合併其成員值。

public enum class BitmapCreateOptions
public enum BitmapCreateOptions
type BitmapCreateOptions = 
Public Enum BitmapCreateOptions


DelayCreation 2

造成 BitmapSource 物件延遲初始設定,直到必要時才開始進行。Causes a BitmapSource object to delay initialization until it is necessary. 處理影像集合時,這會很實用。This is useful when dealing with collections of images.

IgnoreColorProfile 4

造成 BitmapSource 忽略內嵌色彩設定檔。Causes a BitmapSource to ignore an embedded color profile.

IgnoreImageCache 8

載入影像時未使用現有的影像快取。Loads images without using an existing image cache. 只有在快取中的影像需要重新整理時,才應該選取此選項。This option should only be selected when images in a cache need to be refreshed.

None 0

不指定 BitmapCreateOptionsNo BitmapCreateOptions are specified. 此為預設值。This is the default value.

PreservePixelFormat 1

確保儲存和載入檔案所用的 PixelFormat 相同。Ensures that the PixelFormat a file is stored in is the same as it is loaded to.


下列範例示範如何具現化BitmapImage , 並BitmapCreateOptions指定列舉值。The following example demonstrates how to instantiate a BitmapImage and specify a BitmapCreateOptions enumeration value.

// Define a BitmapImage.
Image myImage = new Image();
BitmapImage bi = new BitmapImage();

// Begin initialization.

// Set properties.
bi.CacheOption = BitmapCacheOption.OnDemand;
bi.CreateOptions = BitmapCreateOptions.DelayCreation;
bi.DecodePixelHeight = 125;
bi.DecodePixelWidth = 125;
bi.Rotation = Rotation.Rotate90;
bi.UriSource = new Uri("smiley.png", UriKind.Relative);

// End initialization.
myImage.Source = bi;
myImage.Stretch = Stretch.None;
myImage.Margin = new Thickness(5);
' Define a BitmapImage.
Dim myImage As New Image()
Dim bi As New BitmapImage()

' Begin initialization.

' Set properties.
bi.CacheOption = BitmapCacheOption.OnDemand
bi.CreateOptions = BitmapCreateOptions.DelayCreation
bi.DecodePixelHeight = 125
bi.DecodePixelWidth = 125
bi.Rotation = Rotation.Rotate90
bi.UriSource = New Uri("smiley.png", UriKind.Relative)

' End initialization.
myImage.Source = bi
myImage.Stretch = Stretch.None
myImage.Margin = New Thickness(5)


如果PreservePixelFormat未設定PixelFormat , 系統會根據系統所判斷的結果來選擇影像的, 以產生最佳效能。If PreservePixelFormat is not set, the PixelFormat of the image is chosen by the system depending on what the system determines will yield the best performance. 啟用此選項會保留檔案格式, 但可能會導致較低的效能。Enabling this option preserves the file format but may result in lesser performance.

如果IgnoreColorProfile設定, 則對CopyPixels(Array, Int32, Int32)等方法的呼叫將不會傳回顏色更正的位。If IgnoreColorProfile is set, calls to methods such as CopyPixels(Array, Int32, Int32) will not return color-corrected bits.

如果IgnoreImageCache設定, 則會取代影像快取中的任何現有專案, 即使它們共用相同Uri的也一樣。If IgnoreImageCache is set, any existing entries in the image cache are replaced even if they share the same Uri.