Created
February 3, 2019 11:10
-
-
Save trilliwon/eb8ff7879457c89b51a27dc794742c86 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