react-native-rectangle-doc-scanner 7.38.0 → 7.39.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.
@@ -569,19 +569,24 @@ class CameraController(
569
569
  val bufferWidth = preview.width.toFloat()
570
570
  val bufferHeight = preview.height.toFloat()
571
571
  val isSwapped = rotationDegrees == 90 || rotationDegrees == 270
572
- val rotatedWidth = if (isSwapped) bufferHeight else bufferWidth
573
- val rotatedHeight = if (isSwapped) bufferWidth else bufferHeight
574
- val scale = max(viewWidth / rotatedWidth, viewHeight / rotatedHeight)
575
- val rotateDegrees = -rotationDegrees.toFloat()
576
572
 
577
- // Rotate around buffer center, then scale uniformly and center in the view (aspect-fill).
573
+ val viewRect = RectF(0f, 0f, viewWidth, viewHeight)
574
+ val bufferRect = if (isSwapped) {
575
+ RectF(0f, 0f, bufferHeight, bufferWidth)
576
+ } else {
577
+ RectF(0f, 0f, bufferWidth, bufferHeight)
578
+ }
579
+ val centerX = viewRect.centerX()
580
+ val centerY = viewRect.centerY()
581
+ val scale = max(viewWidth / bufferRect.width(), viewHeight / bufferRect.height())
582
+
583
+ // Map buffer to view with uniform scale (aspect-fill), then rotate in view space.
578
584
  val matrix = Matrix()
579
- matrix.postTranslate(-bufferWidth / 2f, -bufferHeight / 2f)
580
- if (rotateDegrees != 0f) {
581
- matrix.postRotate(rotateDegrees)
585
+ matrix.setRectToRect(bufferRect, viewRect, Matrix.ScaleToFit.CENTER)
586
+ matrix.postScale(scale, scale, centerX, centerY)
587
+ if (rotationDegrees != 0) {
588
+ matrix.postRotate(rotationDegrees.toFloat(), centerX, centerY)
582
589
  }
583
- matrix.postScale(scale, scale)
584
- matrix.postTranslate(viewWidth / 2f, viewHeight / 2f)
585
590
 
586
591
  previewView.setTransform(matrix)
587
592
  Log.d(TAG, "[TRANSFORM] Matrix applied successfully")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "7.38.0",
3
+ "version": "7.39.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",