将大图像加载到图像控件中

时间:2012-11-17 04:33:01

标签: c# wpf bitmapimage

我在WPF窗口上加载大图像进行一些调整(如亮度和对比度)但是当我尝试加载大图像(3000x2000或4000x3000)时,我的图像会自动转换为较低的分辨率(通常为1024x600)< / p>

Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();
openFileDialog.ShowDialog();

BitmapImage bitmap = new BitmapImage(new Uri(openFileDialog.FileName));

imageResolution.Content = bitmap.Width + "x" + bitmap.Height;//label to see dimensions
myImage.Source = bitmap;//image

如何在BitmapImage对象中保留图像的原始分辨率?

2 个答案:

答案 0 :(得分:0)

听起来很奇怪。尝试直接在XAML中设置myImage.Source。

控件应保留原始图像

<Image x:Name="image1" Stretch="None" Source={Binding PathToImage}>

答案 1 :(得分:0)

请尝试使用ImageSource对象:

Microsoft.Win32.OpenFileDialog openFileDialog = new Microsoft.Win32.OpenFileDialog();
openFileDialog.ShowDialog();
ImageSource imageSource = new BitmapImage(new Uri(openFileDialog.FileName));
image1.Source = imageSource;