AVCapturePhotoSettings GetCurrentPhotoSettings ()
{
bool lensStabilizationEnabled = LensStabilizationControl.SelectedSegment == 1;
bool rawEnabled = RawControl.SelectedSegment == 1;
AVCapturePhotoSettings photoSettings = null;
if (lensStabilizationEnabled && photoOutput.IsLensStabilizationDuringBracketedCaptureSupported) {
AVCaptureBracketedStillImageSettings [] bracketedSettings = null;
if (VideoDevice.ExposureMode == AVCaptureExposureMode.Custom) {
bracketedSettings = new AVCaptureBracketedStillImageSettings [] {
AVCaptureManualExposureBracketedStillImageSettings.Create(AVCaptureDevice.ExposureDurationCurrent, AVCaptureDevice.ISOCurrent)
};
} else {
bracketedSettings = new AVCaptureBracketedStillImageSettings []{
AVCaptureAutoExposureBracketedStillImageSettings.Create(AVCaptureDevice.ExposureTargetBiasCurrent)
};
}
if (rawEnabled && photoOutput.AvailableRawPhotoPixelFormatTypes.Length > 0) {
photoSettings = AVCapturePhotoBracketSettings.FromRawPixelFormatType (photoOutput.AvailableRawPhotoPixelFormatTypes [0].UInt32Value, null, bracketedSettings);
} else {
// TODO: https://bugzilla.xamarin.com/show_bug.cgi?id=44111
photoSettings = AVCapturePhotoBracketSettings.FromRawPixelFormatType (0, new NSDictionary<NSString, NSObject> (AVVideo.CodecKey, new NSNumber ((int)AVVideoCodec.JPEG)), bracketedSettings);
}
((AVCapturePhotoBracketSettings)photoSettings).IsLensStabilizationEnabled = true;
} else {
if (rawEnabled && photoOutput.AvailableRawPhotoPixelFormatTypes.Length > 0) {
photoSettings = AVCapturePhotoSettings.FromRawPixelFormatType (photoOutput.AvailableRawPhotoPixelFormatTypes [0].UInt32Value);
} else {
photoSettings = AVCapturePhotoSettings.Create ();
}
// We choose not to use flash when doing manual exposure
if (VideoDevice.ExposureMode == AVCaptureExposureMode.Custom) {
photoSettings.FlashMode = AVCaptureFlashMode.Off;
} else {
photoSettings.FlashMode = photoOutput.SupportedFlashModes.Contains (new NSNumber ((long)AVCaptureFlashMode.Auto)) ? AVCaptureFlashMode.Auto : AVCaptureFlashMode.Off;
}
}
// The first format in the array is the preferred format
if (photoSettings.AvailablePreviewPhotoPixelFormatTypes.Length > 0)
photoSettings.PreviewPhotoFormat = new NSDictionary<NSString, NSObject> (CVPixelBuffer.PixelFormatTypeKey, photoSettings.AvailablePreviewPhotoPixelFormatTypes [0]);
if (VideoDevice.ExposureMode == AVCaptureExposureMode.Custom)
photoSettings.IsAutoStillImageStabilizationEnabled = false;
photoSettings.IsHighResolutionPhotoEnabled = true;
return photoSettings;
}