react-native-rectangle-doc-scanner 3.137.0 → 3.139.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.
|
@@ -28,8 +28,8 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
28
28
|
|
|
29
29
|
// Props (matching iOS)
|
|
30
30
|
var overlayColor: Int = Color.parseColor("#80FFFFFF")
|
|
31
|
-
var
|
|
32
|
-
var
|
|
31
|
+
private var isTorchEnabled: Boolean = false
|
|
32
|
+
private var isUsingFrontCamera: Boolean = false
|
|
33
33
|
var useBase64: Boolean = false
|
|
34
34
|
var saveInAppDocument: Boolean = false
|
|
35
35
|
var captureMultiple: Boolean = false
|
|
@@ -83,7 +83,10 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
83
83
|
handleDetectionResult(rectangle, imageWidth, imageHeight)
|
|
84
84
|
}
|
|
85
85
|
lastDetectionTimestamp = 0L
|
|
86
|
-
cameraController?.startCamera(
|
|
86
|
+
cameraController?.startCamera(isUsingFrontCamera, true)
|
|
87
|
+
if (isTorchEnabled) {
|
|
88
|
+
cameraController?.setTorchEnabled(true)
|
|
89
|
+
}
|
|
87
90
|
|
|
88
91
|
Log.d(TAG, "Camera setup completed")
|
|
89
92
|
} catch (e: Exception) {
|
|
@@ -317,13 +320,13 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
317
320
|
}
|
|
318
321
|
|
|
319
322
|
fun setEnableTorch(enabled: Boolean) {
|
|
320
|
-
|
|
323
|
+
isTorchEnabled = enabled
|
|
321
324
|
cameraController?.setTorchEnabled(enabled)
|
|
322
325
|
}
|
|
323
326
|
|
|
324
327
|
fun setUseFrontCam(enabled: Boolean) {
|
|
325
|
-
if (
|
|
326
|
-
|
|
328
|
+
if (isUsingFrontCamera != enabled) {
|
|
329
|
+
isUsingFrontCamera = enabled
|
|
327
330
|
cameraController?.stopCamera()
|
|
328
331
|
setupCamera()
|
|
329
332
|
}
|
|
@@ -334,7 +337,10 @@ class DocumentScannerView(context: ThemedReactContext) : FrameLayout(context) {
|
|
|
334
337
|
cameraController?.onFrameAnalyzed = { rectangle, imageWidth, imageHeight ->
|
|
335
338
|
handleDetectionResult(rectangle, imageWidth, imageHeight)
|
|
336
339
|
}
|
|
337
|
-
cameraController?.startCamera(
|
|
340
|
+
cameraController?.startCamera(isUsingFrontCamera, true)
|
|
341
|
+
if (isTorchEnabled) {
|
|
342
|
+
cameraController?.setTorchEnabled(true)
|
|
343
|
+
}
|
|
338
344
|
}
|
|
339
345
|
|
|
340
346
|
fun stopCamera() {
|
|
@@ -125,7 +125,8 @@ object ImageProcessor {
|
|
|
125
125
|
val dstMat = Mat()
|
|
126
126
|
srcMat.convertTo(dstMat, -1, contrast.toDouble(), brightness * 255.0)
|
|
127
127
|
|
|
128
|
-
val
|
|
128
|
+
val safeConfig = bitmap.config ?: Bitmap.Config.ARGB_8888
|
|
129
|
+
val resultBitmap = Bitmap.createBitmap(bitmap.width, bitmap.height, safeConfig)
|
|
129
130
|
Utils.matToBitmap(dstMat, resultBitmap)
|
|
130
131
|
|
|
131
132
|
srcMat.release()
|
package/package.json
CHANGED