Share via


BitmapImage.DecodePixelWidth Propiedad

Definición

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

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

Valor de propiedad

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

Ejemplos

En el ejemplo de código siguiente se muestra cómo establecer la DecodePixelWidth 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 DecodePixelHeight también se establece, se omite la relación de aspecto del mapa de bits. Si DecodePixelHeight 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 al 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 DecodePixelWidthProperty
Propiedades de metadatos establecidas en true Ninguno

Se aplica a

Consulte también