react-native-rectangle-doc-scanner 7.6.0 → 7.7.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.
@@ -150,6 +150,10 @@ class CameraController(
150
150
  }
151
151
 
152
152
  try {
153
+ // Use 90 degrees for back camera in portrait mode
154
+ val jpegOrientation = 90
155
+ Log.d(TAG, "[CAPTURE] Setting JPEG_ORIENTATION to $jpegOrientation")
156
+
153
157
  val requestBuilder = device.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE).apply {
154
158
  addTarget(reader.surface)
155
159
  set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE)
@@ -157,7 +161,7 @@ class CameraController(
157
161
  if (torchEnabled) {
158
162
  set(CaptureRequest.FLASH_MODE, CaptureRequest.FLASH_MODE_TORCH)
159
163
  }
160
- set(CaptureRequest.JPEG_ORIENTATION, 0)
164
+ set(CaptureRequest.JPEG_ORIENTATION, jpegOrientation)
161
165
  }
162
166
 
163
167
  session.capture(requestBuilder.build(), object : CameraCaptureSession.CaptureCallback() {}, cameraHandler)
@@ -645,33 +649,18 @@ class CameraController(
645
649
  private fun rotateAndMirror(bitmap: Bitmap, rotationDegrees: Int, mirror: Boolean): Bitmap {
646
650
  Log.d(TAG, "[ROTATE_MIRROR] rotationDegrees=$rotationDegrees mirror=$mirror bitmap=${bitmap.width}x${bitmap.height}")
647
651
 
648
- val matrix = Matrix()
649
-
650
- // For 270 degree rotation (back camera in portrait mode):
651
- // 1. First rotate 90 degrees (not 270)
652
- // 2. Then flip horizontally if needed
653
- // This is because the sensor orientation is 0, but we're holding the phone at 90 degrees
654
- val actualRotation = when (rotationDegrees) {
655
- 270 -> 90 // Convert 270 to 90 for correct orientation
656
- 90 -> 270 // Convert 90 to 270 for front camera
657
- else -> rotationDegrees
658
- }
659
-
660
- Log.d(TAG, "[ROTATE_MIRROR] Adjusted rotation: $rotationDegrees -> $actualRotation")
661
-
662
- // Apply rotation first
663
- if (actualRotation != 0) {
664
- matrix.postRotate(actualRotation.toFloat())
665
- Log.d(TAG, "[ROTATE_MIRROR] Applied rotation: $actualRotation degrees")
652
+ // JPEG_ORIENTATION is already set to 90, so the image should already be rotated correctly
653
+ // We only need to apply mirror for front camera
654
+ if (!mirror) {
655
+ // Back camera: no additional processing needed since JPEG_ORIENTATION handles rotation
656
+ Log.d(TAG, "[ROTATE_MIRROR] Back camera: returning bitmap as-is (JPEG_ORIENTATION=90 already applied)")
657
+ return bitmap
666
658
  }
667
659
 
668
- // Apply mirror for front camera only
669
- if (mirror) {
670
- // Front camera needs horizontal flip after rotation
671
- val rotatedWidth = if (actualRotation == 90 || actualRotation == 270) bitmap.height else bitmap.width
672
- matrix.postScale(-1f, 1f, rotatedWidth / 2f, 0f)
673
- Log.d(TAG, "[ROTATE_MIRROR] Applied horizontal flip for front camera")
674
- }
660
+ // Front camera: apply horizontal mirror
661
+ val matrix = Matrix()
662
+ matrix.postScale(-1f, 1f, bitmap.width / 2f, bitmap.height / 2f)
663
+ Log.d(TAG, "[ROTATE_MIRROR] Front camera: applied horizontal mirror")
675
664
 
676
665
  return Bitmap.createBitmap(bitmap, 0, 0, bitmap.width, bitmap.height, matrix, true)
677
666
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "7.6.0",
3
+ "version": "7.7.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",