react-native-rectangle-doc-scanner 4.7.0 → 4.8.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.
@@ -517,17 +517,27 @@ class CameraController(
517
517
  val bufferWidth = if (rotation == 90 || rotation == 270) preview.height.toFloat() else preview.width.toFloat()
518
518
  val bufferHeight = if (rotation == 90 || rotation == 270) preview.width.toFloat() else preview.height.toFloat()
519
519
 
520
- val viewRect = RectF(0f, 0f, viewWidth, viewHeight)
521
- val bufferRect = RectF(0f, 0f, bufferWidth, bufferHeight)
522
- val centerX = viewRect.centerX()
523
- val centerY = viewRect.centerY()
520
+ val centerX = viewWidth / 2f
521
+ val centerY = viewHeight / 2f
524
522
 
525
523
  val matrix = Matrix()
526
- bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY())
527
- matrix.setRectToRect(bufferRect, viewRect, Matrix.ScaleToFit.FILL)
524
+
525
+ // Apply transformations in correct order:
526
+ // 1. Translate to center
527
+ matrix.postTranslate(-centerX, -centerY)
528
+
529
+ // 2. Rotate around origin
530
+ if (rotation != 0) {
531
+ matrix.postRotate(rotation.toFloat())
532
+ }
533
+
534
+ // 3. Scale to fill view
528
535
  val scale = max(viewWidth / bufferWidth, viewHeight / bufferHeight)
529
- matrix.postScale(scale, scale, centerX, centerY)
530
- matrix.postRotate(rotation.toFloat(), centerX, centerY)
536
+ matrix.postScale(scale, scale)
537
+
538
+ // 4. Translate back to center
539
+ matrix.postTranslate(centerX, centerY)
540
+
531
541
  previewView.setTransform(matrix)
532
542
  }
533
543
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "4.7.0",
3
+ "version": "4.8.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",