react-native-rectangle-doc-scanner 7.2.0 → 7.4.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.
@@ -510,25 +510,17 @@ class CameraController(
510
510
 
511
511
  private fun computeRotationDegrees(): Int {
512
512
  val displayRotation = displayRotationDegrees()
513
- if (sensorOrientation == 0) {
514
- return if (useFrontCamera) {
515
- (360 - displayRotation) % 360
516
- } else {
517
- displayRotation
518
- }
519
- }
520
- if (sensorOrientation == 180) {
521
- return if (useFrontCamera) {
522
- (180 + displayRotation) % 360
523
- } else {
524
- (180 - displayRotation + 360) % 360
525
- }
526
- }
527
- return if (useFrontCamera) {
513
+
514
+ // For back camera with sensor orientation 0 and display rotation 90 (portrait),
515
+ // we need 270 degree rotation to display correctly
516
+ val rotation = if (useFrontCamera) {
528
517
  (sensorOrientation + displayRotation) % 360
529
518
  } else {
530
519
  (sensorOrientation - displayRotation + 360) % 360
531
520
  }
521
+
522
+ Log.d(TAG, "[ROTATION] sensor=$sensorOrientation display=$displayRotation front=$useFrontCamera -> rotation=$rotation")
523
+ return rotation
532
524
  }
533
525
 
534
526
  private fun displayRotationDegrees(): Int {
@@ -549,25 +541,37 @@ class CameraController(
549
541
  if (viewWidth == 0f || viewHeight == 0f) return
550
542
 
551
543
  val rotation = computeRotationDegrees()
544
+ Log.d(TAG, "[TRANSFORM] rotation=$rotation view=${viewWidth}x${viewHeight} preview=${preview.width}x${preview.height}")
545
+
546
+ // Calculate buffer dimensions after rotation
552
547
  val bufferWidth = if (rotation == 90 || rotation == 270) preview.height.toFloat() else preview.width.toFloat()
553
548
  val bufferHeight = if (rotation == 90 || rotation == 270) preview.width.toFloat() else preview.height.toFloat()
554
549
 
550
+ Log.d(TAG, "[TRANSFORM] buffer after rotation: ${bufferWidth}x${bufferHeight}")
551
+
555
552
  val centerX = viewWidth / 2f
556
553
  val centerY = viewHeight / 2f
557
554
 
558
- // Rotate to match display orientation.
559
555
  val matrix = Matrix()
556
+
557
+ // Apply rotation
560
558
  if (rotation != 0) {
561
559
  matrix.postRotate(rotation.toFloat(), centerX, centerY)
562
560
  }
561
+
562
+ // Calculate scale to fill the view (crop mode)
563
+ val scaleX = viewWidth / bufferWidth
564
+ val scaleY = viewHeight / bufferHeight
565
+ val scale = maxOf(scaleX, scaleY)
566
+
567
+ Log.d(TAG, "[TRANSFORM] scaleX=$scaleX scaleY=$scaleY finalScale=$scale")
568
+
569
+ // Apply scale
570
+ matrix.postScale(scale, scale, centerX, centerY)
571
+
563
572
  previewView.setTransform(matrix)
564
573
 
565
- // Uniform center-crop to fill the view.
566
- val scale = max(viewWidth / bufferWidth, viewHeight / bufferHeight)
567
- previewView.pivotX = centerX
568
- previewView.pivotY = centerY
569
- previewView.scaleX = scale
570
- previewView.scaleY = scale
574
+ Log.d(TAG, "[TRANSFORM] Matrix applied successfully")
571
575
  }
572
576
 
573
577
  private fun chooseBestSize(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "7.2.0",
3
+ "version": "7.4.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",