Ler en inglés

Compartir por


BitmapCacheOption Enumeración

Definición

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

C#
public enum BitmapCacheOption
Herencia
BitmapCacheOption

Campos

Nombre Valor Description
Default 0

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

None 2

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

OnDemand 0

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

OnLoad 1

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

Ejemplos

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

C#
// 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);

Se aplica a

Produto Versións
.NET Framework 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
Windows Desktop 3.0, 3.1, 5, 6, 7, 8, 9

Consulte también