react-native-rectangle-doc-scanner 3.236.0 → 3.238.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.
@@ -7,6 +7,7 @@ import android.graphics.Bitmap
7
7
  import android.graphics.BitmapFactory
8
8
  import android.graphics.Matrix
9
9
  import android.graphics.SurfaceTexture
10
+ import android.graphics.RectF
10
11
  import android.graphics.ImageFormat
11
12
  import android.hardware.camera2.CameraCaptureSession
12
13
  import android.hardware.camera2.CameraCharacteristics
@@ -445,12 +446,17 @@ class CameraController(
445
446
  val bufferWidth = if (rotation == 90 || rotation == 270) preview.height.toFloat() else preview.width.toFloat()
446
447
  val bufferHeight = if (rotation == 90 || rotation == 270) preview.width.toFloat() else preview.height.toFloat()
447
448
 
448
- val scale = max(viewWidth / bufferWidth, viewHeight / bufferHeight)
449
+ val viewRect = RectF(0f, 0f, viewWidth, viewHeight)
450
+ val bufferRect = RectF(0f, 0f, bufferWidth, bufferHeight)
451
+ val centerX = viewRect.centerX()
452
+ val centerY = viewRect.centerY()
453
+
449
454
  val matrix = Matrix()
450
- val centerX = viewWidth / 2f
451
- val centerY = viewHeight / 2f
455
+ bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY())
456
+ matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL)
452
457
 
453
- matrix.setScale(scale, scale, centerX, centerY)
458
+ val scale = max(viewWidth / bufferWidth, viewHeight / bufferHeight)
459
+ matrix.postScale(scale, scale, centerX, centerY)
454
460
  matrix.postRotate(rotation.toFloat(), centerX, centerY)
455
461
  previewView.setTransform(matrix)
456
462
  }
@@ -242,7 +242,7 @@ class DocumentDetector {
242
242
  }
243
243
 
244
244
  val minDim = kotlin.math.min(viewWidth.toDouble(), viewHeight.toDouble())
245
- val angleThreshold = max(40.0, minDim * 0.06)
245
+ val angleThreshold = max(60.0, minDim * 0.08)
246
246
 
247
247
  val topYDiff = abs(rectangle.topRight.y - rectangle.topLeft.y)
248
248
  val bottomYDiff = abs(rectangle.bottomLeft.y - rectangle.bottomRight.y)
@@ -253,7 +253,7 @@ class DocumentDetector {
253
253
  return RectangleQuality.BAD_ANGLE
254
254
  }
255
255
 
256
- val margin = max(80.0, minDim * 0.08)
256
+ val margin = max(120.0, minDim * 0.12)
257
257
  if (rectangle.topLeft.y > margin ||
258
258
  rectangle.topRight.y > margin ||
259
259
  rectangle.bottomLeft.y < (viewHeight - margin) ||
@@ -291,10 +291,11 @@ exports.DocScanner = (0, react_1.forwardRef)(({ onCapture, overlayColor = DEFAUL
291
291
  if (payload.rectangleCoordinates || payload.rectangleOnScreen) {
292
292
  lastRectangleRef.current = payload.rectangleCoordinates ?? payload.rectangleOnScreen ?? null;
293
293
  }
294
- const isGoodRectangle = payload.lastDetectionType === 0;
295
- const hasValidRectangle = isGoodRectangle && rectangleOnScreen;
296
- // 그리드를 표시할 조건: 좋은 품질의 사각형이 화면에 있을 때만
297
- if (hasValidRectangle) {
294
+ const hasAnyRectangle = react_native_1.Platform.OS === 'android'
295
+ ? Boolean(rectangleOnScreen || payload.rectangleCoordinates)
296
+ : payload.lastDetectionType === 0 && Boolean(rectangleOnScreen);
297
+ // 그리드를 표시할 조건: 사각형이 잡히면 품질과 무관하게 표시
298
+ if (hasAnyRectangle) {
298
299
  // 기존 타임아웃 클리어
299
300
  if (rectangleClearTimeoutRef.current) {
300
301
  clearTimeout(rectangleClearTimeoutRef.current);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "3.236.0",
3
+ "version": "3.238.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
@@ -397,11 +397,13 @@ export const DocScanner = forwardRef<DocScannerHandle, Props>(
397
397
  lastRectangleRef.current = payload.rectangleCoordinates ?? payload.rectangleOnScreen ?? null;
398
398
  }
399
399
 
400
- const isGoodRectangle = payload.lastDetectionType === 0;
401
- const hasValidRectangle = isGoodRectangle && rectangleOnScreen;
400
+ const hasAnyRectangle =
401
+ Platform.OS === 'android'
402
+ ? Boolean(rectangleOnScreen || payload.rectangleCoordinates)
403
+ : payload.lastDetectionType === 0 && Boolean(rectangleOnScreen);
402
404
 
403
- // 그리드를 표시할 조건: 좋은 품질의 사각형이 화면에 있을 때만
404
- if (hasValidRectangle) {
405
+ // 그리드를 표시할 조건: 사각형이 잡히면 품질과 무관하게 표시
406
+ if (hasAnyRectangle) {
405
407
  // 기존 타임아웃 클리어
406
408
  if (rectangleClearTimeoutRef.current) {
407
409
  clearTimeout(rectangleClearTimeoutRef.current);