byte[] imge = File.ReadAllBytes(path);将图片读为二进制代码
System.IO.MemoryStream ms = new System.IO.MemoryStream(imge);//img是从数据库中读取出来的字节数组
ms.Seek(0, System.IO.SeekOrigin.Begin);
BitmapImage newBitmapImage = new BitmapImage();
newBitmapImage.BeginInit();
newBitmapImage.StreamSource = ms;//二进制代码转为图片
newBitmapImage.EndInit();
//BitmapImage image = new BitmapImage(new Uri(path, UriKind.Absolute));
img.Source = newBitmapImage;
File.Delete(path);