Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.

id title brief samplecode article sdk
Save Photo to App Directory
This recipe shows how to save a photo to an application’s Documents directory.


The sample code uses the Camera helper from TweetStation to take a picture, and then demonstrates how to save it in the completion handler. The photo is saved to the applications Documents directory, like this:

TweetStation.Camera.TakePicture (this, (obj) =>{
   var photo = obj.ValueForKey(new NSString("UIImagePickerControllerOriginalImage")) as UIImage;
   var documentsDirectory = Environment.GetFolderPath
   string jpgFilename = System.IO.Path.Combine (documentsDirectory, "Photo.jpg"); // hardcoded filename, overwritten each time
   NSData imgData = photo.AsJPEG();
   NSError err = null;
   if (imgData.Save(jpgFilename, false, out err)) {
       Console.WriteLine("saved as " + jpgFilename);
   } else {
       Console.WriteLine("NOT saved as " + jpgFilename + " because" + err.LocalizedDescription);

Additional Information

Saving the image data in this way does NOT include the metadata supplied by the camera (such as GPS location, camera model, exposure, etc).