从照片库中获取图像流 [英] get the image stream from photo library
问题描述
这听起来很简单,但我已经失去了很多时间寻找答案
在我的应用程序中,我使用PhotoChooserTask让用户选择照片,我通过使用
获得照片的路径
string FileName = e.OriginalFileName;
其中e是PhotoResult参数任务。 ,比方说:FileName =
" C:\ Data \SharedData \Comms \ Indeistore \ data \\\\\\\\\\\ \\2000000a00000018700b.dat"
(从云中选择)或
" D:\\ \\Pictures\Camera Roll \ WP_20140110_10_40_42_1_Smart.jpg" (来自相机胶卷)
我想保存该字符串路径并将其打开并再次显示图像当用户重新打开应用程序时。但我找不到将这些字符串转换为图像数据(BitmapImage或Stream)的方法
有什么想法吗?
您无法使用OriginalFileName中的路径再次加载图像。你必须使用StorageFolder& StorageFile类加载文件。
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj681698(v = vs.105).aspx
http://blogs.windows.com /windows_phone/b/wpdev/archive/2013/06/25/file-handling-with-windows-storage-apis.aspx
This may sound very simple but I've lost a lot of time looking for answer
In my app I use the PhotoChooserTask to let the user choose the photo, and i get the path of the photo by using
string FileName = e.OriginalFileName;
where e is the PhotoResult argument of the Task. , let's say: FileName=
"C:\Data\SharedData\Comms\Unistore\data\18\k\2000000a00000018700b.dat" (selected from the cloud) or
"D:\Pictures\Camera Roll\WP_20140110_10_40_42_1_Smart.jpg" (from camera roll)
I want to save that string path and open it up and show the image again when the users reopen the app. But I cannot find a method to convert those string into Image data (BitmapImage or Stream)
Any idea?
You can't use path from OriginalFileName to load image again. You have to use StorageFolder & StorageFile classes to load the file.
http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj681698(v=vs.105).aspx
http://blogs.windows.com/windows_phone/b/wpdev/archive/2013/06/25/file-handling-with-windows-storage-apis.aspx
这篇关于从照片库中获取图像流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!