react-native-rectangle-doc-scanner 13.1.0 → 13.2.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.
@@ -494,10 +494,10 @@ class CameraController(
494
494
  val finalWidth = imageWidth
495
495
  val finalHeight = imageHeight
496
496
 
497
- // Apply fit-center scaling to match TextureView display.
497
+ // Apply center-crop scaling to match TextureView display.
498
498
  val scaleX = viewWidth / finalWidth.toFloat()
499
499
  val scaleY = viewHeight / finalHeight.toFloat()
500
- val scale = scaleX.coerceAtMost(scaleY)
500
+ val scale = scaleX.coerceAtLeast(scaleY)
501
501
 
502
502
  val scaledWidth = finalWidth * scale
503
503
  val scaledHeight = finalHeight * scale
@@ -583,26 +583,17 @@ class CameraController(
583
583
  bufferHeight
584
584
  }
585
585
 
586
- // Scale to fit within the view while maintaining aspect ratio (no zoom/crop)
586
+ // Scale to fill the view while maintaining aspect ratio (center-crop)
587
587
  val scaleX = viewWidth.toFloat() / rotatedBufferWidth.toFloat()
588
588
  val scaleY = viewHeight.toFloat() / rotatedBufferHeight.toFloat()
589
- val scale = scaleX.coerceAtMost(scaleY) // Use min to fit
589
+ val scale = scaleX.coerceAtLeast(scaleY) // Use max to fill
590
590
 
591
591
  Log.d(TAG, "[TRANSFORM] Rotated buffer: ${rotatedBufferWidth}x${rotatedBufferHeight}, ScaleX: $scaleX, ScaleY: $scaleY, Using: $scale")
592
592
 
593
593
  matrix.postScale(scale, scale, centerX, centerY)
594
594
 
595
- // Track the actual preview viewport within the view for clipping overlays.
596
- val scaledWidth = rotatedBufferWidth * scale
597
- val scaledHeight = rotatedBufferHeight * scale
598
- val offsetX = (viewWidth - scaledWidth) / 2f
599
- val offsetY = (viewHeight - scaledHeight) / 2f
600
- previewViewport = android.graphics.RectF(
601
- offsetX,
602
- offsetY,
603
- offsetX + scaledWidth,
604
- offsetY + scaledHeight
605
- )
595
+ // With center-crop, the preview fully covers the view bounds.
596
+ previewViewport = android.graphics.RectF(0f, 0f, viewWidth.toFloat(), viewHeight.toFloat())
606
597
 
607
598
  textureView.setTransform(matrix)
608
599
  Log.d(TAG, "[TRANSFORM] Transform applied successfully")
@@ -150,19 +150,13 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context), L
150
150
  private fun layoutPreviewAndOverlay(viewWidth: Int, viewHeight: Int) {
151
151
  if (viewWidth <= 0 || viewHeight <= 0) return
152
152
 
153
- val targetWidth: Int
154
- val targetHeight: Int
155
- val aspectHeight = (viewWidth / PREVIEW_ASPECT_RATIO).toInt()
156
- if (aspectHeight <= viewHeight) {
157
- targetWidth = viewWidth
158
- targetHeight = aspectHeight
159
- } else {
160
- targetWidth = (viewHeight * PREVIEW_ASPECT_RATIO).toInt()
161
- targetHeight = viewHeight
162
- }
153
+ // Always fill width to avoid left/right letterboxing.
154
+ val targetWidth = viewWidth
155
+ val targetHeight = (viewWidth / PREVIEW_ASPECT_RATIO).toInt()
163
156
 
164
- val left = (viewWidth - targetWidth) / 2
165
- val top = if (targetHeight < viewHeight) 0 else (viewHeight - targetHeight) / 2
157
+ val left = 0
158
+ // Center vertically; allows top/bottom crop when targetHeight > viewHeight.
159
+ val top = (viewHeight - targetHeight) / 2
166
160
  val right = left + targetWidth
167
161
  val bottom = top + targetHeight
168
162
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "13.1.0",
3
+ "version": "13.2.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",