Hello, hope you don't mind the cross posting:
I'm building an iOS App where I need to use the camera and save images from it into the App folder.
When I try to convert the image from the camera to a JPEG or PNG, I'm getting: "Cannot cast from source type to destination type."
Here is the code I'm using:
public class ImagePickerDelegate : UIImagePickerControllerDelegate
{
public ImagePickerDelegate()
{
}
public override void FinishedPickingImage(UIImagePickerController picker, UIImage image, NSDictionary editingInfo)
{
var documentsDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
string jpgFilename = System.IO.Path.Combine(documentsDirectory, string.Format("{0}.jpg", Guid.NewGuid()));
using (NSData imageData = image.AsJPEG(0.2f))
{
NSError err;
if (!imageData.Save(jpgFilename, false, out err))
{
Console.WriteLine("Saving of file failed: " + err.Description);
}
}
}
}
The error occurs when I call:
using (NSData imageData = image.AsJPEG(0.2f))
Any ideas?