我用wpf中的Image控件来显示大图片的时候,当图片超过12M,经常出现不显示的现象。其他的图片大小为6M左右的时候,基本都可以正常的显示。如果图片能够正常显示的时候,中间会有个几秒钟的停顿,而没有正常显示的时候,就不会出现停顿现象。代码如下: BinaryReader binReader = new BinaryReader(File.Open(picPath, FileMode.Open));
FileInfo fileInfo = new FileInfo(picPath);
byte[] bytes = binReader.ReadBytes((int)fileInfo.Length);
binReader.Close(); BitmapImage bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.StreamSource = new MemoryStream(bytes);
bitmap.EndInit(); image.Source = bitmap;picPath 是图片的路径,image 就是Image控件。希望各位高手能帮忙解决一下。非常感谢。
FileInfo fileInfo = new FileInfo(picPath);
byte[] bytes = binReader.ReadBytes((int)fileInfo.Length);
binReader.Close(); BitmapImage bitmap = new BitmapImage();
bitmap.BeginInit();
bitmap.StreamSource = new MemoryStream(bytes);
bitmap.EndInit(); image.Source = bitmap;picPath 是图片的路径,image 就是Image控件。希望各位高手能帮忙解决一下。非常感谢。
在使用Image的ImageFailed事件的时候,图片不加载提示是:“没有足够的内存继续执行程序。”