react-native-rectangle-doc-scanner 7.50.0 → 7.51.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.
@@ -578,19 +578,27 @@ class CameraController(
578
578
  val centerY = viewRect.centerY()
579
579
 
580
580
  val isSwapped = rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270
581
- val bufferWidth = if (isSwapped) preview.height.toFloat() else preview.width.toFloat()
582
- val bufferHeight = if (isSwapped) preview.width.toFloat() else preview.height.toFloat()
583
- val bufferRect = RectF(0f, 0f, bufferWidth, bufferHeight)
584
-
585
- // Center-fit, then uniformly scale to fill the view (no distortion).
586
- matrix.setRectToRect(bufferRect, viewRect, Matrix.ScaleToFit.CENTER)
587
- val scale = max(viewWidth / bufferWidth, viewHeight / bufferHeight)
588
- matrix.postScale(scale, scale, centerX, centerY)
589
-
590
581
  if (isSwapped) {
582
+ val bufferRect = RectF(0f, 0f, preview.height.toFloat(), preview.width.toFloat())
583
+ bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY())
584
+ matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL)
585
+ val scale = max(
586
+ viewHeight / preview.height.toFloat(),
587
+ viewWidth / preview.width.toFloat()
588
+ )
589
+ matrix.postScale(scale, scale, centerX, centerY)
591
590
  matrix.postRotate(90f * (rotation - 2), centerX, centerY)
592
- } else if (rotation == Surface.ROTATION_180) {
593
- matrix.postRotate(180f, centerX, centerY)
591
+ } else {
592
+ val bufferRect = RectF(0f, 0f, preview.width.toFloat(), preview.height.toFloat())
593
+ matrix.setRectToRect(bufferRect, viewRect, Matrix.ScaleToFit.CENTER)
594
+ val scale = max(
595
+ viewWidth / preview.width.toFloat(),
596
+ viewHeight / preview.height.toFloat()
597
+ )
598
+ matrix.postScale(scale, scale, centerX, centerY)
599
+ if (rotation == Surface.ROTATION_180) {
600
+ matrix.postRotate(180f, centerX, centerY)
601
+ }
594
602
  }
595
603
 
596
604
  previewView.setTransform(matrix)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "7.50.0",
3
+ "version": "7.51.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",