chore: Fix formatting

This commit is contained in:
Marc Rousavy 2023-09-29 19:42:28 +02:00
parent fb812a6618
commit a1fbba8d66

View File

@ -6,15 +6,15 @@ import android.os.Build
import android.util.Range
fun CaptureRequest.Builder.setZoom(zoom: Float, cameraCharacteristics: CameraCharacteristics) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
val zoomRange = cameraCharacteristics.get(CameraCharacteristics.CONTROL_ZOOM_RATIO_RANGE) ?: Range(1f, 1f)
val zoomClamped = zoomRange.clamp(zoom)
this.set(CaptureRequest.CONTROL_ZOOM_RATIO, zoomClamped)
} else {
val maxZoom = cameraCharacteristics.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM)
val zoomRange = Range(1f, maxZoom ?: 1f)
val size = cameraCharacteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE)!!
val zoomClamped = zoomRange.clamp(zoom)
this.set(CaptureRequest.SCALER_CROP_REGION, size.zoomed(zoomClamped))
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
val zoomRange = cameraCharacteristics.get(CameraCharacteristics.CONTROL_ZOOM_RATIO_RANGE) ?: Range(1f, 1f)
val zoomClamped = zoomRange.clamp(zoom)
this.set(CaptureRequest.CONTROL_ZOOM_RATIO, zoomClamped)
} else {
val maxZoom = cameraCharacteristics.get(CameraCharacteristics.SCALER_AVAILABLE_MAX_DIGITAL_ZOOM)
val zoomRange = Range(1f, maxZoom ?: 1f)
val size = cameraCharacteristics.get(CameraCharacteristics.SENSOR_INFO_ACTIVE_ARRAY_SIZE)!!
val zoomClamped = zoomRange.clamp(zoom)
this.set(CaptureRequest.SCALER_CROP_REGION, size.zoomed(zoomClamped))
}
}