BitmapImage.DecodePixelHeight Propiedad

Definición

Obtiene o establece la altura, en píxeles, con la que se descodifica la imagen.

public:
 property int DecodePixelHeight { int get(); void set(int value); };
public int DecodePixelHeight { get; set; }
member this.DecodePixelHeight : int with get, set
Public Property DecodePixelHeight As Integer

Valor de propiedad

Int32

Altura, en píxeles, con la que se descodifica la imagen. El valor predeterminado es 0.

Ejemplos

En el ejemplo de código siguiente se muestra cómo establecer la DecodePixelHeight propiedad mediante código.

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

Comentarios

Si DecodePixelWidth también se establece, se omite la relación de aspecto del mapa de bits. Si DecodePixelWidth no se establece, la relación de aspecto sigue siendo la misma.

Los códecs JPEG y Portable Network Graphics (PNG) descodifican de forma nativa la imagen en el tamaño especificado; otros códecs descodifican la imagen en su tamaño original y escalan la imagen al tamaño deseado.

Información sobre propiedades de dependencia

Campo identificador DecodePixelHeightProperty
Propiedades de metadatos establecidas en true Ninguno

Se aplica a

Consulte también