Silverlight-使用FileStream加载映像

Silverlight-使用FileStream加载映像,silverlight,Silverlight,我有一个Silverlight应用程序,我想在其中显示图片。图片从数据库加载到FileStream对象中。我需要将这些FileStream对象加载到System.Windows.Image元素中,以便在Silverlight应用程序中显示它们。问题是,我不知道如何将图像源设置为文件流。有人知道怎么做吗 谢谢大家! 这应该行得通。实际上,我在一个附加属性中放置了类似的内容,这样我就可以用我们的图像标识符来装饰xaml中的图像。附加属性还对本地应用程序存储中的图像进行一些缓存 var image =

我有一个Silverlight应用程序,我想在其中显示图片。图片从数据库加载到FileStream对象中。我需要将这些FileStream对象加载到System.Windows.Image元素中,以便在Silverlight应用程序中显示它们。问题是,我不知道如何将图像源设置为文件流。有人知道怎么做吗


谢谢大家!

这应该行得通。实际上,我在一个附加属性中放置了类似的内容,这样我就可以用我们的图像标识符来装饰xaml中的图像。附加属性还对本地应用程序存储中的图像进行一些缓存

var image = d as Image;
if(image != null)
{
    var bitMap = new BitmapImage();
    byte[] buffer = new byte[e.Result.Length];
    e.Result.Read(buffer, 0, (int) e.Result.Length);
    var stream = new MemoryStream(buffer);
    bitMap.SetSource(stream);
    image.Source = bitMap;
}

干杯

这应该行得通。实际上,我在一个附加属性中放置了类似的内容,这样我就可以用我们的图像标识符来装饰xaml中的图像。附加属性还对本地应用程序存储中的图像进行一些缓存

var image = d as Image;
if(image != null)
{
    var bitMap = new BitmapImage();
    byte[] buffer = new byte[e.Result.Length];
    e.Result.Read(buffer, 0, (int) e.Result.Length);
    var stream = new MemoryStream(buffer);
    bitMap.SetSource(stream);
    image.Source = bitMap;
}
干杯