【发布时间】:2014-02-15 21:20:50
【问题描述】:
我可以使用专门的 JPEG 加载 jpeg 方法很好地加载 JPEG,我也可以使用 SO 中详述的许多方法很好地保存 PNG。
但是,每当我创建用于从独立存储加载 PNG 的流时,它都会导致 BitmapImage 的大小为零。
这就是我所拥有的......
public static async Task<BitmapImage> ReadBitmapImageFromIsolatedStorage(string fn)
{
StorageFolder local = Windows.Storage.ApplicationData.Current.LocalFolder;
if (local != null)
{
Stream file = await local.OpenStreamForReadAsync(fn);
BitmapImage bi = new BitmapImage();
bi.SetSource(file);
return bi;
}
return null;
}
我也尝试了很多变化。在创建 BitmapImages 时读取流似乎存在某种延迟,这意味着流通常在 BitmapImage 读取它之前就被处理掉了。 WPF中有一个选项可以设置,但是WINdows Phone BitmapImage没有这个选项。
【问题讨论】:
-
我觉得我还没有厌倦它 - 但也许 stackoverflow.com/questions/4817874/… 会帮助你。在答案中@Stuart 正在从 IS 打开一个 PNG 文件。
-
这个解决方案效果很好!
标签: windows-phone-8