react-native-rectangle-doc-scanner 3.196.0 → 3.198.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.
@@ -357,10 +357,10 @@ class CameraController(
357
357
  return
358
358
  }
359
359
 
360
- val rotation = previewView.display?.rotation ?: Surface.ROTATION_0
360
+ val rotationDegrees = getRotationDegrees()
361
361
  val matrix = Matrix()
362
362
  val viewRect = RectF(0f, 0f, viewWidth.toFloat(), viewHeight.toFloat())
363
- val bufferRect = if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
363
+ val bufferRect = if (rotationDegrees == 90 || rotationDegrees == 270) {
364
364
  RectF(0f, 0f, previewSize.height.toFloat(), previewSize.width.toFloat())
365
365
  } else {
366
366
  RectF(0f, 0f, previewSize.width.toFloat(), previewSize.height.toFloat())
@@ -369,19 +369,13 @@ class CameraController(
369
369
  val centerY = viewRect.centerY()
370
370
 
371
371
  bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY())
372
- matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL)
372
+ // Fill the view while preserving aspect ratio (center-crop).
373
+ matrix.setRectToRect(bufferRect, viewRect, Matrix.ScaleToFit.FILL)
373
374
 
374
- val scale = if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
375
- maxOf(viewHeight.toFloat() / previewSize.height, viewWidth.toFloat() / previewSize.width)
376
- } else {
377
- maxOf(viewWidth.toFloat() / previewSize.width, viewHeight.toFloat() / previewSize.height)
378
- }
379
- matrix.postScale(scale, scale, centerX, centerY)
380
-
381
- when (rotation) {
382
- Surface.ROTATION_90 -> matrix.postRotate(90f, centerX, centerY)
383
- Surface.ROTATION_180 -> matrix.postRotate(180f, centerX, centerY)
384
- Surface.ROTATION_270 -> matrix.postRotate(270f, centerX, centerY)
375
+ when (rotationDegrees) {
376
+ 90 -> matrix.postRotate(90f, centerX, centerY)
377
+ 180 -> matrix.postRotate(180f, centerX, centerY)
378
+ 270 -> matrix.postRotate(270f, centerX, centerY)
385
379
  }
386
380
 
387
381
  previewView.setTransform(matrix)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "3.196.0",
3
+ "version": "3.198.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",