react-native-rectangle-doc-scanner 4.5.0 → 4.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.
@@ -524,7 +524,7 @@ class CameraController(
524
524
 
525
525
  val matrix = Matrix()
526
526
  bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY())
527
- matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL)
527
+ matrix.setRectToRect(bufferRect, viewRect, Matrix.ScaleToFit.FILL)
528
528
  val scale = max(viewWidth / bufferWidth, viewHeight / bufferHeight)
529
529
  matrix.postScale(scale, scale, centerX, centerY)
530
530
  matrix.postRotate(rotation.toFloat(), centerX, centerY)
@@ -559,10 +559,13 @@ class CameraController(
559
559
  }
560
560
 
561
561
  if (preferClosestAspect) {
562
- return capped.minWithOrNull(
563
- compareBy<Size> { aspectDiff(it) }
564
- .thenByDescending { it.width * it.height }
565
- )
562
+ val maxAreaOverall = capped.maxOf { it.width * it.height }
563
+ val minAcceptableArea = max(640 * 480, (maxAreaOverall * 0.1).toInt())
564
+ val sized = capped.filter { it.width * it.height >= minAcceptableArea }
565
+ val pool = if (sized.isNotEmpty()) sized else capped
566
+ val bestDiff = pool.minOf { aspectDiff(it) }
567
+ val close = pool.filter { aspectDiff(it) <= bestDiff + 0.05 }
568
+ return close.maxByOrNull { it.width * it.height } ?: pool.maxByOrNull { it.width * it.height }
566
569
  }
567
570
 
568
571
  val matching = capped.filter { aspectDiff(it) <= ANALYSIS_ASPECT_TOLERANCE }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "4.5.0",
3
+ "version": "4.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",