如何转换“System.IO.IsolatedStorage.IsolatedStorageFileStream”到图像源?
问题很清楚:我正在尝试将“System.IO.IsolatedStorage.IsolatedStorageFileStream”转换为 ImageSource,但不知道如何做到这一点。我看过几篇文章讨论将字节数组转换为 Imagesource,但没有讨论 ISFileStreams。如果有人有解决方案或有关如何继续的示例,请告诉我。
我的代码:
private void Files_List_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
if (store.FileExists(Path.Combine("wallpaper", Files_List.SelectedValue.ToString())))
{
using (var isoStream = store.OpenFile(Path.Combine("wallpaper", Files_List.SelectedValue.ToString()), FileMode.Open))
{
//Here is where I want to set an ImageSource from isoStream!
}
}
}
}
谢谢。
The question is clear: I am trying to Convert an "System.IO.IsolatedStorage.IsolatedStorageFileStream" to an ImageSource but have no clue of how I could do this. I've seen severals articles that talk about converting arrays of bytes to Imagesource, but nothing about ISFileStreams. If someone has a solution or an example on how to proceed please let me know.
My code:
private void Files_List_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
using (var store = IsolatedStorageFile.GetUserStoreForApplication())
{
if (store.FileExists(Path.Combine("wallpaper", Files_List.SelectedValue.ToString())))
{
using (var isoStream = store.OpenFile(Path.Combine("wallpaper", Files_List.SelectedValue.ToString()), FileMode.Open))
{
//Here is where I want to set an ImageSource from isoStream!
}
}
}
}
Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
下面是在加载中使用您的代码的完整工作应用程序。
您可以选择 PNG 文件保存到独立存储,然后将文件重新加载到显示的图像。我注意到的一件事是,您必须小心保存流关闭并且 PNG 兼容:
Xaml:
代码隐藏:
Below is a complete working application using your code in the load.
You can select PNG files to save to isolated storage then reload the file to the image on display. One thing I noticed is that you must be careful that the saving stream closes and that the PNG is compatible:
Xaml:
Code behind: