react-native-rectangle-doc-scanner 7.45.0 → 7.46.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.
|
@@ -581,33 +581,37 @@ class CameraController(
|
|
|
581
581
|
|
|
582
582
|
if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
|
|
583
583
|
// When rotated 90/270, preview dimensions are swapped
|
|
584
|
-
val
|
|
585
|
-
val
|
|
584
|
+
val bufferWidth = preview.height.toFloat() // 1088
|
|
585
|
+
val bufferHeight = preview.width.toFloat() // 1920
|
|
586
586
|
|
|
587
|
-
// Android: Use 90% of view height
|
|
588
|
-
val
|
|
587
|
+
// Android: Use 90% of view height for 10% vertical padding
|
|
588
|
+
val effectiveHeight = viewHeight * 0.90f
|
|
589
589
|
|
|
590
|
-
// Calculate scale to fit
|
|
591
|
-
|
|
592
|
-
val
|
|
593
|
-
val
|
|
590
|
+
// Calculate scale to fit the preview proportionally
|
|
591
|
+
// Use min to ensure entire preview fits (no cropping, no stretching)
|
|
592
|
+
val scaleX = viewWidth / bufferWidth
|
|
593
|
+
val scaleY = effectiveHeight / bufferHeight
|
|
594
|
+
val scale = min(scaleX, scaleY) // This maintains aspect ratio
|
|
594
595
|
|
|
595
|
-
//
|
|
596
|
-
val
|
|
597
|
-
val scaledHeight = swappedHeight * scale
|
|
596
|
+
// Create swap buffer rect (before rotation: height x width)
|
|
597
|
+
val bufferRect = RectF(0f, 0f, bufferHeight, bufferWidth)
|
|
598
598
|
|
|
599
|
-
//
|
|
600
|
-
|
|
599
|
+
// Apply the transformation
|
|
600
|
+
// 1. Scale uniformly to fit in view
|
|
601
|
+
matrix.postScale(scale, scale)
|
|
601
602
|
|
|
602
|
-
//
|
|
603
|
-
|
|
604
|
-
|
|
603
|
+
// 2. Rotate 90 degrees
|
|
604
|
+
val scaledWidth = bufferWidth * scale
|
|
605
|
+
val scaledHeight = bufferHeight * scale
|
|
606
|
+
matrix.postRotate(90f * (rotation - 2), scaledHeight / 2f, scaledWidth / 2f)
|
|
607
|
+
|
|
608
|
+
// 3. Center in view
|
|
605
609
|
matrix.postTranslate(
|
|
606
|
-
centerX -
|
|
607
|
-
centerY -
|
|
610
|
+
centerX - scaledHeight / 2f,
|
|
611
|
+
centerY - scaledWidth / 2f
|
|
608
612
|
)
|
|
609
613
|
|
|
610
|
-
Log.d(TAG, "[TRANSFORM] Android:
|
|
614
|
+
Log.d(TAG, "[TRANSFORM] Android: buffer=${bufferWidth}x${bufferHeight}, scale=$scale, final=${scaledWidth}x${scaledHeight}")
|
|
611
615
|
} else if (rotation == Surface.ROTATION_180) {
|
|
612
616
|
matrix.postRotate(180f, centerX, centerY)
|
|
613
617
|
} else {
|