dynamsoft-capture-vision-react-native 3.4.1200 → 3.4.3000
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.
- package/LICENSE +5 -5
- package/README.md +62 -66
- package/android/README.md +14 -14
- package/android/build.gradle +167 -163
- package/android/gradle.properties +20 -20
- package/android/settings.gradle +5 -5
- package/android/src/main/AndroidManifest.xml +6 -6
- package/android/src/main/AndroidManifest_noPackage.xml +5 -5
- package/android/src/main/cpp/CMakeLists.txt +21 -21
- package/android/src/main/cpp/ImgHO.cpp +94 -94
- package/android/src/main/cpp/ImgHO.h +34 -34
- package/android/src/main/cpp/JsiCore.cpp +296 -296
- package/android/src/main/cpp/JsiCore.h +51 -51
- package/android/src/main/cpp/JsiCvr.cpp +332 -332
- package/android/src/main/cpp/JsiCvr.h +54 -54
- package/android/src/main/cpp/JsiDbr.cpp +283 -283
- package/android/src/main/cpp/JsiDbr.h +26 -26
- package/android/src/main/cpp/JsiDce.cpp +59 -59
- package/android/src/main/cpp/JsiDce.h +17 -17
- package/android/src/main/cpp/JsiDcp.cpp +51 -51
- package/android/src/main/cpp/JsiDcp.h +31 -31
- package/android/src/main/cpp/JsiDdn.cpp +50 -50
- package/android/src/main/cpp/JsiDdn.h +28 -28
- package/android/src/main/cpp/JsiDlr.cpp +60 -60
- package/android/src/main/cpp/JsiDlr.h +26 -26
- package/android/src/main/cpp/JsiUtility.cpp +604 -604
- package/android/src/main/cpp/JsiUtility.h +26 -26
- package/android/src/main/cpp/RawBuffer.cpp +23 -23
- package/android/src/main/cpp/RawBuffer.h +24 -24
- package/android/src/main/cpp/android_log.h +14 -14
- package/android/src/main/dysJniLibs/debug/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/debug/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/debug/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/debug/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/release/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/release/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/release/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibs/release/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/debug/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/debug/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/debug/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/debug/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/release/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/release/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/release/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor81/release/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/debug/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/debug/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/debug/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/debug/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/release/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/release/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/release/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor82/release/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/debug/arm64-v8a/librn_dys.so +3 -0
- package/android/src/main/dysJniLibsFor86/debug/armeabi-v7a/librn_dys.so +3 -0
- package/android/src/main/dysJniLibsFor86/debug/x86/librn_dys.so +3 -0
- package/android/src/main/dysJniLibsFor86/debug/x86_64/librn_dys.so +3 -0
- package/android/src/main/dysJniLibsFor86/release/arm64-v8a/librn_dys.so +3 -0
- package/android/src/main/dysJniLibsFor86/release/armeabi-v7a/librn_dys.so +3 -0
- package/android/src/main/dysJniLibsFor86/release/x86/librn_dys.so +3 -0
- package/android/src/main/dysJniLibsFor86/release/x86_64/librn_dys.so +3 -0
- package/android/src/main/java/com/dynamsoft/reactnativelib/CVRModule.kt +137 -137
- package/android/src/main/java/com/dynamsoft/reactnativelib/CameraViewManager.kt +62 -62
- package/android/src/main/java/com/dynamsoft/reactnativelib/DCEModule.kt +125 -125
- package/android/src/main/java/com/dynamsoft/reactnativelib/DynamsoftBaseModule.kt +8 -8
- package/android/src/main/java/com/dynamsoft/reactnativelib/ISAModule.kt +73 -73
- package/android/src/main/java/com/dynamsoft/reactnativelib/ImageEditorViewManager.kt +14 -14
- package/android/src/main/java/com/dynamsoft/reactnativelib/ImageEditorViewModule.kt +35 -35
- package/android/src/main/java/com/dynamsoft/reactnativelib/ImageManagerModule.kt +15 -15
- package/android/src/main/java/com/dynamsoft/reactnativelib/LicenseModule.kt +29 -29
- package/android/src/main/java/com/dynamsoft/reactnativelib/MultiCrossFilterModule.kt +83 -83
- package/android/src/main/java/com/dynamsoft/reactnativelib/ReactNativeDcvPackage.kt +32 -32
- package/android/src/main/java/com/dynamsoft/reactnativelib/VersionsModule.kt +41 -41
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/Basic.kt +44 -44
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForCore.kt +50 -50
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForCvr.kt +129 -129
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDBR.kt +157 -157
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDCE.kt +110 -110
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDCP.kt +49 -49
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDDN.kt +85 -85
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ForDLR.kt +72 -72
- package/android/src/main/java/com/dynamsoft/reactnativelib/basicutils/ImageUtil.kt +58 -58
- package/android/src/main/java/com/dynamsoft/reactnativelib/core/ImageSourceAdapterModuleImpl.kt +120 -120
- package/android/src/main/java/com/dynamsoft/reactnativelib/cvr/CaptureVisionRouterModuleImpl.kt +306 -306
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraEnhancerModuleImpl.kt +247 -247
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraLifeCycleOwner.java +14 -14
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/CameraViewManagerImpl.kt +77 -77
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/ImageEditorViewManagerImpl.kt +15 -15
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/ImageEditorViewModuleImpl.kt +110 -110
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/RNCameraView.kt +20 -20
- package/android/src/main/java/com/dynamsoft/reactnativelib/dce/RNImageEditorView.kt +19 -19
- package/android/src/main/java/com/dynamsoft/reactnativelib/license/LicenseModuleImpl.kt +39 -39
- package/android/src/main/java/com/dynamsoft/reactnativelib/utility/ImageManagerModuleImpl.kt +120 -120
- package/android/src/main/java/com/dynamsoft/reactnativelib/utility/MultiCrossFilterModuleImpl.kt +111 -111
- package/app.plugin.js +21 -21
- package/dynamsoft-capture-vision-react-native.podspec +24 -24
- package/ios/CPP/DSImageData+HostObject.h +18 -18
- package/ios/CPP/DSImageData+HostObject.mm +38 -38
- package/ios/CPP/ImageDataHostObject.cpp +87 -87
- package/ios/CPP/ImageDataHostObject.hpp +35 -35
- package/ios/CPP/MutableRawBuffer.cpp +23 -23
- package/ios/CPP/MutableRawBuffer.hpp +23 -23
- package/ios/CPP/RNDynamsoft+JSI.h +22 -22
- package/ios/CPP/RNDynamsoft+JSI.mm +303 -303
- package/ios/CPP/RNDynamsoft+Json.h +93 -93
- package/ios/CPP/RNDynamsoft+Json.m +733 -733
- package/ios/CPP/YeetJSIUtils.h +56 -56
- package/ios/CPP/YeetJSIUtils.mm +208 -208
- package/ios/RNDynamsoftCameraView.h +31 -31
- package/ios/RNDynamsoftCameraView.m +108 -108
- package/ios/RNDynamsoftCameraViewManager.h +14 -14
- package/ios/RNDynamsoftCameraViewManager.m +195 -195
- package/ios/RNDynamsoftCaptureVisionRouter.h +18 -18
- package/ios/RNDynamsoftCaptureVisionRouter.mm +532 -532
- package/ios/RNDynamsoftImageEditorView.h +17 -17
- package/ios/RNDynamsoftImageEditorView.m +25 -25
- package/ios/RNDynamsoftImageEditorViewManager.h +14 -14
- package/ios/RNDynamsoftImageEditorViewManager.mm +183 -183
- package/ios/RNDynamsoftImageManager.h +14 -14
- package/ios/RNDynamsoftImageManager.mm +369 -369
- package/ios/RNDynamsoftImageSourceAdapter.h +19 -19
- package/ios/RNDynamsoftImageSourceAdapter.mm +255 -255
- package/ios/RNDynamsoftLicense.h +14 -14
- package/ios/RNDynamsoftLicense.m +62 -62
- package/ios/RNDynamsoftMultiCrossFilter.h +14 -14
- package/ios/RNDynamsoftMultiCrossFilter.m +145 -145
- package/ios/RNDynamsoftVersions.h +13 -13
- package/ios/RNDynamsoftVersions.m +27 -27
- package/package.json +48 -48
- package/src/NativeDynamsoftVersionsModule.tsx +20 -20
- package/src/VersionsModule.tsx +7 -7
- package/src/core/CapturedResultBase.tsx +18 -18
- package/src/core/CapturedResultItem.tsx +23 -23
- package/src/core/CoreModule.tsx +9 -9
- package/src/core/DSRect.tsx +29 -29
- package/src/core/EnumCaptureResultItemType.tsx +52 -52
- package/src/core/EnumColourChannelUsageType.tsx +26 -26
- package/src/core/EnumCrossVerificationStatus.tsx +46 -46
- package/src/core/EnumGrayscaleEnhancementMode.tsx +46 -46
- package/src/core/EnumGrayscaleTransformationMode.tsx +35 -35
- package/src/core/EnumImageFileFormat.tsx +6 -6
- package/src/core/EnumPixelFormat.tsx +53 -53
- package/src/core/ImageData.tsx +87 -87
- package/src/core/ImageSourceAdapter.tsx +160 -160
- package/src/core/NativeDynamsoftImageSourceAdapterModule.tsx +29 -29
- package/src/core/Point.tsx +13 -13
- package/src/core/Quadrilateral.tsx +12 -12
- package/src/core/index.tsx +18 -18
- package/src/cvr/CaptureVisionRouter.tsx +683 -683
- package/src/cvr/CaptureVisionRouterModule.tsx +9 -9
- package/src/cvr/CapturedResult.tsx +123 -123
- package/src/cvr/CapturedResultFilter.tsx +13 -13
- package/src/cvr/CapturedResultReceiver.tsx +71 -71
- package/src/cvr/EnumPresetTemplate.tsx +81 -81
- package/src/cvr/NativeDynamsoftCaptureVisionRouterModule.tsx +25 -25
- package/src/cvr/SimplifiedCaptureVisionSettings.tsx +61 -61
- package/src/cvr/index.tsx +11 -11
- package/src/dbr/BarcodeDetails.tsx +51 -51
- package/src/dbr/BarcodeReaderModule.tsx +9 -9
- package/src/dbr/BarcodeResultItem.tsx +65 -65
- package/src/dbr/DecodedBarcodesResult.tsx +14 -14
- package/src/dbr/ECISegment.tsx +23 -23
- package/src/dbr/EnumBarcodeFormat.tsx +112 -112
- package/src/dbr/EnumDeblurMode.tsx +29 -29
- package/src/dbr/EnumLocalizationMode.tsx +27 -27
- package/src/dbr/EnumQRCodeErrorCorrectionLevel.tsx +6 -6
- package/src/dbr/SimplifiedBarcodeReaderSettings.tsx +80 -80
- package/src/dbr/index.tsx +9 -9
- package/src/dce/CameraEnhancer.tsx +254 -254
- package/src/dce/CameraEnhancerModule.tsx +9 -9
- package/src/dce/CameraView.tsx +100 -100
- package/src/dce/DynamsoftCameraViewNativeComponent.ts +96 -96
- package/src/dce/DynamsoftImageEditorViewNativeComponent.ts +9 -9
- package/src/dce/EnumCameraPosition.tsx +25 -25
- package/src/dce/EnumDrawingLayerId.tsx +17 -17
- package/src/dce/EnumEnhancedFeatures.tsx +24 -24
- package/src/dce/EnumFocusMode.tsx +6 -6
- package/src/dce/EnumResolution.tsx +8 -8
- package/src/dce/EnumTorchState.tsx +10 -10
- package/src/dce/FeedBack.tsx +28 -28
- package/src/dce/ImageEditorView.tsx +131 -131
- package/src/dce/NativeDynamsoftCameraViewModule.tsx +47 -47
- package/src/dce/NativeDynamsoftImageEditorViewModule.ts +9 -9
- package/src/dce/index.tsx +13 -13
- package/src/dcp/CodeParserDedicatorModule.tsx +9 -9
- package/src/dcp/CodeParserModule.tsx +9 -9
- package/src/dcp/EnumMappingStatus.tsx +14 -14
- package/src/dcp/EnumValidationStatus.tsx +14 -14
- package/src/dcp/ParsedResult.tsx +14 -14
- package/src/dcp/ParsedResultItem.tsx +50 -50
- package/src/dcp/index.tsx +8 -8
- package/src/ddn/DeskewedImageResultItem.tsx +40 -40
- package/src/ddn/DetectedQuadResultItem.tsx +31 -31
- package/src/ddn/DocumentNormalizerModule.tsx +9 -9
- package/src/ddn/EnhancedImageResultItem.tsx +20 -20
- package/src/ddn/EnumImageColourMode.tsx +14 -14
- package/src/ddn/ProcessedDocumentResult.tsx +27 -27
- package/src/ddn/SimplifiedDocumentNormalizerSettings.tsx +65 -65
- package/src/ddn/index.tsx +11 -11
- package/src/dip/ImageProcessingModule.tsx +9 -9
- package/src/dip/index.tsx +1 -1
- package/src/dlr/CharacterResult.tsx +28 -28
- package/src/dlr/LabelRecognizerModule.tsx +9 -9
- package/src/dlr/RecognizedTextLinesResult.tsx +19 -19
- package/src/dlr/SimplifiedLabelRecognizerSettings.tsx +33 -33
- package/src/dlr/TextLineResultItem.tsx +41 -41
- package/src/dlr/index.tsx +8 -8
- package/src/index.tsx +13 -13
- package/src/license/LicenseManager.tsx +49 -49
- package/src/license/LicenseModule.tsx +9 -9
- package/src/license/NativeDynamsoftLicenseModule.tsx +7 -7
- package/src/license/index.tsx +7 -7
- package/src/utility/CrossVerificationCriteria.tsx +11 -11
- package/src/utility/EnumFilterType.tsx +5 -5
- package/src/utility/ImageManager.tsx +348 -348
- package/src/utility/MultiFrameResultCrossFilter.tsx +183 -183
- package/src/utility/NativeDynamsoftImageManagerModule.tsx +7 -7
- package/src/utility/NativeDynamsoftMultiCrossFilterModule.tsx +18 -18
- package/src/utility/UtilityModule.tsx +9 -9
- package/src/utility/index.tsx +4 -4
- package/android/.gitignore +0 -4
package/android/src/main/java/com/dynamsoft/reactnativelib/dce/ImageEditorViewManagerImpl.kt
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
package com.dynamsoft.reactnativelib.dce
|
|
2
|
-
|
|
3
|
-
import com.dynamsoft.dce.ImageEditorView
|
|
4
|
-
import com.facebook.react.uimanager.ThemedReactContext
|
|
5
|
-
|
|
6
|
-
class ImageEditorViewManagerImpl {
|
|
7
|
-
companion object {
|
|
8
|
-
const val TAG = "DynamsoftImageEditorView"
|
|
9
|
-
}
|
|
10
|
-
fun getName() = TAG
|
|
11
|
-
fun createViewInstance(context: ThemedReactContext): ImageEditorView {
|
|
12
|
-
return RNImageEditorView(context)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
}
|
|
1
|
+
package com.dynamsoft.reactnativelib.dce
|
|
2
|
+
|
|
3
|
+
import com.dynamsoft.dce.ImageEditorView
|
|
4
|
+
import com.facebook.react.uimanager.ThemedReactContext
|
|
5
|
+
|
|
6
|
+
class ImageEditorViewManagerImpl {
|
|
7
|
+
companion object {
|
|
8
|
+
const val TAG = "DynamsoftImageEditorView"
|
|
9
|
+
}
|
|
10
|
+
fun getName() = TAG
|
|
11
|
+
fun createViewInstance(context: ThemedReactContext): ImageEditorView {
|
|
12
|
+
return RNImageEditorView(context)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
}
|
|
@@ -1,110 +1,110 @@
|
|
|
1
|
-
package com.dynamsoft.reactnativelib.dce
|
|
2
|
-
|
|
3
|
-
import android.util.Log
|
|
4
|
-
import com.dynamsoft.core.basic_structures.ImageData
|
|
5
|
-
import com.dynamsoft.dce.DrawingItem
|
|
6
|
-
import com.dynamsoft.dce.ImageEditorView
|
|
7
|
-
import com.dynamsoft.dce.QuadDrawingItem
|
|
8
|
-
import com.dynamsoft.reactnativelib.basicutils.toQuad
|
|
9
|
-
import com.dynamsoft.reactnativelib.basicutils.toWritableMap
|
|
10
|
-
import com.facebook.react.bridge.Promise
|
|
11
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
12
|
-
import com.facebook.react.bridge.ReactMethod
|
|
13
|
-
import com.facebook.react.bridge.ReadableArray
|
|
14
|
-
import com.facebook.react.uimanager.UIManagerHelper
|
|
15
|
-
import kotlinx.coroutines.CoroutineName
|
|
16
|
-
import kotlinx.coroutines.CoroutineScope
|
|
17
|
-
import kotlinx.coroutines.Dispatchers
|
|
18
|
-
import kotlinx.coroutines.isActive
|
|
19
|
-
import kotlinx.coroutines.launch
|
|
20
|
-
import kotlinx.coroutines.withContext
|
|
21
|
-
import kotlinx.coroutines.withTimeoutOrNull
|
|
22
|
-
|
|
23
|
-
class ImageEditorViewModuleImpl(private val reactContext: ReactApplicationContext) {
|
|
24
|
-
companion object {
|
|
25
|
-
const val NAME = "DynamsoftImageEditorView"
|
|
26
|
-
const val TAG = "ImageEditorModuleImpl"
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
fun getName() = NAME
|
|
30
|
-
|
|
31
|
-
@ReactMethod
|
|
32
|
-
fun setQuads(viewTag: Int, readableArray: ReadableArray, layerId: Int, promise: Promise) {
|
|
33
|
-
CoroutineScope(Dispatchers.Default).launch(CoroutineName("setQuads")) {
|
|
34
|
-
val imageEditorView = findImageEditorView(viewTag)
|
|
35
|
-
if(imageEditorView == null) {
|
|
36
|
-
Log.e(TAG, "setQuads: Can't not find imageEditorView!(viewId = $viewTag)")
|
|
37
|
-
promise.resolve(null)
|
|
38
|
-
return@launch
|
|
39
|
-
}
|
|
40
|
-
val drawingItems = ArrayList<DrawingItem<*>>()
|
|
41
|
-
for (i in 0 until readableArray.size()) {
|
|
42
|
-
readableArray.getMap(i)?.toQuad()?.apply {
|
|
43
|
-
drawingItems.add(QuadDrawingItem(this))
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
imageEditorView.getDrawingLayer(layerId).drawingItems = drawingItems
|
|
47
|
-
promise.resolve(null)
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
@ReactMethod
|
|
52
|
-
fun getSelectedQuad(viewTag: Int, promise: Promise) {
|
|
53
|
-
CoroutineScope(Dispatchers.Default).launch(CoroutineName("getSelectedQuad")) {
|
|
54
|
-
val imageEditorView = findImageEditorView(viewTag)
|
|
55
|
-
if(imageEditorView == null) {
|
|
56
|
-
Log.e(TAG, "getSelectedQuad: Can't not find imageEditorView!(viewId = $viewTag)")
|
|
57
|
-
promise.resolve(null)
|
|
58
|
-
return@launch
|
|
59
|
-
}
|
|
60
|
-
val selectedDrawingItem = imageEditorView.selectedDrawingItem
|
|
61
|
-
if (selectedDrawingItem != null) {
|
|
62
|
-
promise.resolve((selectedDrawingItem as QuadDrawingItem).quad.toWritableMap())
|
|
63
|
-
} else {
|
|
64
|
-
promise.resolve(null)
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
70
|
-
fun install(): Boolean {
|
|
71
|
-
reactContext.javaScriptContextHolder?.apply {
|
|
72
|
-
nativeInstall(get())
|
|
73
|
-
}
|
|
74
|
-
return true
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
private suspend fun findImageEditorView(viewId: Int): ImageEditorView? = withTimeoutOrNull(300) {
|
|
78
|
-
while (true) {
|
|
79
|
-
val view = withContext(Dispatchers.Main) {
|
|
80
|
-
try {
|
|
81
|
-
UIManagerHelper.getUIManager(reactContext, viewId)?.resolveView(viewId) as? ImageEditorView
|
|
82
|
-
} catch (e: Exception) {
|
|
83
|
-
null
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
if (view != null) {
|
|
87
|
-
return@withTimeoutOrNull view
|
|
88
|
-
}
|
|
89
|
-
if (!isActive) {
|
|
90
|
-
break
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
return@withTimeoutOrNull null
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
//@Native
|
|
97
|
-
private fun setOriginalImageCalledInJSI(imageData: ImageData, editorViewTag: Int) {
|
|
98
|
-
CoroutineScope(Dispatchers.Default).launch(CoroutineName("setOriginalImageCalledInJSI")) {
|
|
99
|
-
val imageEditorView = findImageEditorView(editorViewTag)
|
|
100
|
-
if(imageEditorView == null) {
|
|
101
|
-
Log.e(TAG, "setOriginalImageCalledInJSI: Can't not find imageEditorView!(viewId = $editorViewTag)")
|
|
102
|
-
return@launch
|
|
103
|
-
}
|
|
104
|
-
imageEditorView?.originalImage = imageData
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
private external fun nativeInstall(jsiPtr: Long)
|
|
109
|
-
|
|
110
|
-
}
|
|
1
|
+
package com.dynamsoft.reactnativelib.dce
|
|
2
|
+
|
|
3
|
+
import android.util.Log
|
|
4
|
+
import com.dynamsoft.core.basic_structures.ImageData
|
|
5
|
+
import com.dynamsoft.dce.DrawingItem
|
|
6
|
+
import com.dynamsoft.dce.ImageEditorView
|
|
7
|
+
import com.dynamsoft.dce.QuadDrawingItem
|
|
8
|
+
import com.dynamsoft.reactnativelib.basicutils.toQuad
|
|
9
|
+
import com.dynamsoft.reactnativelib.basicutils.toWritableMap
|
|
10
|
+
import com.facebook.react.bridge.Promise
|
|
11
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
12
|
+
import com.facebook.react.bridge.ReactMethod
|
|
13
|
+
import com.facebook.react.bridge.ReadableArray
|
|
14
|
+
import com.facebook.react.uimanager.UIManagerHelper
|
|
15
|
+
import kotlinx.coroutines.CoroutineName
|
|
16
|
+
import kotlinx.coroutines.CoroutineScope
|
|
17
|
+
import kotlinx.coroutines.Dispatchers
|
|
18
|
+
import kotlinx.coroutines.isActive
|
|
19
|
+
import kotlinx.coroutines.launch
|
|
20
|
+
import kotlinx.coroutines.withContext
|
|
21
|
+
import kotlinx.coroutines.withTimeoutOrNull
|
|
22
|
+
|
|
23
|
+
class ImageEditorViewModuleImpl(private val reactContext: ReactApplicationContext) {
|
|
24
|
+
companion object {
|
|
25
|
+
const val NAME = "DynamsoftImageEditorView"
|
|
26
|
+
const val TAG = "ImageEditorModuleImpl"
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
fun getName() = NAME
|
|
30
|
+
|
|
31
|
+
@ReactMethod
|
|
32
|
+
fun setQuads(viewTag: Int, readableArray: ReadableArray, layerId: Int, promise: Promise) {
|
|
33
|
+
CoroutineScope(Dispatchers.Default).launch(CoroutineName("setQuads")) {
|
|
34
|
+
val imageEditorView = findImageEditorView(viewTag)
|
|
35
|
+
if(imageEditorView == null) {
|
|
36
|
+
Log.e(TAG, "setQuads: Can't not find imageEditorView!(viewId = $viewTag)")
|
|
37
|
+
promise.resolve(null)
|
|
38
|
+
return@launch
|
|
39
|
+
}
|
|
40
|
+
val drawingItems = ArrayList<DrawingItem<*>>()
|
|
41
|
+
for (i in 0 until readableArray.size()) {
|
|
42
|
+
readableArray.getMap(i)?.toQuad()?.apply {
|
|
43
|
+
drawingItems.add(QuadDrawingItem(this))
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
imageEditorView.getDrawingLayer(layerId).drawingItems = drawingItems
|
|
47
|
+
promise.resolve(null)
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
@ReactMethod
|
|
52
|
+
fun getSelectedQuad(viewTag: Int, promise: Promise) {
|
|
53
|
+
CoroutineScope(Dispatchers.Default).launch(CoroutineName("getSelectedQuad")) {
|
|
54
|
+
val imageEditorView = findImageEditorView(viewTag)
|
|
55
|
+
if(imageEditorView == null) {
|
|
56
|
+
Log.e(TAG, "getSelectedQuad: Can't not find imageEditorView!(viewId = $viewTag)")
|
|
57
|
+
promise.resolve(null)
|
|
58
|
+
return@launch
|
|
59
|
+
}
|
|
60
|
+
val selectedDrawingItem = imageEditorView.selectedDrawingItem
|
|
61
|
+
if (selectedDrawingItem != null) {
|
|
62
|
+
promise.resolve((selectedDrawingItem as QuadDrawingItem).quad.toWritableMap())
|
|
63
|
+
} else {
|
|
64
|
+
promise.resolve(null)
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
70
|
+
fun install(): Boolean {
|
|
71
|
+
reactContext.javaScriptContextHolder?.apply {
|
|
72
|
+
nativeInstall(get())
|
|
73
|
+
}
|
|
74
|
+
return true
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
private suspend fun findImageEditorView(viewId: Int): ImageEditorView? = withTimeoutOrNull(300) {
|
|
78
|
+
while (true) {
|
|
79
|
+
val view = withContext(Dispatchers.Main) {
|
|
80
|
+
try {
|
|
81
|
+
UIManagerHelper.getUIManager(reactContext, viewId)?.resolveView(viewId) as? ImageEditorView
|
|
82
|
+
} catch (e: Exception) {
|
|
83
|
+
null
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (view != null) {
|
|
87
|
+
return@withTimeoutOrNull view
|
|
88
|
+
}
|
|
89
|
+
if (!isActive) {
|
|
90
|
+
break
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return@withTimeoutOrNull null
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
//@Native
|
|
97
|
+
private fun setOriginalImageCalledInJSI(imageData: ImageData, editorViewTag: Int) {
|
|
98
|
+
CoroutineScope(Dispatchers.Default).launch(CoroutineName("setOriginalImageCalledInJSI")) {
|
|
99
|
+
val imageEditorView = findImageEditorView(editorViewTag)
|
|
100
|
+
if(imageEditorView == null) {
|
|
101
|
+
Log.e(TAG, "setOriginalImageCalledInJSI: Can't not find imageEditorView!(viewId = $editorViewTag)")
|
|
102
|
+
return@launch
|
|
103
|
+
}
|
|
104
|
+
imageEditorView?.originalImage = imageData
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
private external fun nativeInstall(jsiPtr: Long)
|
|
109
|
+
|
|
110
|
+
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
package com.dynamsoft.reactnativelib.dce
|
|
2
|
-
|
|
3
|
-
import android.content.Context
|
|
4
|
-
import com.dynamsoft.dce.CameraView
|
|
5
|
-
|
|
6
|
-
class RNCameraView(context: Context) : CameraView(context) {
|
|
7
|
-
|
|
8
|
-
override fun requestLayout() {
|
|
9
|
-
super.requestLayout()
|
|
10
|
-
post(this::manuallyMeasureAndLayout)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
private fun manuallyMeasureAndLayout() {
|
|
14
|
-
measure(
|
|
15
|
-
MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY),
|
|
16
|
-
MeasureSpec.makeMeasureSpec(measuredHeight, MeasureSpec.EXACTLY)
|
|
17
|
-
)
|
|
18
|
-
layout(0, 0, measuredWidth, measuredHeight)
|
|
19
|
-
}
|
|
20
|
-
}
|
|
1
|
+
package com.dynamsoft.reactnativelib.dce
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import com.dynamsoft.dce.CameraView
|
|
5
|
+
|
|
6
|
+
class RNCameraView(context: Context) : CameraView(context) {
|
|
7
|
+
|
|
8
|
+
override fun requestLayout() {
|
|
9
|
+
super.requestLayout()
|
|
10
|
+
post(this::manuallyMeasureAndLayout)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
private fun manuallyMeasureAndLayout() {
|
|
14
|
+
measure(
|
|
15
|
+
MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY),
|
|
16
|
+
MeasureSpec.makeMeasureSpec(measuredHeight, MeasureSpec.EXACTLY)
|
|
17
|
+
)
|
|
18
|
+
layout(0, 0, measuredWidth, measuredHeight)
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
package com.dynamsoft.reactnativelib.dce
|
|
2
|
-
|
|
3
|
-
import android.content.Context
|
|
4
|
-
import com.dynamsoft.dce.ImageEditorView
|
|
5
|
-
|
|
6
|
-
class RNImageEditorView(context: Context) : ImageEditorView(context) {
|
|
7
|
-
override fun requestLayout() {
|
|
8
|
-
super.requestLayout()
|
|
9
|
-
post(this::manuallyMeasureAndLayout)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
private fun manuallyMeasureAndLayout() {
|
|
13
|
-
measure(
|
|
14
|
-
MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY),
|
|
15
|
-
MeasureSpec.makeMeasureSpec(measuredHeight, MeasureSpec.EXACTLY)
|
|
16
|
-
)
|
|
17
|
-
layout(0, 0, measuredWidth, measuredHeight)
|
|
18
|
-
}
|
|
19
|
-
}
|
|
1
|
+
package com.dynamsoft.reactnativelib.dce
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
import com.dynamsoft.dce.ImageEditorView
|
|
5
|
+
|
|
6
|
+
class RNImageEditorView(context: Context) : ImageEditorView(context) {
|
|
7
|
+
override fun requestLayout() {
|
|
8
|
+
super.requestLayout()
|
|
9
|
+
post(this::manuallyMeasureAndLayout)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
private fun manuallyMeasureAndLayout() {
|
|
13
|
+
measure(
|
|
14
|
+
MeasureSpec.makeMeasureSpec(measuredWidth, MeasureSpec.EXACTLY),
|
|
15
|
+
MeasureSpec.makeMeasureSpec(measuredHeight, MeasureSpec.EXACTLY)
|
|
16
|
+
)
|
|
17
|
+
layout(0, 0, measuredWidth, measuredHeight)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
package com.dynamsoft.reactnativelib.license
|
|
2
|
-
|
|
3
|
-
import android.annotation.SuppressLint
|
|
4
|
-
import com.dynamsoft.license.LicenseManager
|
|
5
|
-
import com.dynamsoft.license.bean.InnerData
|
|
6
|
-
import com.facebook.react.bridge.Promise
|
|
7
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
8
|
-
import com.facebook.react.bridge.ReactMethod
|
|
9
|
-
|
|
10
|
-
class LicenseModuleImpl(private val reactContext: ReactApplicationContext) {
|
|
11
|
-
companion object {
|
|
12
|
-
const val NAME = "DynamsoftLicenseModule"
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
fun getName() = NAME
|
|
16
|
-
|
|
17
|
-
@ReactMethod
|
|
18
|
-
fun initLicense(license: String?, promise: Promise) {
|
|
19
|
-
@SuppressLint("RestrictedApi")
|
|
20
|
-
InnerData.remark.edition = "android-react-native"
|
|
21
|
-
LicenseManager.initLicense(license) { isSuccessful, error ->
|
|
22
|
-
if (isSuccessful) {
|
|
23
|
-
promise.resolve(true)
|
|
24
|
-
} else {
|
|
25
|
-
promise.reject(error?.message?:"InitLicense failed.", error)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@ReactMethod
|
|
31
|
-
fun setDeviceFriendlyName(deviceFriendlyName: String) {
|
|
32
|
-
LicenseManager.setDeviceFriendlyName(deviceFriendlyName)
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@ReactMethod
|
|
36
|
-
fun getDeviceUUID(promise: Promise) {
|
|
37
|
-
promise.resolve(LicenseManager.getDeviceUUID())
|
|
38
|
-
}
|
|
39
|
-
}
|
|
1
|
+
package com.dynamsoft.reactnativelib.license
|
|
2
|
+
|
|
3
|
+
import android.annotation.SuppressLint
|
|
4
|
+
import com.dynamsoft.license.LicenseManager
|
|
5
|
+
import com.dynamsoft.license.bean.InnerData
|
|
6
|
+
import com.facebook.react.bridge.Promise
|
|
7
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
8
|
+
import com.facebook.react.bridge.ReactMethod
|
|
9
|
+
|
|
10
|
+
class LicenseModuleImpl(private val reactContext: ReactApplicationContext) {
|
|
11
|
+
companion object {
|
|
12
|
+
const val NAME = "DynamsoftLicenseModule"
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
fun getName() = NAME
|
|
16
|
+
|
|
17
|
+
@ReactMethod
|
|
18
|
+
fun initLicense(license: String?, promise: Promise) {
|
|
19
|
+
@SuppressLint("RestrictedApi")
|
|
20
|
+
InnerData.remark.edition = "android-react-native"
|
|
21
|
+
LicenseManager.initLicense(license) { isSuccessful, error ->
|
|
22
|
+
if (isSuccessful) {
|
|
23
|
+
promise.resolve(true)
|
|
24
|
+
} else {
|
|
25
|
+
promise.reject(error?.message?:"InitLicense failed.", error)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@ReactMethod
|
|
31
|
+
fun setDeviceFriendlyName(deviceFriendlyName: String) {
|
|
32
|
+
LicenseManager.setDeviceFriendlyName(deviceFriendlyName)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@ReactMethod
|
|
36
|
+
fun getDeviceUUID(promise: Promise) {
|
|
37
|
+
promise.resolve(LicenseManager.getDeviceUUID())
|
|
38
|
+
}
|
|
39
|
+
}
|
package/android/src/main/java/com/dynamsoft/reactnativelib/utility/ImageManagerModuleImpl.kt
CHANGED
|
@@ -1,120 +1,120 @@
|
|
|
1
|
-
package com.dynamsoft.reactnativelib.utility
|
|
2
|
-
|
|
3
|
-
import android.graphics.Rect
|
|
4
|
-
import com.dynamsoft.core.basic_structures.DSRect
|
|
5
|
-
import com.dynamsoft.core.basic_structures.EnumImageFileFormat
|
|
6
|
-
import com.dynamsoft.core.basic_structures.ImageData
|
|
7
|
-
import com.dynamsoft.core.basic_structures.Quadrilateral
|
|
8
|
-
import com.dynamsoft.utility.EnumFilterType
|
|
9
|
-
import com.dynamsoft.utility.ImageDrawer
|
|
10
|
-
import com.dynamsoft.utility.ImageIO
|
|
11
|
-
import com.dynamsoft.utility.ImageProcessor
|
|
12
|
-
import com.dynamsoft.utility.UtilityException
|
|
13
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
14
|
-
|
|
15
|
-
class ImageManagerModuleImpl(private val reactContext: ReactApplicationContext) {
|
|
16
|
-
companion object {
|
|
17
|
-
const val NAME = "DynamsoftImageManagerModule"
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
private val imageIo by lazy { ImageIO() }
|
|
21
|
-
private val imageProcessor by lazy { ImageProcessor() }
|
|
22
|
-
private val imageDrawer by lazy { ImageDrawer() }
|
|
23
|
-
|
|
24
|
-
fun getName() = NAME
|
|
25
|
-
|
|
26
|
-
fun install(): Boolean {
|
|
27
|
-
reactContext.javaScriptContextHolder?.apply {
|
|
28
|
-
nativeInstall(get())
|
|
29
|
-
}
|
|
30
|
-
return true
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
fun saveToFileCalledInJsi(imageData: ImageData, filePath: String, overWrite: Boolean) {
|
|
34
|
-
imageIo.saveToFile(imageData, filePath, overWrite)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
fun readFromFileCalledInJsi(filePath: String): ImageData? {
|
|
38
|
-
return try {
|
|
39
|
-
imageIo.readFromFile(filePath)
|
|
40
|
-
} catch (_: UtilityException) {
|
|
41
|
-
null
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
fun readFromMemoryCalledInJsi(buffer: ByteArray): ImageData? {
|
|
46
|
-
return try {
|
|
47
|
-
imageIo.readFromMemory(buffer)
|
|
48
|
-
} catch (_: UtilityException) {
|
|
49
|
-
null
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
fun saveToMemoryCalledInJsi(imageData: ImageData, @EnumImageFileFormat format: Int): ByteArray? {
|
|
55
|
-
return try {
|
|
56
|
-
imageIo.saveToMemory(imageData, format)
|
|
57
|
-
} catch (_: UtilityException) {
|
|
58
|
-
null
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
fun drawOnImageCalledInJsi(imageData: ImageData, quads: Array<Quadrilateral>, color: Int, thickness: Int): ImageData {
|
|
63
|
-
return imageDrawer.drawOnImage(imageData, quads, color, thickness)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
fun cropImageCalledInJsi(imageData: ImageData, dsRect: DSRect): ImageData? {
|
|
67
|
-
val rect = if (dsRect.measuredInPercentage) {
|
|
68
|
-
Rect(
|
|
69
|
-
(dsRect.left * imageData.width).toInt(),
|
|
70
|
-
(dsRect.top * imageData.height).toInt(),
|
|
71
|
-
(dsRect.right * imageData.width).toInt(),
|
|
72
|
-
(dsRect.bottom * imageData.height).toInt()
|
|
73
|
-
)
|
|
74
|
-
} else {
|
|
75
|
-
Rect(dsRect.left.toInt(), dsRect.top.toInt(), dsRect.right.toInt(), dsRect.bottom.toInt())
|
|
76
|
-
}
|
|
77
|
-
return try {
|
|
78
|
-
imageProcessor.cropImage(imageData, rect)
|
|
79
|
-
} catch (e: UtilityException) {
|
|
80
|
-
null
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
fun cropAndDeskewImageCalledInJsi(imageData: ImageData, quad: Quadrilateral, dstWidth: Int, dstHeight: Int, padding: Int): ImageData? {
|
|
85
|
-
return try {
|
|
86
|
-
imageProcessor.cropAndDeskewImage(imageData, quad, dstWidth, dstHeight, padding)
|
|
87
|
-
} catch (e: UtilityException) {
|
|
88
|
-
null
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
fun adjustBrightnessCalledInJsi(imageData: ImageData, brightness: Int) : ImageData {
|
|
93
|
-
return imageProcessor.adjustBrightness(imageData, brightness)
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
fun adjustContrastCalledInJsi(imageData: ImageData, contrast: Int) : ImageData {
|
|
97
|
-
return imageProcessor.adjustContrast(imageData, contrast)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
fun filterImageCalledInJsi(imageData: ImageData, @EnumFilterType filterType: Int) : ImageData {
|
|
101
|
-
return imageProcessor.filterImage(imageData, filterType)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
fun convertToGrayCalledInJsi(imageData: ImageData, r: Float, g: Float, b: Float) : ImageData {
|
|
105
|
-
return imageProcessor.convertToGray(imageData, r, g, b)
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
fun convertToBinaryGlobalCalledInJsi(imageData: ImageData, threshold: Int, invert: Boolean): ImageData {
|
|
109
|
-
return imageProcessor.convertToBinaryGlobal(imageData, threshold, invert)
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
fun convertToBinaryLocalCalledInJsi(imageData: ImageData, blockSize: Int, compensation: Int, invert: Boolean): ImageData {
|
|
113
|
-
return imageProcessor.convertToBinaryLocal(imageData, blockSize, compensation, invert)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
private external fun nativeInstall(jsiPtr: Long)
|
|
119
|
-
|
|
120
|
-
}
|
|
1
|
+
package com.dynamsoft.reactnativelib.utility
|
|
2
|
+
|
|
3
|
+
import android.graphics.Rect
|
|
4
|
+
import com.dynamsoft.core.basic_structures.DSRect
|
|
5
|
+
import com.dynamsoft.core.basic_structures.EnumImageFileFormat
|
|
6
|
+
import com.dynamsoft.core.basic_structures.ImageData
|
|
7
|
+
import com.dynamsoft.core.basic_structures.Quadrilateral
|
|
8
|
+
import com.dynamsoft.utility.EnumFilterType
|
|
9
|
+
import com.dynamsoft.utility.ImageDrawer
|
|
10
|
+
import com.dynamsoft.utility.ImageIO
|
|
11
|
+
import com.dynamsoft.utility.ImageProcessor
|
|
12
|
+
import com.dynamsoft.utility.UtilityException
|
|
13
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
14
|
+
|
|
15
|
+
class ImageManagerModuleImpl(private val reactContext: ReactApplicationContext) {
|
|
16
|
+
companion object {
|
|
17
|
+
const val NAME = "DynamsoftImageManagerModule"
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
private val imageIo by lazy { ImageIO() }
|
|
21
|
+
private val imageProcessor by lazy { ImageProcessor() }
|
|
22
|
+
private val imageDrawer by lazy { ImageDrawer() }
|
|
23
|
+
|
|
24
|
+
fun getName() = NAME
|
|
25
|
+
|
|
26
|
+
fun install(): Boolean {
|
|
27
|
+
reactContext.javaScriptContextHolder?.apply {
|
|
28
|
+
nativeInstall(get())
|
|
29
|
+
}
|
|
30
|
+
return true
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
fun saveToFileCalledInJsi(imageData: ImageData, filePath: String, overWrite: Boolean) {
|
|
34
|
+
imageIo.saveToFile(imageData, filePath, overWrite)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
fun readFromFileCalledInJsi(filePath: String): ImageData? {
|
|
38
|
+
return try {
|
|
39
|
+
imageIo.readFromFile(filePath)
|
|
40
|
+
} catch (_: UtilityException) {
|
|
41
|
+
null
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
fun readFromMemoryCalledInJsi(buffer: ByteArray): ImageData? {
|
|
46
|
+
return try {
|
|
47
|
+
imageIo.readFromMemory(buffer)
|
|
48
|
+
} catch (_: UtilityException) {
|
|
49
|
+
null
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
fun saveToMemoryCalledInJsi(imageData: ImageData, @EnumImageFileFormat format: Int): ByteArray? {
|
|
55
|
+
return try {
|
|
56
|
+
imageIo.saveToMemory(imageData, format)
|
|
57
|
+
} catch (_: UtilityException) {
|
|
58
|
+
null
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
fun drawOnImageCalledInJsi(imageData: ImageData, quads: Array<Quadrilateral>, color: Int, thickness: Int): ImageData {
|
|
63
|
+
return imageDrawer.drawOnImage(imageData, quads, color, thickness)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
fun cropImageCalledInJsi(imageData: ImageData, dsRect: DSRect): ImageData? {
|
|
67
|
+
val rect = if (dsRect.measuredInPercentage) {
|
|
68
|
+
Rect(
|
|
69
|
+
(dsRect.left * imageData.width).toInt(),
|
|
70
|
+
(dsRect.top * imageData.height).toInt(),
|
|
71
|
+
(dsRect.right * imageData.width).toInt(),
|
|
72
|
+
(dsRect.bottom * imageData.height).toInt()
|
|
73
|
+
)
|
|
74
|
+
} else {
|
|
75
|
+
Rect(dsRect.left.toInt(), dsRect.top.toInt(), dsRect.right.toInt(), dsRect.bottom.toInt())
|
|
76
|
+
}
|
|
77
|
+
return try {
|
|
78
|
+
imageProcessor.cropImage(imageData, rect)
|
|
79
|
+
} catch (e: UtilityException) {
|
|
80
|
+
null
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
fun cropAndDeskewImageCalledInJsi(imageData: ImageData, quad: Quadrilateral, dstWidth: Int, dstHeight: Int, padding: Int): ImageData? {
|
|
85
|
+
return try {
|
|
86
|
+
imageProcessor.cropAndDeskewImage(imageData, quad, dstWidth, dstHeight, padding)
|
|
87
|
+
} catch (e: UtilityException) {
|
|
88
|
+
null
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
fun adjustBrightnessCalledInJsi(imageData: ImageData, brightness: Int) : ImageData {
|
|
93
|
+
return imageProcessor.adjustBrightness(imageData, brightness)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
fun adjustContrastCalledInJsi(imageData: ImageData, contrast: Int) : ImageData {
|
|
97
|
+
return imageProcessor.adjustContrast(imageData, contrast)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
fun filterImageCalledInJsi(imageData: ImageData, @EnumFilterType filterType: Int) : ImageData {
|
|
101
|
+
return imageProcessor.filterImage(imageData, filterType)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
fun convertToGrayCalledInJsi(imageData: ImageData, r: Float, g: Float, b: Float) : ImageData {
|
|
105
|
+
return imageProcessor.convertToGray(imageData, r, g, b)
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
fun convertToBinaryGlobalCalledInJsi(imageData: ImageData, threshold: Int, invert: Boolean): ImageData {
|
|
109
|
+
return imageProcessor.convertToBinaryGlobal(imageData, threshold, invert)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
fun convertToBinaryLocalCalledInJsi(imageData: ImageData, blockSize: Int, compensation: Int, invert: Boolean): ImageData {
|
|
113
|
+
return imageProcessor.convertToBinaryLocal(imageData, blockSize, compensation, invert)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
private external fun nativeInstall(jsiPtr: Long)
|
|
119
|
+
|
|
120
|
+
}
|