2 つのイメージ コントロールがあります。1 つはサムネイル解像度 (70x90) で画像を表示し、もう 1 つは元/ソースの解像度で画像を表示します。サムネイル画像は、縦横比を考慮せずに元の解像度からサイズ変更されます。
私の質問は、どちらがより良いパフォーマンスを生み出すかということです?
各イメージ コントロールに 2 つのイメージ ファイル (同じイメージ、異なる解像度) を使用します。
XAML
<Image Name="Img_Thumb"/>
<Image Name="Img_Original"/>
コードビハインド
BitmapImage bmp_thumb = new BitmapImage();
bmp_thumb.BeginInit();
bmp_thumb.CacheOption = BitmapCacheOption.OnLoad;
bmp_thumb.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
bmp_thumb.UriSource = new Uri(thumbnails_directory);
bmp_thumb.EndInit();
Img_Thumb.Source = bmp_thumb;
Img_Thumb.Width = bmp_thumb.PixelWidth;
Img_Thumb.Height = bmp_thumb.PixelHeight;
bmp_ori = new BitmapImage();
bmp_ori.BeginInit();
bmp_ori.CacheOption = BitmapCacheOption.OnLoad;
bmp_ori.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
bmp_ori.UriSource = new Uri(original_image_directory);
bmp_ori.EndInit();
Img_Original.Source = bmp_ori;
Img_Original.Width = bmp_ori.PixelWidth;
Img_Original.Height = bmp_ori.PixelHeight;
または、1 つのイメージ ファイル (大きいファイル) を使用して、カスタム解像度で 2 つの異なるイメージ コントロールにロードします。
XAML
<Image Name="Img_Thumb" width="70" height="90"/>
<Image Name="Img_Original"/>
コードビハインド
BitmapImage bmp_thumb = new BitmapImage();
bmp_thumb.BeginInit();
bmp_thumb.CacheOption = BitmapCacheOption.OnLoad;
bmp_thumb.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
bmp_thumb.UriSource = new Uri(original_image_directory);
bmp_thumb.EndInit();
Img_Thumb.Source = bmp_thumb;
bmp_ori = new BitmapImage();
bmp_ori.BeginInit();
bmp_ori.CacheOption = BitmapCacheOption.OnLoad;
bmp_ori.CreateOptions = BitmapCreateOptions.IgnoreImageCache;
bmp_ori.UriSource = new Uri(original_image_directory);
bmp_ori.EndInit();
Img_Original.Source = bmp_ori;
Img_Original.Width = bmp_ori.PixelWidth;
Img_Original.Height = bmp_ori.PixelHeight;