react-native-rectangle-doc-scanner 7.50.0 → 7.52.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.
@@ -559,14 +559,7 @@ class CameraController(
559
559
  val preview = previewSize ?: return
560
560
  if (viewWidth == 0f || viewHeight == 0f) return
561
561
 
562
- val rotation = previewView.display?.rotation ?: Surface.ROTATION_0
563
- val rotationDegrees = when (rotation) {
564
- Surface.ROTATION_0 -> 0
565
- Surface.ROTATION_90 -> 90
566
- Surface.ROTATION_180 -> 180
567
- Surface.ROTATION_270 -> 270
568
- else -> 0
569
- }
562
+ val rotationDegrees = computeRotationDegrees()
570
563
  Log.d(
571
564
  TAG,
572
565
  "[TRANSFORM] rotation=$rotationDegrees view=${viewWidth}x${viewHeight} preview=${preview.width}x${preview.height}"
@@ -577,20 +570,19 @@ class CameraController(
577
570
  val centerX = viewRect.centerX()
578
571
  val centerY = viewRect.centerY()
579
572
 
580
- val isSwapped = rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270
573
+ val isSwapped = rotationDegrees == 90 || rotationDegrees == 270
581
574
  val bufferWidth = if (isSwapped) preview.height.toFloat() else preview.width.toFloat()
582
575
  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
576
  val scale = max(viewWidth / bufferWidth, viewHeight / bufferHeight)
588
- matrix.postScale(scale, scale, centerX, centerY)
577
+ val scaledWidth = bufferWidth * scale
578
+ val scaledHeight = bufferHeight * scale
579
+ val dx = (viewWidth - scaledWidth) / 2f
580
+ val dy = (viewHeight - scaledHeight) / 2f
589
581
 
590
- if (isSwapped) {
591
- matrix.postRotate(90f * (rotation - 2), centerX, centerY)
592
- } else if (rotation == Surface.ROTATION_180) {
593
- matrix.postRotate(180f, centerX, centerY)
582
+ matrix.setScale(scale, scale)
583
+ matrix.postTranslate(dx, dy)
584
+ if (rotationDegrees != 0) {
585
+ matrix.postRotate(rotationDegrees.toFloat(), centerX, centerY)
594
586
  }
595
587
 
596
588
  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.52.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",