react-native-rectangle-doc-scanner 7.23.0 → 7.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -246,8 +246,10 @@ class CameraController(
|
|
|
246
246
|
val previewSizes = streamConfigMap.getOutputSizes(SurfaceTexture::class.java)
|
|
247
247
|
Log.d(TAG, "[CAMERA2] Available preview sizes: ${previewSizes?.take(10)?.joinToString { "${it.width}x${it.height}" }}")
|
|
248
248
|
|
|
249
|
-
//
|
|
250
|
-
|
|
249
|
+
// Match iOS photo preset behavior (4:3) when available for consistent FOV.
|
|
250
|
+
val targetPreviewAspect = 4.0 / 3.0
|
|
251
|
+
previewSize = chooseBestSize(previewSizes, targetPreviewAspect, null, preferClosestAspect = true)
|
|
252
|
+
?: chooseBestSize(previewSizes, viewAspect, null, preferClosestAspect = true)
|
|
251
253
|
?: previewSizes?.maxByOrNull { it.width * it.height }
|
|
252
254
|
Log.d(TAG, "[CAMERA2] Selected preview size: ${previewSize?.width}x${previewSize?.height}")
|
|
253
255
|
|
|
@@ -562,27 +564,25 @@ class CameraController(
|
|
|
562
564
|
)
|
|
563
565
|
|
|
564
566
|
val matrix = Matrix()
|
|
565
|
-
val isSwapped = rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270
|
|
566
|
-
val bufferWidth = if (isSwapped) preview.height.toFloat() else preview.width.toFloat()
|
|
567
|
-
val bufferHeight = if (isSwapped) preview.width.toFloat() else preview.height.toFloat()
|
|
568
567
|
val viewRect = RectF(0f, 0f, viewWidth, viewHeight)
|
|
569
|
-
val bufferRect = RectF(0f, 0f,
|
|
568
|
+
val bufferRect = RectF(0f, 0f, preview.height.toFloat(), preview.width.toFloat())
|
|
570
569
|
val centerX = viewRect.centerX()
|
|
571
570
|
val centerY = viewRect.centerY()
|
|
572
571
|
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
matrix.
|
|
572
|
+
if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
|
|
573
|
+
bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY())
|
|
574
|
+
matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL)
|
|
575
|
+
val scale = max(viewHeight / preview.height.toFloat(), viewWidth / preview.width.toFloat())
|
|
576
|
+
matrix.postScale(scale, scale, centerX, centerY)
|
|
577
|
+
matrix.postRotate(90f * (rotation - 2), centerX, centerY)
|
|
578
|
+
} else if (rotation == Surface.ROTATION_180) {
|
|
579
|
+
matrix.postRotate(180f, centerX, centerY)
|
|
580
|
+
} else {
|
|
581
|
+
val scale = max(viewWidth / preview.width.toFloat(), viewHeight / preview.height.toFloat())
|
|
582
|
+
val scaledWidth = preview.width.toFloat() * scale
|
|
583
|
+
val scaledHeight = preview.height.toFloat() * scale
|
|
584
|
+
matrix.setScale(scale, scale)
|
|
585
|
+
matrix.postTranslate((viewWidth - scaledWidth) / 2f, (viewHeight - scaledHeight) / 2f)
|
|
586
586
|
}
|
|
587
587
|
|
|
588
588
|
previewView.setTransform(matrix)
|