我正在使用此代码在完成相机操作时将图像存储到隔离存储器中。如何将独立存储中的图像加载到windows phone上的图像控件中?
void camera_Completed(object sender, PhotoResult e)
{
BitmapImage objImage = new BitmapImage();
//objImage.SetSource(e.ChosenPhoto);
//Own_Image.Source = objImage;
using (var isolatedStorage = IsolatedStorageFile.GetUserStoreForApplication())
{
fnam = e.OriginalFileName.Substring(93);
MessageBox.Show(fnam);
if (isolatedStorage.FileExists(fnam))
isolatedStorage.DeleteFile(fnam);
IsolatedStorageFileStream fileStream = isolatedStorage.CreateFile(fnam);
BitmapImage bitmap = new BitmapImage();
bitmap.SetSource(e.ChosenPhoto);
WriteableBitmap wb = new WriteableBitmap(bitmap);
wb.SaveJpeg(fileStream, wb.PixelWidth, wb.PixelHeight, 100, 100);
MessageBox.Show("File Created");
fileStream.Close();
}
}
现在我想从孤立存储中获取图像并将其显示在我的图像控件中。
可能吗?
它工作正常。而我移动下一页做一些操作。并回到这个旧屏幕。这里加载的图像不显示。我在page_Loaded事件中写入了相同的函数调用。为什么它不再被加载。使用(var isolatedStorage = IsolatedStorageFile.GetUserStoreForApplication()) if(isolatedStorage.FileExists(fnam)) Own_Image.Source = GetImageFromIsolatedStorage(fnam); }} – selvam