react-native-rectangle-doc-scanner 7.51.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,28 +570,19 @@ class CameraController(
|
|
|
577
570
|
val centerX = viewRect.centerX()
|
|
578
571
|
val centerY = viewRect.centerY()
|
|
579
572
|
|
|
580
|
-
val isSwapped =
|
|
581
|
-
if (isSwapped)
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
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
|
-
}
|
|
573
|
+
val isSwapped = rotationDegrees == 90 || rotationDegrees == 270
|
|
574
|
+
val bufferWidth = if (isSwapped) preview.height.toFloat() else preview.width.toFloat()
|
|
575
|
+
val bufferHeight = if (isSwapped) preview.width.toFloat() else preview.height.toFloat()
|
|
576
|
+
val scale = max(viewWidth / bufferWidth, viewHeight / bufferHeight)
|
|
577
|
+
val scaledWidth = bufferWidth * scale
|
|
578
|
+
val scaledHeight = bufferHeight * scale
|
|
579
|
+
val dx = (viewWidth - scaledWidth) / 2f
|
|
580
|
+
val dy = (viewHeight - scaledHeight) / 2f
|
|
581
|
+
|
|
582
|
+
matrix.setScale(scale, scale)
|
|
583
|
+
matrix.postTranslate(dx, dy)
|
|
584
|
+
if (rotationDegrees != 0) {
|
|
585
|
+
matrix.postRotate(rotationDegrees.toFloat(), centerX, centerY)
|
|
602
586
|
}
|
|
603
587
|
|
|
604
588
|
previewView.setTransform(matrix)
|