react-native-rectangle-doc-scanner 7.48.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.
@@ -246,10 +246,9 @@ class CameraController(
246
246
  val previewSizes = streamConfigMap.getOutputSizes(SurfaceTexture::class.java)
247
247
  Log.d(TAG, "[CAMERA2] Available preview sizes: ${previewSizes?.take(10)?.joinToString { "${it.width}x${it.height}" }}")
248
248
 
249
- // Prefer 4:3 to match iOS FOV on phones; use view aspect on tablets to reduce crop.
250
- val isTablet = context.resources.configuration.smallestScreenWidthDp >= 600
251
- val targetPreviewAspect = if (isTablet) viewAspect else 4.0 / 3.0
252
- val minPreviewArea = if (isTablet) 1280 * 720 else 960 * 720
249
+ // Prefer 4:3 so height-based scaling fills the screen without stretching.
250
+ val targetPreviewAspect = 4.0 / 3.0
251
+ val minPreviewArea = 960 * 720
253
252
  previewSize = chooseBestSize(previewSizes, targetPreviewAspect, null, minPreviewArea, preferClosestAspect = true)
254
253
  ?: chooseBestSize(previewSizes, viewAspect, null, preferClosestAspect = true)
255
254
  ?: previewSizes?.maxByOrNull { it.width * it.height }
@@ -581,12 +580,12 @@ class CameraController(
581
580
  val isSwapped = rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270
582
581
  val bufferWidth = if (isSwapped) preview.height.toFloat() else preview.width.toFloat()
583
582
  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
583
+ val bufferRect = RectF(0f, 0f, bufferWidth, bufferHeight)
587
584
 
588
- matrix.setScale(scale, scale)
589
- 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)
590
589
 
591
590
  if (isSwapped) {
592
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.48.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",