BitmapCacheOption Enumeración

Definición

Especifica cómo una imagen de mapa de bits aprovecha el almacenamiento en caché de memoria.

public enum class BitmapCacheOption
public enum BitmapCacheOption
type BitmapCacheOption = 
Public Enum BitmapCacheOption
Herencia
BitmapCacheOption

Campos

Nombre Valor Description
Default 0

Almacena en caché toda la imagen en la memoria. Este es el valor predeterminado.

OnDemand 0

Crea un almacén de memoria solo para los datos solicitados. La primera solicitud carga la imagen directamente; Las solicitudes posteriores se rellenan desde la memoria caché.

OnLoad 1

Almacena en caché toda la imagen en memoria en tiempo de carga. Todas las solicitudes de datos de imagen se rellenan desde el almacén de memoria.

None 2

No cree un almacén de memoria. El archivo de imagen rellena directamente todas las solicitudes de la imagen.

Ejemplos

En el ejemplo de código siguiente se muestra cómo cargar y BitmapImage especificar .BitmapCacheOption

// 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)

Se aplica a

Consulte también