C# WPF Imageコントロール

Image.Source の設定

string dataPath = @"C:\image.jpg";

var bmpImage = new BitmapImage();
bmpImage.BeginInit();
bmpImage.CacheOption = BitmapCacheOption.OnLoad;
bmpImage.CreateOptions = BitmapCreateOptions.None;
bmpImage.UriSource = new Uri(dataPath);
bmpImage.DecodePixelWidth = 300; // サムネイル
bmpImage.EndInit();
bmpImage.Freeze();

image.Source = bmpImage;

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

This site uses Akismet to reduce spam. Learn how your comment data is processed.