react-native-rectangle-doc-scanner 3.208.0 → 3.210.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.
@@ -434,39 +434,34 @@ class CameraController(
434
434
  }
435
435
 
436
436
  val rotationDegrees = getRotationDegrees()
437
- val bufferWidth = previewSize.width.toFloat()
438
- val bufferHeight = previewSize.height.toFloat()
439
- val rotatedBufferWidth = if (rotationDegrees == 90 || rotationDegrees == 270) {
440
- bufferHeight
437
+ val viewRect = RectF(0f, 0f, viewWidth.toFloat(), viewHeight.toFloat())
438
+ val bufferRect = if (rotationDegrees == 90 || rotationDegrees == 270) {
439
+ RectF(0f, 0f, previewSize.height.toFloat(), previewSize.width.toFloat())
441
440
  } else {
442
- bufferWidth
443
- }
444
- val rotatedBufferHeight = if (rotationDegrees == 90 || rotationDegrees == 270) {
445
- bufferWidth
446
- } else {
447
- bufferHeight
441
+ RectF(0f, 0f, previewSize.width.toFloat(), previewSize.height.toFloat())
448
442
  }
443
+ val centerX = viewRect.centerX()
444
+ val centerY = viewRect.centerY()
449
445
 
450
- // Fill the view like the default camera preview (center-crop).
451
- val scale = kotlin.math.max(
452
- viewWidth.toFloat() / rotatedBufferWidth,
453
- viewHeight.toFloat() / rotatedBufferHeight
454
- )
446
+ bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY())
455
447
 
456
448
  val matrix = Matrix()
457
- // Center buffer at origin, rotate, scale to fit, then move to view center.
458
- matrix.postTranslate(-bufferWidth / 2f, -bufferHeight / 2f)
449
+ // Map buffer to view, then scale to fill and rotate around the center.
450
+ matrix.setRectToRect(bufferRect, viewRect, Matrix.ScaleToFit.FILL)
451
+ val scale = kotlin.math.max(
452
+ viewWidth.toFloat() / bufferRect.width(),
453
+ viewHeight.toFloat() / bufferRect.height()
454
+ )
455
+ matrix.postScale(scale, scale, centerX, centerY)
459
456
  if (rotationDegrees != 0) {
460
- matrix.postRotate(rotationDegrees.toFloat())
457
+ matrix.postRotate(rotationDegrees.toFloat(), centerX, centerY)
461
458
  }
462
- matrix.postScale(scale, scale)
463
- matrix.postTranslate(viewWidth / 2f, viewHeight / 2f)
464
459
 
465
460
  previewView.setTransform(matrix)
466
461
  Log.d(
467
462
  TAG,
468
- "[CAMERA2] transform view=${viewWidth}x${viewHeight} buffer=${bufferWidth}x${bufferHeight} " +
469
- "rotated=${rotatedBufferWidth}x${rotatedBufferHeight} rotation=$rotationDegrees scale=$scale"
463
+ "[CAMERA2] transform view=${viewWidth}x${viewHeight} buffer=${previewSize.width}x${previewSize.height} " +
464
+ "rotation=$rotationDegrees scale=$scale"
470
465
  )
471
466
  }
472
467
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "3.208.0",
3
+ "version": "3.210.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",