react-native-rectangle-doc-scanner 7.49.0 → 7.50.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.
@@ -580,20 +580,12 @@ class CameraController(
580
580
  val isSwapped = rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270
581
581
  val bufferWidth = if (isSwapped) preview.height.toFloat() else preview.width.toFloat()
582
582
  val bufferHeight = if (isSwapped) preview.width.toFloat() else preview.height.toFloat()
583
- var scale = if (isSwapped) {
584
- // Scale by height to preserve aspect, then ensure width fills the view.
585
- viewHeight / bufferHeight
586
- } else {
587
- viewHeight / bufferHeight
588
- }
589
- if (bufferWidth * scale < viewWidth) {
590
- scale = viewWidth / bufferWidth
591
- }
592
- val scaledWidth = bufferWidth * scale
593
- val scaledHeight = bufferHeight * scale
583
+ val bufferRect = RectF(0f, 0f, bufferWidth, bufferHeight)
594
584
 
595
- matrix.setScale(scale, scale)
596
- matrix.postTranslate((viewWidth - scaledWidth) / 2f, (viewHeight - scaledHeight) / 2f)
585
+ // Center-fit, then uniformly scale to fill the view (no distortion).
586
+ matrix.setRectToRect(bufferRect, viewRect, Matrix.ScaleToFit.CENTER)
587
+ val scale = max(viewWidth / bufferWidth, viewHeight / bufferHeight)
588
+ matrix.postScale(scale, scale, centerX, centerY)
597
589
 
598
590
  if (isSwapped) {
599
591
  matrix.postRotate(90f * (rotation - 2), centerX, centerY)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "7.49.0",
3
+ "version": "7.50.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",