Bagikan melalui


BitmapImage.DecodePixelHeight Properti

Definisi

Mendapatkan atau mengatur tinggi, dalam piksel, tempat gambar didekodekan.

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

Nilai Properti

Tinggi, dalam piksel, tempat gambar didekodekan. Nilai defaultnya adalah 0.

Contoh

Contoh kode berikut menunjukkan cara mengatur DecodePixelHeight properti dengan menggunakan kode.

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

Keterangan

Jika DecodePixelWidth juga diatur, rasio aspek bitmap diabaikan. Jika DecodePixelWidth tidak diatur, rasio aspek tetap sama.

Codec JPEG dan Portable Network Graphics (PNG) secara asli mendekode gambar ke ukuran yang ditentukan; codec lain mendekode gambar pada ukuran aslinya dan menskalakan gambar ke ukuran yang diinginkan.

Informasi Properti Dependensi

Item Nilai
Bidang pengidentifikasi DecodePixelHeightProperty
Properti metadata diatur ke true Tidak

Berlaku untuk

Lihat juga