react-native-rectangle-doc-scanner 7.3.0 → 7.5.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 {
@@ -637,15 +629,27 @@ class CameraController(
637
629
  }
638
630
 
639
631
  private fun rotateAndMirror(bitmap: Bitmap, rotationDegrees: Int, mirror: Boolean): Bitmap {
632
+ Log.d(TAG, "[ROTATE_MIRROR] rotationDegrees=$rotationDegrees mirror=$mirror bitmap=${bitmap.width}x${bitmap.height}")
640
633
  if (rotationDegrees == 0 && !mirror) {
641
634
  return bitmap
642
635
  }
643
636
  val matrix = Matrix()
644
- if (mirror) {
637
+
638
+ // For back camera, we need to mirror horizontally to fix the flip issue
639
+ // The camera sensor output is already mirrored, so we need to flip it back
640
+ if (!mirror) {
641
+ // Back camera: flip horizontally
645
642
  matrix.postScale(-1f, 1f, bitmap.width / 2f, bitmap.height / 2f)
643
+ Log.d(TAG, "[ROTATE_MIRROR] Applied horizontal flip for back camera")
644
+ } else {
645
+ // Front camera: keep mirror
646
+ matrix.postScale(-1f, 1f, bitmap.width / 2f, bitmap.height / 2f)
647
+ Log.d(TAG, "[ROTATE_MIRROR] Applied horizontal flip for front camera")
646
648
  }
649
+
647
650
  if (rotationDegrees != 0) {
648
651
  matrix.postRotate(rotationDegrees.toFloat(), bitmap.width / 2f, bitmap.height / 2f)
652
+ Log.d(TAG, "[ROTATE_MIRROR] Applied rotation: $rotationDegrees degrees")
649
653
  }
650
654
  return Bitmap.createBitmap(bitmap, 0, 0, bitmap.width, bitmap.height, matrix, true)
651
655
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "7.3.0",
3
+ "version": "7.5.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",