react-native-rectangle-doc-scanner 3.242.0 → 3.243.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.
@@ -487,7 +487,9 @@ class CameraController(
487
487
 
488
488
  val matrix = Matrix()
489
489
  bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY())
490
- matrix.setRectToRect(bufferRect, viewRect, Matrix.ScaleToFit.FILL)
490
+ matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL)
491
+ val scale = max(viewWidth / bufferWidth, viewHeight / bufferHeight)
492
+ matrix.postScale(scale, scale, centerX, centerY)
491
493
  matrix.postRotate(rotation.toFloat(), centerX, centerY)
492
494
  previewView.setTransform(matrix)
493
495
  }
@@ -312,7 +312,13 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context), L
312
312
  try {
313
313
  // Detect rectangle in captured image
314
314
  val bitmap = BitmapFactory.decodeFile(imageFile.absolutePath)
315
- val detectedRectangle = DocumentDetector.detectRectangle(bitmap)
315
+ ?: throw IllegalStateException("decode_failed")
316
+ val detectedRectangle = try {
317
+ DocumentDetector.detectRectangle(bitmap)
318
+ } catch (e: Exception) {
319
+ Log.w(TAG, "Rectangle detection failed, using original image", e)
320
+ null
321
+ }
316
322
 
317
323
  // Process image with detected rectangle
318
324
  val shouldCrop = detectedRectangle != null && stableCounter > 0
@@ -194,7 +194,8 @@ object ImageProcessor {
194
194
  saturation: Float = 1f,
195
195
  shouldCrop: Boolean = true
196
196
  ): ProcessedImage {
197
- var initialBitmap = BitmapFactory.decodeFile(imagePath)
197
+ val initialBitmap = BitmapFactory.decodeFile(imagePath)
198
+ ?: throw IllegalStateException("decode_failed")
198
199
  var croppedBitmap = initialBitmap
199
200
 
200
201
  // Apply perspective correction if rectangle detected and cropping enabled
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-rectangle-doc-scanner",
3
- "version": "3.242.0",
3
+ "version": "3.243.0",
4
4
  "description": "Native-backed document scanner for React Native with customizable overlays.",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",