monotouch: WriteImageToSavedPhotosAlbum problems saving from camera
-
06-03-2021 - |
Question
Please see gist here: https://gist.github.com/1387224
Essentially, I'm trying to save a photo from the AVCaptureSession
, I'm grabbing the output from an AVCaptureStillImageOutput
, converting it into a UIImage and trying to send it to the WriteImageToSavedPhotosAlbum
method on ALAssetLibrary
.
The reason for doing this is so I can grab the asset url once it's been saved (UIImage.SaveToPhotosAlbum
works fine but doesn't let me extract the filename created)
The method is throwing an error
Failed to encode image for saved photos.
Does anyone know how to fix this?
I also looked at passing the raw NSData
jpeg stream from the AVCaptureStillImageOutput
but can't work out how to get the metadata NSDictionary
to pass through.
Many Thanks
Solution
The WriteImageToSavedPhotosAlbum
overloads that takes a UIImage
were incorrectly bound (they should take a CGImage
instead). This has now been fixed, and there is a hotfix available in this bug report.
In the mean time you should be able to use the WriteImageToSavedPhotosAlbum
that takes the raw NSData
stream, passing a non-null NSDictionary
(like in the sample code in this bug report).