BitmapCreateOptions 枚举

定义

指定位图图像的初始化选项。Specifies initialization options for bitmap images.

此枚举有一个 FlagsAttribute 属性,允许按位组合成员值。

public enum class BitmapCreateOptions
[System.Flags]
public enum BitmapCreateOptions
type BitmapCreateOptions = 
Public Enum BitmapCreateOptions
继承
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.

示例

下面的示例演示如何实例化BitmapImageBitmapCreateOptions指定枚举值。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.
bi.BeginInit();

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

// End initialization.
bi.EndInit();
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.
bi.BeginInit()

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

' End initialization.
bi.EndInit()
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.

适用于

另请参阅