Created
July 19, 2017 07:24
-
-
Save NikhilManapure/5c7f88f19e7cd51ea2cb24ebb63ba42c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // HDR | |
| @IBOutlet weak var hdrButton: HDRButton! | |
| var currentHDRMode: HDRMode = .auto | |
| @IBAction func HDRButtonTouched(_ sender: HDRButton) { | |
| toggleHDR() | |
| sender.mode = currentHDRMode | |
| } | |
| func toggleHDR() { | |
| switch currentHDRMode { | |
| case .on: | |
| setHDR(.off) | |
| case .off: | |
| setHDR(.auto) | |
| case .auto: | |
| setHDR(.on) | |
| } | |
| } | |
| func setHDR(_ state: HDRMode) { | |
| guard camera.inputCamera.activeFormat.isVideoHDRSupported else { | |
| print("isVideoHDRSupported is false") | |
| return | |
| } | |
| do { | |
| try camera.inputCamera.lockForConfiguration() | |
| switch state { | |
| case .on: | |
| camera.inputCamera.automaticallyAdjustsVideoHDREnabled = false | |
| camera.inputCamera.isVideoHDREnabled = true | |
| case .off: | |
| camera.inputCamera.automaticallyAdjustsVideoHDREnabled = false | |
| camera.inputCamera.isVideoHDREnabled = false | |
| case .auto: | |
| camera.inputCamera.automaticallyAdjustsVideoHDREnabled = true | |
| } | |
| camera.inputCamera.unlockForConfiguration() | |
| } catch { | |
| print("Could not lock configuration") | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment