我可以使用专门的JPEG加载jpeg方法加载JPEG,我还可以使用SO上详细介绍的许多方法保存PNG。从Windows Phone上的独立存储加载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没有这个选项。
想到我没有厌倦它 - 但也许http://stackoverflow.com/questions/4817874/problem-opening-jpeg-from-isolated-storage-on-windows-phone-7将帮助你。在答案@Stuart从IS打开一个PNG文件。 – Romasz
此解决方案非常棒! –