示例#1
0
        private MediaFile GetPictureMediaFile(NSDictionary info)
        {
            var image = (UIImage)info[UIImagePickerController.EditedImage];

            if (image == null)
            {
                image = (UIImage)info[UIImagePickerController.OriginalImage];
            }

            string path = GetOutputPath(MediaImplementation.TypeImage,
                                        options.Directory ?? ((IsCaptured) ? String.Empty : "temp"),
                                        options.Name);

            using (FileStream fs = File.OpenWrite(path))
                using (Stream s = new NSDataStream(image.AsJPEG()))
                {
                    s.CopyTo(fs);
                    fs.Flush();
                }

            Action <bool> dispose = null;

            if (this.source != UIImagePickerControllerSourceType.Camera)
            {
                dispose = d => File.Delete(path);
            }

            return(new MediaFile(path, () => File.OpenRead(path), dispose: dispose));
        }
        private MediaFile GetPictureMediaFile(NSDictionary info)
        {
            var image = (UIImage)info[UIImagePickerController.EditedImage];
            if (image == null)
                image = (UIImage)info[UIImagePickerController.OriginalImage];

            string path = GetOutputPath(MediaImplementation.TypeImage,
                options.Directory ?? ((IsCaptured) ? String.Empty : "temp"),
                options.Name);

            using (FileStream fs = File.OpenWrite(path))
            using (Stream s = new NSDataStream(image.AsJPEG()))
            {
                s.CopyTo(fs);
                fs.Flush();
            }

            Action<bool> dispose = null;
            if (this.source != UIImagePickerControllerSourceType.Camera)
                dispose = d => File.Delete(path);

            return new MediaFile(path, () => File.OpenRead(path), dispose: dispose);
        }