react-native-rectangle-doc-scanner 4.9.0 → 4.10.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.
@@ -209,12 +209,30 @@ class CameraController(
209
209
  ?: return
210
210
  sensorOrientation = characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION) ?: 0
211
211
 
212
- val viewAspect = if (previewView.height == 0) {
213
- 1.0
212
+ // Calculate view aspect ratio considering sensor orientation
213
+ // For portrait mode with 90/270 degree sensor, we need to swap width/height
214
+ val displayRotation = displayRotationDegrees()
215
+ val totalRotation = if (useFrontCamera) {
216
+ (sensorOrientation + displayRotation) % 360
214
217
  } else {
215
- previewView.width.toDouble() / previewView.height.toDouble()
218
+ (sensorOrientation - displayRotation + 360) % 360
216
219
  }
217
220
 
221
+ val viewWidth = previewView.width.takeIf { it > 0 } ?: 1200
222
+ val viewHeight = previewView.height.takeIf { it > 0 } ?: 1928
223
+
224
+ // If total rotation is 90 or 270, the sensor output is rotated, so we need to match against swapped aspect
225
+ val viewAspect = if (totalRotation == 90 || totalRotation == 270) {
226
+ // Sensor outputs landscape (e.g., 1920x1080), but we display portrait
227
+ // So we want to find sensor size with aspect ~= viewHeight/viewWidth
228
+ viewHeight.toDouble() / viewWidth.toDouble()
229
+ } else {
230
+ viewWidth.toDouble() / viewHeight.toDouble()
231
+ }
232
+
233
+ Log.d(TAG, "[CAMERA2] sensorOrientation=$sensorOrientation displayRotation=$displayRotation totalRotation=$totalRotation")
234
+ Log.d(TAG, "[CAMERA2] viewAspect=$viewAspect (view: ${viewWidth}x${viewHeight})")
235
+
218
236
  val previewSizes = streamConfigMap.getOutputSizes(SurfaceTexture::class.java)
219
237
  previewSize = chooseBestSize(previewSizes, viewAspect, null, preferClosestAspect = true)
220
238
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "4.9.0",
3
+ "version": "4.10.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",