BitmapCacheOption Énumération

Définition

Spécifie comment une image bitmap tire parti de la mise en cache de la mémoire.

public enum class BitmapCacheOption
public enum BitmapCacheOption
type BitmapCacheOption = 
Public Enum BitmapCacheOption
Héritage
BitmapCacheOption

Champs

Nom Valeur Description
Default 0

Met en cache toute l’image en mémoire. Il s’agit de la valeur par défaut.

OnDemand 0

Crée un magasin de mémoire pour les données demandées uniquement. La première requête charge l’image directement ; les requêtes suivantes sont remplies à partir du cache.

OnLoad 1

Met en cache toute l’image en mémoire au moment du chargement. Toutes les demandes de données d’image sont remplies à partir du magasin de mémoire.

None 2

Ne créez pas de magasin de mémoire. Toutes les demandes de l’image sont remplies directement par le fichier image.

Exemples

L’exemple de code suivant montre comment charger un BitmapImage et spécifier le 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)

S’applique à

Voir aussi