react-native-rectangle-doc-scanner 7.12.0 → 7.13.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.
|
@@ -553,21 +553,28 @@ class CameraController(
|
|
|
553
553
|
Log.d(TAG, "[TRANSFORM] rotation=$rotationDegrees view=${viewWidth}x${viewHeight} preview=${preview.width}x${preview.height}")
|
|
554
554
|
|
|
555
555
|
val matrix = Matrix()
|
|
556
|
-
val
|
|
557
|
-
val
|
|
558
|
-
val
|
|
559
|
-
val
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
556
|
+
val centerX = viewWidth / 2f
|
|
557
|
+
val centerY = viewHeight / 2f
|
|
558
|
+
val isSwapped = rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270
|
|
559
|
+
val bufferWidth = if (isSwapped) preview.height.toFloat() else preview.width.toFloat()
|
|
560
|
+
val bufferHeight = if (isSwapped) preview.width.toFloat() else preview.height.toFloat()
|
|
561
|
+
val scale = maxOf(viewWidth / bufferWidth, viewHeight / bufferHeight)
|
|
562
|
+
val scaledWidth = bufferWidth * scale
|
|
563
|
+
val scaledHeight = bufferHeight * scale
|
|
564
|
+
val dx = (viewWidth - scaledWidth) / 2f
|
|
565
|
+
val dy = (viewHeight - scaledHeight) / 2f
|
|
566
|
+
|
|
567
|
+
matrix.setScale(scale, scale)
|
|
568
|
+
matrix.postTranslate(dx, dy)
|
|
569
|
+
|
|
570
|
+
if (rotation != Surface.ROTATION_0) {
|
|
571
|
+
val rotateDegrees = when (rotation) {
|
|
572
|
+
Surface.ROTATION_90 -> -90f
|
|
573
|
+
Surface.ROTATION_180 -> 180f
|
|
574
|
+
Surface.ROTATION_270 -> 90f
|
|
575
|
+
else -> 0f
|
|
570
576
|
}
|
|
577
|
+
matrix.postRotate(rotateDegrees, centerX, centerY)
|
|
571
578
|
}
|
|
572
579
|
|
|
573
580
|
previewView.setTransform(matrix)
|