Saving a BitmapImage object as a file in local storage in windows 8?

橙三吉。 提交于 2020-01-04 06:49:11

问题


I have a BitmapImage object, which already has its source etc set. I simply want to save it to my apps local storage folder, so that I can reference it at other points in the program. I just cannot figure out how to get it from object to file though! I've found solutions to similar problems for WP7, but its just not the same.

Ive got as far as creating my image from a Base64 string (which works as I can load the image into a UI image viewer and see it) and have called it img, and I know I need to get it to ApplicationData.Current.LocalFolder, but I have no idea how to convert it. Does anyone know?


回答1:


Is it from the camera UI?

var _Photo = await new CameraCaptureUI()
    .CaptureFileAsync(CameraCaptureUIMode.PhotoOrVideo);
await _Photo.MoveAsync(ApplicationData.Current.LocalFolder);

Is it from opening the file? Then you just need:

await _Photo.MoveAsync(ApplicationData.Current.LocalFolder);

However, if you simply have a BitmapImage, you cannot get the image out of it. Instead you need to go back to the original source or file. That's the only way. Reference



来源:https://stackoverflow.com/questions/12753437/saving-a-bitmapimage-object-as-a-file-in-local-storage-in-windows-8

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!