BitmapImage.DecodePixelHeight 屬性

定義

取得或設定影像解碼成的高度 (以像素為單位)。

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

屬性值

影像解碼成的高度 (以像素為單位)。 預設值為 0。

範例

下列程式碼範例示範如何使用程式碼來設定 DecodePixelHeight 屬性。

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

備註

如果 DecodePixelWidth 也已設定,則會忽略點陣圖的外觀比例。 如果未 DecodePixelWidth 設定,外觀比例會維持不變。

JPEG 和可攜式網狀圖形 (PNG) 編解碼器以原生方式將影像解碼為指定的大小;其他編解碼器會以原始大小解碼影像,並將影像調整為所需的大小。

相依性屬性資訊

識別碼欄位 DecodePixelHeightProperty
設定為 的中繼資料屬性 true

適用於

另請參閱