react-native-rectangle-doc-scanner 7.37.0 → 7.39.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.
|
@@ -565,28 +565,27 @@ class CameraController(
|
|
|
565
565
|
"[TRANSFORM] rotation=${displayRotationDegrees()} view=${viewWidth}x${viewHeight} preview=${preview.width}x${preview.height}"
|
|
566
566
|
)
|
|
567
567
|
|
|
568
|
-
val
|
|
568
|
+
val rotationDegrees = displayRotationDegrees()
|
|
569
|
+
val bufferWidth = preview.width.toFloat()
|
|
570
|
+
val bufferHeight = preview.height.toFloat()
|
|
571
|
+
val isSwapped = rotationDegrees == 90 || rotationDegrees == 270
|
|
572
|
+
|
|
569
573
|
val viewRect = RectF(0f, 0f, viewWidth, viewHeight)
|
|
570
|
-
val bufferRect = if (
|
|
571
|
-
RectF(0f, 0f,
|
|
574
|
+
val bufferRect = if (isSwapped) {
|
|
575
|
+
RectF(0f, 0f, bufferHeight, bufferWidth)
|
|
572
576
|
} else {
|
|
573
|
-
RectF(0f, 0f,
|
|
577
|
+
RectF(0f, 0f, bufferWidth, bufferHeight)
|
|
574
578
|
}
|
|
575
579
|
val centerX = viewRect.centerX()
|
|
576
580
|
val centerY = viewRect.centerY()
|
|
581
|
+
val scale = max(viewWidth / bufferRect.width(), viewHeight / bufferRect.height())
|
|
577
582
|
|
|
578
|
-
//
|
|
583
|
+
// Map buffer to view with uniform scale (aspect-fill), then rotate in view space.
|
|
584
|
+
val matrix = Matrix()
|
|
579
585
|
matrix.setRectToRect(bufferRect, viewRect, Matrix.ScaleToFit.CENTER)
|
|
580
|
-
val scale = max(viewWidth / bufferRect.width(), viewHeight / bufferRect.height())
|
|
581
586
|
matrix.postScale(scale, scale, centerX, centerY)
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
Surface.ROTATION_180 -> 180f
|
|
585
|
-
Surface.ROTATION_270 -> 90f
|
|
586
|
-
else -> 0f
|
|
587
|
-
}
|
|
588
|
-
if (rotateDegrees != 0f) {
|
|
589
|
-
matrix.postRotate(rotateDegrees, centerX, centerY)
|
|
587
|
+
if (rotationDegrees != 0) {
|
|
588
|
+
matrix.postRotate(rotationDegrees.toFloat(), centerX, centerY)
|
|
590
589
|
}
|
|
591
590
|
|
|
592
591
|
previewView.setTransform(matrix)
|