react-native-rectangle-doc-scanner 7.43.0 → 7.45.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.
|
@@ -584,14 +584,30 @@ class CameraController(
|
|
|
584
584
|
val swappedWidth = preview.height.toFloat()
|
|
585
585
|
val swappedHeight = preview.width.toFloat()
|
|
586
586
|
|
|
587
|
-
//
|
|
587
|
+
// Android: Use 90% of view height to add 10% padding (5% top + 5% bottom)
|
|
588
|
+
val effectiveViewHeight = viewHeight * 0.90f
|
|
589
|
+
|
|
590
|
+
// Calculate scale to fit within the effective area while maintaining aspect ratio
|
|
588
591
|
val scaleX = viewWidth / swappedWidth
|
|
589
|
-
val scaleY =
|
|
590
|
-
val scale =
|
|
592
|
+
val scaleY = effectiveViewHeight / swappedHeight
|
|
593
|
+
val scale = min(scaleX, scaleY)
|
|
594
|
+
|
|
595
|
+
// Calculate the final dimensions after scaling
|
|
596
|
+
val scaledWidth = swappedWidth * scale
|
|
597
|
+
val scaledHeight = swappedHeight * scale
|
|
598
|
+
|
|
599
|
+
// Create buffer rectangle at origin
|
|
600
|
+
val bufferRectRotated = RectF(0f, 0f, swappedHeight, swappedWidth)
|
|
601
|
+
|
|
602
|
+
// Set up the matrix: scale and center the rotated preview
|
|
603
|
+
matrix.setScale(scale, scale)
|
|
604
|
+
matrix.postRotate(90f * (rotation - 2), scaledWidth / 2f, scaledHeight / 2f)
|
|
605
|
+
matrix.postTranslate(
|
|
606
|
+
centerX - scaledWidth / 2f,
|
|
607
|
+
centerY - scaledHeight / 2f
|
|
608
|
+
)
|
|
591
609
|
|
|
592
|
-
|
|
593
|
-
matrix.postRotate(90f * (rotation - 2), centerX, centerY)
|
|
594
|
-
matrix.postScale(scale, scale, centerX, centerY)
|
|
610
|
+
Log.d(TAG, "[TRANSFORM] Android: effectiveHeight=$effectiveViewHeight, scale=$scale, scaledSize=${scaledWidth}x${scaledHeight}")
|
|
595
611
|
} else if (rotation == Surface.ROTATION_180) {
|
|
596
612
|
matrix.postRotate(180f, centerX, centerY)
|
|
597
613
|
} else {
|