BitmapImage.DecodePixelWidth Properti
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
Mendapatkan atau mengatur lebar, dalam piksel, tempat gambar didekodekan.
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
Nilai Properti
Lebar, dalam piksel, tempat gambar didekodekan. Nilai defaultnya adalah 0.
Contoh
Contoh kode berikut menunjukkan cara mengatur DecodePixelWidth 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 DecodePixelHeight juga diatur, rasio aspek bitmap diabaikan. Jika DecodePixelHeight 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 | DecodePixelWidthProperty |
Properti metadata diatur ke true |
Tidak |