react-native-rectangle-doc-scanner 7.38.0 → 7.39.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.
|
@@ -569,19 +569,24 @@ class CameraController(
|
|
|
569
569
|
val bufferWidth = preview.width.toFloat()
|
|
570
570
|
val bufferHeight = preview.height.toFloat()
|
|
571
571
|
val isSwapped = rotationDegrees == 90 || rotationDegrees == 270
|
|
572
|
-
val rotatedWidth = if (isSwapped) bufferHeight else bufferWidth
|
|
573
|
-
val rotatedHeight = if (isSwapped) bufferWidth else bufferHeight
|
|
574
|
-
val scale = max(viewWidth / rotatedWidth, viewHeight / rotatedHeight)
|
|
575
|
-
val rotateDegrees = -rotationDegrees.toFloat()
|
|
576
572
|
|
|
577
|
-
|
|
573
|
+
val viewRect = RectF(0f, 0f, viewWidth, viewHeight)
|
|
574
|
+
val bufferRect = if (isSwapped) {
|
|
575
|
+
RectF(0f, 0f, bufferHeight, bufferWidth)
|
|
576
|
+
} else {
|
|
577
|
+
RectF(0f, 0f, bufferWidth, bufferHeight)
|
|
578
|
+
}
|
|
579
|
+
val centerX = viewRect.centerX()
|
|
580
|
+
val centerY = viewRect.centerY()
|
|
581
|
+
val scale = max(viewWidth / bufferRect.width(), viewHeight / bufferRect.height())
|
|
582
|
+
|
|
583
|
+
// Map buffer to view with uniform scale (aspect-fill), then rotate in view space.
|
|
578
584
|
val matrix = Matrix()
|
|
579
|
-
matrix.
|
|
580
|
-
|
|
581
|
-
|
|
585
|
+
matrix.setRectToRect(bufferRect, viewRect, Matrix.ScaleToFit.CENTER)
|
|
586
|
+
matrix.postScale(scale, scale, centerX, centerY)
|
|
587
|
+
if (rotationDegrees != 0) {
|
|
588
|
+
matrix.postRotate(rotationDegrees.toFloat(), centerX, centerY)
|
|
582
589
|
}
|
|
583
|
-
matrix.postScale(scale, scale)
|
|
584
|
-
matrix.postTranslate(viewWidth / 2f, viewHeight / 2f)
|
|
585
590
|
|
|
586
591
|
previewView.setTransform(matrix)
|
|
587
592
|
Log.d(TAG, "[TRANSFORM] Matrix applied successfully")
|