BitmapCreateOptions 枚举

定义

指定位图图像的初始化选项。

此枚举支持其成员值的按位组合。

public enum class BitmapCreateOptions
[System.Flags]
public enum BitmapCreateOptions
[<System.Flags>]
type BitmapCreateOptions = 
Public Enum BitmapCreateOptions
继承
BitmapCreateOptions
属性

字段

名称 说明
None 0

BitmapCreateOptions 指定任何值。 这是默认值。

PreservePixelFormat 1

确保 PixelFormat 文件存储在其中与加载到的文件相同。

DelayCreation 2

BitmapSource使对象延迟初始化,直到有必要。 处理图像集合时,这非常有用。

IgnoreColorProfile 4

BitmapSource导致忽略嵌入的颜色配置文件。

IgnoreImageCache 8

在不使用现有映像缓存的情况下加载映像。 仅当缓存中的图像需要刷新时,才应选择此选项。

示例

以下示例演示如何实例化 BitmapImage 和指定 BitmapCreateOptions 枚举值。

// 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 系统会根据系统确定的内容选择映像,从而产生最佳性能。 启用此选项会保留文件格式,但可能会导致性能降低。

如果 IgnoreColorProfile 已设置,则调用方法(如 CopyPixels(Array, Int32, Int32) 不会返回颜色更正的位)。

如果 IgnoreImageCache 已设置,即使映像缓存中的任何现有条目共享相同 Uri,也会替换这些条目。

适用于

另请参阅