我在本地数据库中写图像。
MemoryStream stream = new MemoryStream();
WriteableBitmap mywbq = new WriteableBitmap(bmp);
mywbq.SaveJpeg(stream, mywbq.PixelWidth, mywbq.PixelHeight, 0, 95);
byte[] imagearray = stream.ToArray();
stream.Close();
db._contacts.InsertOnSubmit(new MyContactsList {ItemImage = imagearray });
db.SubmitChanges();
我希望这张照片以xaml显示。
怎么不可能?
我用它source
但是这个课程不起作用
答案 0 :(得分:1)
简单:
byte[] yourImageBytesFromDatabase = ......;
MemoryStream ms = new MemoryStream();
ms.Write(yourImageBytesFromDatabase, 0, yourImageBytesFromDatabase.Length);
BitmapImage src = new BitmapImage();
src.SetSource(ms);