id | title | brief | samplecode | sdk | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3ED7298A-1B29-EBAE-2203-F2F4919A8221 |
Save Photo to Album with Metadata |
This recipe shows how to save a photo to the Photos Camera Roll Album, including image metadata. |
|
|
The sample code uses the Camera helper from TweetStation to take a picture, then demonstrates how to save it (with metadata) in the completion handler:
TweetStation.Camera.TakePicture (this, (obj) =>{
var photo = obj.ValueForKey(new NSString("UIImagePickerControllerOriginalImage")) as UIImage;
var meta = obj.ValueForKey(new NSString("UIImagePickerControllerMediaMetadata")) as NSDictionary;
ALAssetsLibrary library = new ALAssetsLibrary();
library.WriteImageToSavedPhotosAlbum (photo.CGImage, meta, (assetUrl, error) =>{
Console.WriteLine ("assetUrl:"+assetUrl);
});
});;
There is a simpler mechanism to save an existing UIImage to the Photo Album, but it does not include metadata:
var someImage = UIImage.FromFile("someImage.jpg");
someImage.SaveToPhotosAlbum((image, error) => {
var o = image as UIImage;
Console.WriteLine("error:" + error);
});