react-native-rectangle-doc-scanner 7.46.0 → 7.48.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.
@@ -575,51 +575,23 @@ class CameraController(
575
575
 
576
576
  val matrix = Matrix()
577
577
  val viewRect = RectF(0f, 0f, viewWidth, viewHeight)
578
- val bufferRect = RectF(0f, 0f, preview.width.toFloat(), preview.height.toFloat())
579
578
  val centerX = viewRect.centerX()
580
579
  val centerY = viewRect.centerY()
581
580
 
582
- if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) {
583
- // When rotated 90/270, preview dimensions are swapped
584
- val bufferWidth = preview.height.toFloat() // 1088
585
- val bufferHeight = preview.width.toFloat() // 1920
581
+ val isSwapped = rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270
582
+ val bufferWidth = if (isSwapped) preview.height.toFloat() else preview.width.toFloat()
583
+ val bufferHeight = if (isSwapped) preview.width.toFloat() else preview.height.toFloat()
584
+ val scale = max(viewWidth / bufferWidth, viewHeight / bufferHeight)
585
+ val scaledWidth = bufferWidth * scale
586
+ val scaledHeight = bufferHeight * scale
586
587
 
587
- // Android: Use 90% of view height for 10% vertical padding
588
- val effectiveHeight = viewHeight * 0.90f
588
+ matrix.setScale(scale, scale)
589
+ matrix.postTranslate((viewWidth - scaledWidth) / 2f, (viewHeight - scaledHeight) / 2f)
589
590
 
590
- // Calculate scale to fit the preview proportionally
591
- // Use min to ensure entire preview fits (no cropping, no stretching)
592
- val scaleX = viewWidth / bufferWidth
593
- val scaleY = effectiveHeight / bufferHeight
594
- val scale = min(scaleX, scaleY) // This maintains aspect ratio
595
-
596
- // Create swap buffer rect (before rotation: height x width)
597
- val bufferRect = RectF(0f, 0f, bufferHeight, bufferWidth)
598
-
599
- // Apply the transformation
600
- // 1. Scale uniformly to fit in view
601
- matrix.postScale(scale, scale)
602
-
603
- // 2. Rotate 90 degrees
604
- val scaledWidth = bufferWidth * scale
605
- val scaledHeight = bufferHeight * scale
606
- matrix.postRotate(90f * (rotation - 2), scaledHeight / 2f, scaledWidth / 2f)
607
-
608
- // 3. Center in view
609
- matrix.postTranslate(
610
- centerX - scaledHeight / 2f,
611
- centerY - scaledWidth / 2f
612
- )
613
-
614
- Log.d(TAG, "[TRANSFORM] Android: buffer=${bufferWidth}x${bufferHeight}, scale=$scale, final=${scaledWidth}x${scaledHeight}")
591
+ if (isSwapped) {
592
+ matrix.postRotate(90f * (rotation - 2), centerX, centerY)
615
593
  } else if (rotation == Surface.ROTATION_180) {
616
594
  matrix.postRotate(180f, centerX, centerY)
617
- } else {
618
- val scale = max(viewWidth / preview.width.toFloat(), viewHeight / preview.height.toFloat())
619
- val scaledWidth = preview.width.toFloat() * scale
620
- val scaledHeight = preview.height.toFloat() * scale
621
- matrix.setScale(scale, scale)
622
- matrix.postTranslate((viewWidth - scaledWidth) / 2f, (viewHeight - scaledHeight) / 2f)
623
595
  }
624
596
 
625
597
  previewView.setTransform(matrix)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "7.46.0",
3
+ "version": "7.48.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",