react-native-rectangle-doc-scanner 4.7.0 → 4.8.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.
|
@@ -517,17 +517,27 @@ class CameraController(
|
|
|
517
517
|
val bufferWidth = if (rotation == 90 || rotation == 270) preview.height.toFloat() else preview.width.toFloat()
|
|
518
518
|
val bufferHeight = if (rotation == 90 || rotation == 270) preview.width.toFloat() else preview.height.toFloat()
|
|
519
519
|
|
|
520
|
-
val
|
|
521
|
-
val
|
|
522
|
-
val centerX = viewRect.centerX()
|
|
523
|
-
val centerY = viewRect.centerY()
|
|
520
|
+
val centerX = viewWidth / 2f
|
|
521
|
+
val centerY = viewHeight / 2f
|
|
524
522
|
|
|
525
523
|
val matrix = Matrix()
|
|
526
|
-
|
|
527
|
-
|
|
524
|
+
|
|
525
|
+
// Apply transformations in correct order:
|
|
526
|
+
// 1. Translate to center
|
|
527
|
+
matrix.postTranslate(-centerX, -centerY)
|
|
528
|
+
|
|
529
|
+
// 2. Rotate around origin
|
|
530
|
+
if (rotation != 0) {
|
|
531
|
+
matrix.postRotate(rotation.toFloat())
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
// 3. Scale to fill view
|
|
528
535
|
val scale = max(viewWidth / bufferWidth, viewHeight / bufferHeight)
|
|
529
|
-
matrix.postScale(scale, scale
|
|
530
|
-
|
|
536
|
+
matrix.postScale(scale, scale)
|
|
537
|
+
|
|
538
|
+
// 4. Translate back to center
|
|
539
|
+
matrix.postTranslate(centerX, centerY)
|
|
540
|
+
|
|
531
541
|
previewView.setTransform(matrix)
|
|
532
542
|
}
|
|
533
543
|
|