react-native-rectangle-doc-scanner 7.29.0 → 7.30.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.
@@ -565,27 +565,25 @@ class CameraController(
565
565
  )
566
566
 
567
567
  val matrix = Matrix()
568
- val isSwapped = rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270
569
- val bufferWidth = if (isSwapped) preview.height.toFloat() else preview.width.toFloat()
570
- val bufferHeight = if (isSwapped) preview.width.toFloat() else preview.height.toFloat()
571
568
  val viewRect = RectF(0f, 0f, viewWidth, viewHeight)
572
- val bufferRect = RectF(0f, 0f, bufferWidth, bufferHeight)
573
569
  val centerX = viewRect.centerX()
574
570
  val centerY = viewRect.centerY()
575
571
 
576
- // Uniform scale to avoid stretching; then center-crop to fill the view.
577
- matrix.setRectToRect(bufferRect, viewRect, Matrix.ScaleToFit.CENTER)
578
- val scale = max(viewWidth / bufferWidth, viewHeight / bufferHeight)
579
- matrix.postScale(scale, scale, centerX, centerY)
580
-
581
- if (rotation != Surface.ROTATION_0) {
582
- val rotateDegrees = when (rotation) {
583
- Surface.ROTATION_90 -> -90f
584
- Surface.ROTATION_180 -> 180f
585
- Surface.ROTATION_270 -> 90f
586
- else -> 0f
587
- }
588
- matrix.postRotate(rotateDegrees, centerX, centerY)
572
+ if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
573
+ val bufferRect = RectF(0f, 0f, preview.height.toFloat(), preview.width.toFloat())
574
+ bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY())
575
+ matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL)
576
+ val scale = max(viewHeight / preview.height.toFloat(), viewWidth / preview.width.toFloat())
577
+ matrix.postScale(scale, scale, centerX, centerY)
578
+ matrix.postRotate(90f * (rotation - 2), centerX, centerY)
579
+ } else if (rotation == Surface.ROTATION_180) {
580
+ matrix.postRotate(180f, centerX, centerY)
581
+ } else {
582
+ val bufferRect = RectF(0f, 0f, preview.width.toFloat(), preview.height.toFloat())
583
+ bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY())
584
+ matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL)
585
+ val scale = max(viewWidth / preview.width.toFloat(), viewHeight / preview.height.toFloat())
586
+ matrix.postScale(scale, scale, centerX, centerY)
589
587
  }
590
588
 
591
589
  previewView.setTransform(matrix)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "7.29.0",
3
+ "version": "7.30.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",