BitmapImage 读取内存流和显示图片

FileStream filestream = File.OpenRead(@"C:\Users\Administrator\Desktop\queryHeaderImg.png");

BitmapImage image = new BitmapImage();
MemoryStream stream = new MemoryStream();

filestream.CopyTo(stream);

 

 

我开始将stream 赋值给BitmapImage 中的StreamSource 但是图片一直报错,

提示StreamSource 为null

 

查找资料 一定要要先初始货才能给StreamSource赋值。

 

bitmapImage.BeginInit();
bitmapImage.StreamSource = stream;
bitmapImage.EndInit();

posted @ 2015-01-10 17:52  玖彩技术团队  阅读(2444)  评论(0编辑  收藏  举报
以上只是个人想法和实践经验,如果有文字错误和语法错误,请加以指点! QQ:247039968 emil:wujc@younger.com 无论是美女的歌声,还是鬣狗的狂吠,无论是鳄鱼的眼泪,还是恶狼的嚎叫,都不会使我动摇