wpf 解决 编码解码器无法使用提供的流类型 The codec cannot use the type of stream provided
之前做的ListBox里列大图http://www.cnblogs.com/li-peng/archive/2012/11/20/2778657.html
图片转换的时候这段代码

有的时候会有问题 编码解码器无法使用提供的流类型 或者 The codec cannot use the type of stream provided
改成
BitmapImage bitImage = new BitmapImage();
bitImage.BeginInit();
bitImage.StreamSource = imageStreamSource;
bitImage.EndInit();
//JpegBitmapDecoder jpeDecoder=new JpegBitmapDecoder(imageStreamSource,BitmapCreateOptions.PreservePixelFormat,BitmapCacheOption.OnLoad);
//ImageSource imageSource=jpeDecoder.Frames[0];
ImageSource imageSource = bitImage;
return imageSource;
作者:李鹏
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

浙公网安备 33010602011771号