2

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?

J.B
  • 1,642
  • 2
  • 15
  • 33

1 Answers1

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

Jerry Nixon
  • 31,313
  • 14
  • 117
  • 233
  • unfortunately it is from a database where the image is stored as a string (in its current state SQLite for metro does seem to support images). That is the only source of the image that I would be able to reference at the point in the program I want to be able to do this. Looks like I'll have to work out some other way, many thanks for your answer. – J.B Oct 06 '12 at 13:55
  • Look at this http://stackoverflow.com/questions/11363169/winrt-storagefile-write-downloaded-file – Jerry Nixon Oct 09 '12 at 19:56