react-native-rectangle-doc-scanner 7.25.0 → 7.26.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.
|
@@ -564,25 +564,27 @@ class CameraController(
|
|
|
564
564
|
)
|
|
565
565
|
|
|
566
566
|
val matrix = Matrix()
|
|
567
|
+
val isSwapped = rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270
|
|
568
|
+
val bufferWidth = if (isSwapped) preview.height.toFloat() else preview.width.toFloat()
|
|
569
|
+
val bufferHeight = if (isSwapped) preview.width.toFloat() else preview.height.toFloat()
|
|
567
570
|
val viewRect = RectF(0f, 0f, viewWidth, viewHeight)
|
|
568
|
-
val bufferRect = RectF(0f, 0f,
|
|
571
|
+
val bufferRect = RectF(0f, 0f, bufferWidth, bufferHeight)
|
|
569
572
|
val centerX = viewRect.centerX()
|
|
570
573
|
val centerY = viewRect.centerY()
|
|
571
574
|
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
matrix.
|
|
585
|
-
matrix.postTranslate((viewWidth - scaledWidth) / 2f, (viewHeight - scaledHeight) / 2f)
|
|
575
|
+
// Use uniform scaling to avoid stretching; then center-crop to fill.
|
|
576
|
+
matrix.setRectToRect(bufferRect, viewRect, Matrix.ScaleToFit.CENTER)
|
|
577
|
+
val scale = max(viewWidth / bufferWidth, viewHeight / bufferHeight)
|
|
578
|
+
matrix.postScale(scale, scale, centerX, centerY)
|
|
579
|
+
|
|
580
|
+
if (rotation != Surface.ROTATION_0) {
|
|
581
|
+
val rotateDegrees = when (rotation) {
|
|
582
|
+
Surface.ROTATION_90 -> -90f
|
|
583
|
+
Surface.ROTATION_180 -> 180f
|
|
584
|
+
Surface.ROTATION_270 -> 90f
|
|
585
|
+
else -> 0f
|
|
586
|
+
}
|
|
587
|
+
matrix.postRotate(rotateDegrees, centerX, centerY)
|
|
586
588
|
}
|
|
587
589
|
|
|
588
590
|
previewView.setTransform(matrix)
|