BitmapImage.DecodePixelHeight Proprietà

Definizione

Ottiene o imposta l'altezza, in pixel, a cui l'immagine è decodificata.

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

Valore della proprietà

Int32

Altezza, in pixel, a cui l'immagine è decodificata. Il valore predefinito è 0.

Esempio

Nell'esempio di codice seguente viene illustrato come impostare la proprietà usando il DecodePixelHeight codice.

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

Commenti

Se DecodePixelWidth è impostato anche, il rapporto di aspetto della bitmap viene ignorato. Se DecodePixelWidth non è impostato, il rapporto di aspetto rimane invariato.

I codec JPEG e Portable Network Graphics (PNG) decodificano in modo nativo l'immagine alle dimensioni specificate; altri codec decodificano l'immagine con le dimensioni originali e ridimensionano l'immagine in base alle dimensioni desiderate.

Informazioni proprietà di dipendenza

Campo Identificatore DecodePixelHeightProperty
Proprietà dei metadati impostate su true Nessuno

Si applica a

Vedi anche