react-native-rectangle-doc-scanner 7.35.0 → 7.36.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,27 +559,34 @@ class CameraController(
|
|
|
559
559
|
val viewHeight = previewView.height.toFloat()
|
|
560
560
|
val preview = previewSize ?: return
|
|
561
561
|
if (viewWidth == 0f || viewHeight == 0f) return
|
|
562
|
-
val
|
|
562
|
+
val rotation = previewView.display?.rotation ?: Surface.ROTATION_0
|
|
563
563
|
Log.d(
|
|
564
564
|
TAG,
|
|
565
565
|
"[TRANSFORM] rotation=${displayRotationDegrees()} view=${viewWidth}x${viewHeight} preview=${preview.width}x${preview.height}"
|
|
566
566
|
)
|
|
567
567
|
|
|
568
568
|
val matrix = Matrix()
|
|
569
|
-
val
|
|
570
|
-
val
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
569
|
+
val viewRect = RectF(0f, 0f, viewWidth, viewHeight)
|
|
570
|
+
val bufferRect = if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
|
|
571
|
+
RectF(0f, 0f, preview.height.toFloat(), preview.width.toFloat())
|
|
572
|
+
} else {
|
|
573
|
+
RectF(0f, 0f, preview.width.toFloat(), preview.height.toFloat())
|
|
574
|
+
}
|
|
575
|
+
val centerX = viewRect.centerX()
|
|
576
|
+
val centerY = viewRect.centerY()
|
|
577
|
+
|
|
578
|
+
if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
|
|
579
|
+
bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY())
|
|
580
|
+
matrix.setRectToRect(bufferRect, viewRect, Matrix.ScaleToFit.FILL)
|
|
581
|
+
val scale = max(
|
|
582
|
+
viewWidth / preview.width.toFloat(),
|
|
583
|
+
viewHeight / preview.height.toFloat()
|
|
584
|
+
)
|
|
585
|
+
matrix.postScale(scale, scale, centerX, centerY)
|
|
586
|
+
matrix.postRotate(90f * (rotation - 2), centerX, centerY)
|
|
587
|
+
} else if (rotation == Surface.ROTATION_180) {
|
|
588
|
+
matrix.postRotate(180f, centerX, centerY)
|
|
589
|
+
}
|
|
583
590
|
|
|
584
591
|
previewView.setTransform(matrix)
|
|
585
592
|
Log.d(TAG, "[TRANSFORM] Matrix applied successfully")
|