react-native-rectangle-doc-scanner 7.50.0 → 7.52.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.
|
@@ -559,14 +559,7 @@ class CameraController(
|
|
|
559
559
|
val preview = previewSize ?: return
|
|
560
560
|
if (viewWidth == 0f || viewHeight == 0f) return
|
|
561
561
|
|
|
562
|
-
val
|
|
563
|
-
val rotationDegrees = when (rotation) {
|
|
564
|
-
Surface.ROTATION_0 -> 0
|
|
565
|
-
Surface.ROTATION_90 -> 90
|
|
566
|
-
Surface.ROTATION_180 -> 180
|
|
567
|
-
Surface.ROTATION_270 -> 270
|
|
568
|
-
else -> 0
|
|
569
|
-
}
|
|
562
|
+
val rotationDegrees = computeRotationDegrees()
|
|
570
563
|
Log.d(
|
|
571
564
|
TAG,
|
|
572
565
|
"[TRANSFORM] rotation=$rotationDegrees view=${viewWidth}x${viewHeight} preview=${preview.width}x${preview.height}"
|
|
@@ -577,20 +570,19 @@ class CameraController(
|
|
|
577
570
|
val centerX = viewRect.centerX()
|
|
578
571
|
val centerY = viewRect.centerY()
|
|
579
572
|
|
|
580
|
-
val isSwapped =
|
|
573
|
+
val isSwapped = rotationDegrees == 90 || rotationDegrees == 270
|
|
581
574
|
val bufferWidth = if (isSwapped) preview.height.toFloat() else preview.width.toFloat()
|
|
582
575
|
val bufferHeight = if (isSwapped) preview.width.toFloat() else preview.height.toFloat()
|
|
583
|
-
val bufferRect = RectF(0f, 0f, bufferWidth, bufferHeight)
|
|
584
|
-
|
|
585
|
-
// Center-fit, then uniformly scale to fill the view (no distortion).
|
|
586
|
-
matrix.setRectToRect(bufferRect, viewRect, Matrix.ScaleToFit.CENTER)
|
|
587
576
|
val scale = max(viewWidth / bufferWidth, viewHeight / bufferHeight)
|
|
588
|
-
|
|
577
|
+
val scaledWidth = bufferWidth * scale
|
|
578
|
+
val scaledHeight = bufferHeight * scale
|
|
579
|
+
val dx = (viewWidth - scaledWidth) / 2f
|
|
580
|
+
val dy = (viewHeight - scaledHeight) / 2f
|
|
589
581
|
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
matrix.postRotate(
|
|
582
|
+
matrix.setScale(scale, scale)
|
|
583
|
+
matrix.postTranslate(dx, dy)
|
|
584
|
+
if (rotationDegrees != 0) {
|
|
585
|
+
matrix.postRotate(rotationDegrees.toFloat(), centerX, centerY)
|
|
594
586
|
}
|
|
595
587
|
|
|
596
588
|
previewView.setTransform(matrix)
|