【发布时间】:2012-09-30 11:28:49
【问题描述】:
在 ApplicationData.Current.RomanigFolder 中,我保存了一个 jpg 文件。是否可以在流或 MemoryStream 中读取此文件的内容并将其设置为 ImageSource?
我在带有 .NET 4.0 的 WPF 应用程序中使用它,代码如下:(img 是 XAML-Image-Control
BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.CacheOption = BitmapCacheOption.OnLoad;
StreamReader sr = new StreamReader(data.message.imageUrl);
bi.StreamSource = sr.BaseStream;
bi.EndInit();
img.Source = bi;
sr.Close();
对于 Metro 应用程序,我认为无法将 StreamSource 设置为 BitmapImage。如何将 Image-File 设置为 Image-Control?
【问题讨论】:
标签: c# windows-8 windows-runtime winrt-xaml