react-native-rectangle-doc-scanner 3.208.0 → 3.209.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,29 @@ 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 bufferRect = if (rotationDegrees == 90 || rotationDegrees == 270) {
438
+ RectF(0f, 0f, previewSize.height.toFloat(), previewSize.width.toFloat())
441
439
  } else {
442
- bufferWidth
443
- }
444
- val rotatedBufferHeight = if (rotationDegrees == 90 || rotationDegrees == 270) {
445
- bufferWidth
446
- } else {
447
- bufferHeight
440
+ RectF(0f, 0f, previewSize.width.toFloat(), previewSize.height.toFloat())
448
441
  }
442
+ val viewRect = RectF(0f, 0f, viewWidth.toFloat(), viewHeight.toFloat())
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
+ // Scale to fill (center-crop) and then apply rotation around center.
450
+ matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL)
459
451
  if (rotationDegrees != 0) {
460
- matrix.postRotate(rotationDegrees.toFloat())
452
+ matrix.postRotate(rotationDegrees.toFloat(), centerX, centerY)
461
453
  }
462
- matrix.postScale(scale, scale)
463
- matrix.postTranslate(viewWidth / 2f, viewHeight / 2f)
464
454
 
465
455
  previewView.setTransform(matrix)
466
456
  Log.d(
467
457
  TAG,
468
- "[CAMERA2] transform view=${viewWidth}x${viewHeight} buffer=${bufferWidth}x${bufferHeight} " +
469
- "rotated=${rotatedBufferWidth}x${rotatedBufferHeight} rotation=$rotationDegrees scale=$scale"
458
+ "[CAMERA2] transform view=${viewWidth}x${viewHeight} buffer=${previewSize.width}x${previewSize.height} " +
459
+ "rotation=$rotationDegrees"
470
460
  )
471
461
  }
472
462
 
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.209.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",