Sdílet prostřednictvím


BitmapImage.DecodePixelWidth Vlastnost

Definice

Získá nebo nastaví šířku v pixelech, na které je obrázek dekódován.

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

Hodnota vlastnosti

Int32

Šířka v pixelech, na kterou je obrázek dekódován. Výchozí hodnota je 0.

Příklady

Následující příklad kódu ukazuje, jak nastavit DecodePixelWidth vlastnost pomocí kódu.

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

Poznámky

Pokud DecodePixelHeight je nastaven také poměr stran rastrového obrázku, bude ignorován. Pokud DecodePixelHeight není nastavená, poměr stran zůstane stejný.

Kodeky JPEG a Portable Network Graphics (PNG) nativně dekódují obrázek na zadanou velikost; ostatní kodeky dekódují obrázek v původní velikosti a škálují obrázek na požadovanou velikost.

Informace o vlastnosti závislosti

Pole identifikátoru DecodePixelWidthProperty
Vlastnosti metadat nastavené na true Žádné

Platí pro

Viz také