catch negative values set by out of preview bound press

This commit is contained in:
2026-01-21 12:57:46 -08:00
parent ac5dac127f
commit 3bb72d5d94

View File

@@ -198,8 +198,10 @@ class PreviewView(context: Context, callback: SurfaceHolder.Callback) :
val viewOrientation = Orientation.PORTRAIT val viewOrientation = Orientation.PORTRAIT
val rotated = point.rotatedBy(viewSize, cameraSize, viewOrientation, sensorOrientation) val rotated = point.rotatedBy(viewSize, cameraSize, viewOrientation, sensorOrientation)
Log.i(TAG, "Converted layer point $point to camera point $rotated! ($sensorOrientation, $cameraSize -> $viewSize)") // Clamp to valid camera coordinates (must be non-negative for MeteringRectangle)
return rotated val clamped = Point(maxOf(0, rotated.x), maxOf(0, rotated.y))
Log.i(TAG, "Converted layer point $point to camera point $clamped! ($sensorOrientation, $cameraSize -> $viewSize)")
return clamped
} }
private fun updateLayout() { private fun updateLayout() {