首先读取出数据
byte[] b = drv["image"] as byte[];
用byte数组接收数据
实例化BitmapImage
BitmapImage newBitmapImage = new BitmapImage();
之后判断数据是否为空,并作处理,为空给予一个默认图片
if (b == null || b.Length <= 0) { this.headerImg.Source = new BitmapImage(new Uri("../templet/images/defaulthead.jpg", UriKind.Relative)); } else { System.IO.MemoryStream _ImageMem = new System.IO.MemoryStream(b); newBitmapImage.StreamSource = _ImageMem; newBitmapImage.BeginInit(); newBitmapImage.StreamSource = _ImageMem; newBitmapImage.EndInit(); this.headerImg.Source = newBitmapImage; }