1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
- (BOOL)cameraSupportsZoom { return self.activeCamera.activeFormat.videoMaxZoomFactor > 1.0f; // 1 } - (CGFloat)maxZoomFactor { return MIN(self.activeCamera.activeFormat.videoMaxZoomFactor, 4.0f); // 2 } - (void)setZoomValue:(CGFloat)zoomValue { // 3 if (!self.activeCamera.isRampingVideoZoom) { NSError *error; if ([self.activeCamera lockForConfiguration:&error]) { // 4 // Provide linear feel to zoom slider CGFloat zoomFactor = pow([self maxZoomFactor], zoomValue); // 5 self.activeCamera.videoZoomFactor = zoomFactor; [self.activeCamera unlockForConfiguration]; // 6 } else { [self.delegate deviceConfigurationFailedWithError:error]; } } } - (void)rampZoomToValue:(CGFloat)zoomValue { // 1 CGFloat zoomFactor = pow([self maxZoomFactor], zoomValue); NSError *error; if ([self.activeCamera lockForConfiguration:&error]) { [self.activeCamera rampToVideoZoomFactor:zoomFactor // 2 withRate:THZoomRate]; [self.activeCamera unlockForConfiguration]; } else { [self.delegate deviceConfigurationFailedWithError:error]; } }
|
近期评论