react-native-rectangle-doc-scanner 7.40.0 → 7.42.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.
|
@@ -575,26 +575,25 @@ class CameraController(
|
|
|
575
575
|
|
|
576
576
|
val matrix = Matrix()
|
|
577
577
|
val viewRect = RectF(0f, 0f, viewWidth, viewHeight)
|
|
578
|
-
val bufferRect =
|
|
579
|
-
RectF(0f, 0f, preview.height.toFloat(), preview.width.toFloat())
|
|
580
|
-
} else {
|
|
581
|
-
RectF(0f, 0f, preview.width.toFloat(), preview.height.toFloat())
|
|
582
|
-
}
|
|
578
|
+
val bufferRect = RectF(0f, 0f, preview.width.toFloat(), preview.height.toFloat())
|
|
583
579
|
val centerX = viewRect.centerX()
|
|
584
580
|
val centerY = viewRect.centerY()
|
|
585
581
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
582
|
+
if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
|
|
583
|
+
val swappedBufferRect = RectF(0f, 0f, preview.height.toFloat(), preview.width.toFloat())
|
|
584
|
+
swappedBufferRect.offset(centerX - swappedBufferRect.centerX(), centerY - swappedBufferRect.centerY())
|
|
585
|
+
matrix.setRectToRect(viewRect, swappedBufferRect, Matrix.ScaleToFit.CENTER)
|
|
586
|
+
val scale = max(viewHeight / preview.height.toFloat(), viewWidth / preview.width.toFloat())
|
|
587
|
+
matrix.postScale(scale, scale, centerX, centerY)
|
|
588
|
+
matrix.postRotate(90f * (rotation - 2), centerX, centerY)
|
|
589
|
+
} else if (rotation == Surface.ROTATION_180) {
|
|
590
|
+
matrix.postRotate(180f, centerX, centerY)
|
|
591
|
+
} else {
|
|
592
|
+
val scale = max(viewWidth / preview.width.toFloat(), viewHeight / preview.height.toFloat())
|
|
593
|
+
val scaledWidth = preview.width.toFloat() * scale
|
|
594
|
+
val scaledHeight = preview.height.toFloat() * scale
|
|
595
|
+
matrix.setScale(scale, scale)
|
|
596
|
+
matrix.postTranslate((viewWidth - scaledWidth) / 2f, (viewHeight - scaledHeight) / 2f)
|
|
598
597
|
}
|
|
599
598
|
|
|
600
599
|
previewView.setTransform(matrix)
|