react-native-rectangle-doc-scanner 7.2.0 → 7.3.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.
|
@@ -549,25 +549,37 @@ class CameraController(
|
|
|
549
549
|
if (viewWidth == 0f || viewHeight == 0f) return
|
|
550
550
|
|
|
551
551
|
val rotation = computeRotationDegrees()
|
|
552
|
+
Log.d(TAG, "[TRANSFORM] rotation=$rotation view=${viewWidth}x${viewHeight} preview=${preview.width}x${preview.height}")
|
|
553
|
+
|
|
554
|
+
// Calculate buffer dimensions after rotation
|
|
552
555
|
val bufferWidth = if (rotation == 90 || rotation == 270) preview.height.toFloat() else preview.width.toFloat()
|
|
553
556
|
val bufferHeight = if (rotation == 90 || rotation == 270) preview.width.toFloat() else preview.height.toFloat()
|
|
554
557
|
|
|
558
|
+
Log.d(TAG, "[TRANSFORM] buffer after rotation: ${bufferWidth}x${bufferHeight}")
|
|
559
|
+
|
|
555
560
|
val centerX = viewWidth / 2f
|
|
556
561
|
val centerY = viewHeight / 2f
|
|
557
562
|
|
|
558
|
-
// Rotate to match display orientation.
|
|
559
563
|
val matrix = Matrix()
|
|
564
|
+
|
|
565
|
+
// Apply rotation
|
|
560
566
|
if (rotation != 0) {
|
|
561
567
|
matrix.postRotate(rotation.toFloat(), centerX, centerY)
|
|
562
568
|
}
|
|
569
|
+
|
|
570
|
+
// Calculate scale to fill the view (crop mode)
|
|
571
|
+
val scaleX = viewWidth / bufferWidth
|
|
572
|
+
val scaleY = viewHeight / bufferHeight
|
|
573
|
+
val scale = maxOf(scaleX, scaleY)
|
|
574
|
+
|
|
575
|
+
Log.d(TAG, "[TRANSFORM] scaleX=$scaleX scaleY=$scaleY finalScale=$scale")
|
|
576
|
+
|
|
577
|
+
// Apply scale
|
|
578
|
+
matrix.postScale(scale, scale, centerX, centerY)
|
|
579
|
+
|
|
563
580
|
previewView.setTransform(matrix)
|
|
564
581
|
|
|
565
|
-
|
|
566
|
-
val scale = max(viewWidth / bufferWidth, viewHeight / bufferHeight)
|
|
567
|
-
previewView.pivotX = centerX
|
|
568
|
-
previewView.pivotY = centerY
|
|
569
|
-
previewView.scaleX = scale
|
|
570
|
-
previewView.scaleY = scale
|
|
582
|
+
Log.d(TAG, "[TRANSFORM] Matrix applied successfully")
|
|
571
583
|
}
|
|
572
584
|
|
|
573
585
|
private fun chooseBestSize(
|