react-native-rectangle-doc-scanner 10.39.0 → 10.41.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.
@@ -118,9 +118,8 @@ class CameraController(
118
118
  Log.d(TAG, "[CAMERAX] TextureView visibility: ${textureView.visibility}")
119
119
  Log.d(TAG, "[CAMERAX] TextureView isAvailable: ${textureView.isAvailable}")
120
120
 
121
- // Force portrait orientation (app is portrait-only)
122
- val targetRotation = android.view.Surface.ROTATION_0
123
- Log.d(TAG, "[CAMERAX] Setting target rotation to ROTATION_0 (portrait-only app)")
121
+ val targetRotation = textureView.display?.rotation ?: android.view.Surface.ROTATION_0
122
+ Log.d(TAG, "[CAMERAX] Setting target rotation to $targetRotation")
124
123
 
125
124
  preview = Preview.Builder()
126
125
  .setTargetAspectRatio(AspectRatio.RATIO_4_3)
@@ -187,6 +186,7 @@ class CameraController(
187
186
  imageAnalyzer = ImageAnalysis.Builder()
188
187
  .setBackpressureStrategy(ImageAnalysis.STRATEGY_KEEP_ONLY_LATEST)
189
188
  .setTargetAspectRatio(AspectRatio.RATIO_4_3)
189
+ .setTargetResolution(android.util.Size(1280, 960))
190
190
  .setTargetRotation(targetRotation) // Match preview rotation
191
191
  .build()
192
192
  .also {
@@ -496,7 +496,6 @@ class CameraController(
496
496
  return
497
497
  }
498
498
 
499
- // Get sensor orientation to determine correct rotation
500
499
  val sensorOrientation = getCameraSensorOrientation()
501
500
  val displayRotationDegrees = when (textureView.display?.rotation ?: Surface.ROTATION_0) {
502
501
  Surface.ROTATION_0 -> 0
@@ -516,17 +515,16 @@ class CameraController(
516
515
  val centerX = viewWidth / 2f
517
516
  val centerY = viewHeight / 2f
518
517
 
519
- // Calculate rotation from buffer to display coordinates.
520
- // CameraX provides buffers in sensor orientation; rotate to match display.
521
- val rotationDegrees = ((sensorOrientation - displayRotationDegrees + 360) % 360).toFloat()
522
-
523
- Log.d(TAG, "[TRANSFORM] Applying rotation: ${rotationDegrees}°")
518
+ val rotationDegrees = if (sensorOrientation == 0) {
519
+ displayRotationDegrees.toFloat()
520
+ } else {
521
+ sensorOrientation.toFloat()
522
+ }
524
523
 
525
524
  if (rotationDegrees != 0f) {
526
525
  matrix.postRotate(rotationDegrees, centerX, centerY)
527
526
  }
528
527
 
529
- // After rotation, determine effective buffer size
530
528
  val rotatedBufferWidth = if (rotationDegrees == 90f || rotationDegrees == 270f) {
531
529
  bufferHeight
532
530
  } else {
@@ -121,24 +121,14 @@ const mirrorRectangleHorizontally = (rectangle, imageWidth) => ({
121
121
  const mapRectangleToView = (rectangle, imageWidth, imageHeight, viewWidth, viewHeight, density) => {
122
122
  const viewWidthPx = viewWidth * density;
123
123
  const viewHeightPx = viewHeight * density;
124
- const scale = react_native_1.Platform.OS === 'ios'
125
- ? Math.max(viewWidthPx / imageWidth, viewHeightPx / imageHeight)
126
- : Math.min(viewWidthPx / imageWidth, viewHeightPx / imageHeight);
124
+ const scale = Math.max(viewWidthPx / imageWidth, viewHeightPx / imageHeight);
127
125
  const scaledImageWidth = imageWidth * scale;
128
126
  const scaledImageHeight = imageHeight * scale;
129
- const offsetX = react_native_1.Platform.OS === 'ios'
130
- ? (scaledImageWidth - viewWidthPx) / 2
131
- : (viewWidthPx - scaledImageWidth) / 2;
132
- const offsetY = react_native_1.Platform.OS === 'ios'
133
- ? (scaledImageHeight - viewHeightPx) / 2
134
- : (viewHeightPx - scaledImageHeight) / 2;
127
+ const offsetX = (scaledImageWidth - viewWidthPx) / 2;
128
+ const offsetY = (scaledImageHeight - viewHeightPx) / 2;
135
129
  const mapPoint = (point) => ({
136
- x: react_native_1.Platform.OS === 'ios'
137
- ? (point.x * scale - offsetX) / density
138
- : (point.x * scale + offsetX) / density,
139
- y: react_native_1.Platform.OS === 'ios'
140
- ? (point.y * scale - offsetY) / density
141
- : (point.y * scale + offsetY) / density,
130
+ x: (point.x * scale - offsetX) / density,
131
+ y: (point.y * scale - offsetY) / density,
142
132
  });
143
133
  return {
144
134
  topLeft: mapPoint(rectangle.topLeft),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "10.39.0",
3
+ "version": "10.41.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -188,30 +188,15 @@ const mapRectangleToView = (
188
188
  ): Rectangle => {
189
189
  const viewWidthPx = viewWidth * density;
190
190
  const viewHeightPx = viewHeight * density;
191
- const scale =
192
- Platform.OS === 'ios'
193
- ? Math.max(viewWidthPx / imageWidth, viewHeightPx / imageHeight)
194
- : Math.min(viewWidthPx / imageWidth, viewHeightPx / imageHeight);
191
+ const scale = Math.max(viewWidthPx / imageWidth, viewHeightPx / imageHeight);
195
192
  const scaledImageWidth = imageWidth * scale;
196
193
  const scaledImageHeight = imageHeight * scale;
197
- const offsetX =
198
- Platform.OS === 'ios'
199
- ? (scaledImageWidth - viewWidthPx) / 2
200
- : (viewWidthPx - scaledImageWidth) / 2;
201
- const offsetY =
202
- Platform.OS === 'ios'
203
- ? (scaledImageHeight - viewHeightPx) / 2
204
- : (viewHeightPx - scaledImageHeight) / 2;
194
+ const offsetX = (scaledImageWidth - viewWidthPx) / 2;
195
+ const offsetY = (scaledImageHeight - viewHeightPx) / 2;
205
196
 
206
197
  const mapPoint = (point: Point): Point => ({
207
- x:
208
- Platform.OS === 'ios'
209
- ? (point.x * scale - offsetX) / density
210
- : (point.x * scale + offsetX) / density,
211
- y:
212
- Platform.OS === 'ios'
213
- ? (point.y * scale - offsetY) / density
214
- : (point.y * scale + offsetY) / density,
198
+ x: (point.x * scale - offsetX) / density,
199
+ y: (point.y * scale - offsetY) / density,
215
200
  });
216
201
 
217
202
  return {