react-native-rectangle-doc-scanner 7.49.0 → 7.51.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.
|
@@ -578,27 +578,27 @@ class CameraController(
|
|
|
578
578
|
val centerY = viewRect.centerY()
|
|
579
579
|
|
|
580
580
|
val isSwapped = rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270
|
|
581
|
-
val bufferWidth = if (isSwapped) preview.height.toFloat() else preview.width.toFloat()
|
|
582
|
-
val bufferHeight = if (isSwapped) preview.width.toFloat() else preview.height.toFloat()
|
|
583
|
-
var scale = if (isSwapped) {
|
|
584
|
-
// Scale by height to preserve aspect, then ensure width fills the view.
|
|
585
|
-
viewHeight / bufferHeight
|
|
586
|
-
} else {
|
|
587
|
-
viewHeight / bufferHeight
|
|
588
|
-
}
|
|
589
|
-
if (bufferWidth * scale < viewWidth) {
|
|
590
|
-
scale = viewWidth / bufferWidth
|
|
591
|
-
}
|
|
592
|
-
val scaledWidth = bufferWidth * scale
|
|
593
|
-
val scaledHeight = bufferHeight * scale
|
|
594
|
-
|
|
595
|
-
matrix.setScale(scale, scale)
|
|
596
|
-
matrix.postTranslate((viewWidth - scaledWidth) / 2f, (viewHeight - scaledHeight) / 2f)
|
|
597
|
-
|
|
598
581
|
if (isSwapped) {
|
|
582
|
+
val bufferRect = RectF(0f, 0f, preview.height.toFloat(), preview.width.toFloat())
|
|
583
|
+
bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY())
|
|
584
|
+
matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL)
|
|
585
|
+
val scale = max(
|
|
586
|
+
viewHeight / preview.height.toFloat(),
|
|
587
|
+
viewWidth / preview.width.toFloat()
|
|
588
|
+
)
|
|
589
|
+
matrix.postScale(scale, scale, centerX, centerY)
|
|
599
590
|
matrix.postRotate(90f * (rotation - 2), centerX, centerY)
|
|
600
|
-
} else
|
|
601
|
-
|
|
591
|
+
} else {
|
|
592
|
+
val bufferRect = RectF(0f, 0f, preview.width.toFloat(), preview.height.toFloat())
|
|
593
|
+
matrix.setRectToRect(bufferRect, viewRect, Matrix.ScaleToFit.CENTER)
|
|
594
|
+
val scale = max(
|
|
595
|
+
viewWidth / preview.width.toFloat(),
|
|
596
|
+
viewHeight / preview.height.toFloat()
|
|
597
|
+
)
|
|
598
|
+
matrix.postScale(scale, scale, centerX, centerY)
|
|
599
|
+
if (rotation == Surface.ROTATION_180) {
|
|
600
|
+
matrix.postRotate(180f, centerX, centerY)
|
|
601
|
+
}
|
|
602
602
|
}
|
|
603
603
|
|
|
604
604
|
previewView.setTransform(matrix)
|