dynamsoft-capture-vision-react-native 3.4.1300 → 3.4.3010
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 +4 -4
- package/README.md +62 -62
- 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/dysJniLibsFor86/debug/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/debug/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/debug/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/debug/x86_64/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/release/arm64-v8a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/release/armeabi-v7a/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/release/x86/librn_dys.so +0 -0
- package/android/src/main/dysJniLibsFor86/release/x86_64/librn_dys.so +0 -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/utility/MultiCrossFilterModuleImpl.kt
CHANGED
|
@@ -1,111 +1,111 @@
|
|
|
1
|
-
package com.dynamsoft.reactnativelib.utility
|
|
2
|
-
|
|
3
|
-
import com.dynamsoft.reactnativelib.cvr.filterMap
|
|
4
|
-
import com.dynamsoft.utility.CrossVerificationCriteria
|
|
5
|
-
import com.dynamsoft.utility.MultiFrameResultCrossFilter
|
|
6
|
-
import com.facebook.react.bridge.Arguments
|
|
7
|
-
import com.facebook.react.bridge.Promise
|
|
8
|
-
import com.facebook.react.bridge.ReactApplicationContext
|
|
9
|
-
import com.facebook.react.bridge.ReactMethod
|
|
10
|
-
import com.facebook.react.bridge.ReadableMap
|
|
11
|
-
|
|
12
|
-
class MultiCrossFilterModuleImpl(context: ReactApplicationContext) {
|
|
13
|
-
companion object {
|
|
14
|
-
const val NAME = "DynamsoftMultiCrossFilterModule"
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
fun getName() = NAME
|
|
18
|
-
|
|
19
|
-
private fun getMultiCrossFilterById(filterId: String): MultiFrameResultCrossFilter? {
|
|
20
|
-
return if (filterMap[filterId] is MultiFrameResultCrossFilter) {
|
|
21
|
-
filterMap[filterId] as MultiFrameResultCrossFilter
|
|
22
|
-
} else {
|
|
23
|
-
null
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
28
|
-
fun createInstance(): String {
|
|
29
|
-
return MultiFrameResultCrossFilter().apply {
|
|
30
|
-
filterMap[this.toString()] = this
|
|
31
|
-
}.toString()
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
@ReactMethod
|
|
35
|
-
fun destroy(filterId: String) {
|
|
36
|
-
filterMap.remove(filterId)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
@ReactMethod
|
|
40
|
-
fun enableResultCrossVerification(filterId: String, resultItemTypes: Int, enable: Boolean) {
|
|
41
|
-
getMultiCrossFilterById(filterId)?.enableResultCrossVerification(resultItemTypes, enable)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
@ReactMethod
|
|
45
|
-
fun isResultCrossVerificationEnabled(filterId: String, type: Int, promise: Promise) {
|
|
46
|
-
promise.resolve(getMultiCrossFilterById(filterId)?.isResultCrossVerificationEnabled(type))
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@ReactMethod
|
|
50
|
-
fun enableResultDeduplication(filterId: String, resultItemTypes: Int, enable: Boolean) {
|
|
51
|
-
getMultiCrossFilterById(filterId)?.enableResultDeduplication(resultItemTypes, enable)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
@ReactMethod
|
|
55
|
-
fun isResultDeduplicationEnabled(filterId: String, type: Int, promise: Promise) {
|
|
56
|
-
promise.resolve(getMultiCrossFilterById(filterId)?.isResultDeduplicationEnabled(type))
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
@ReactMethod
|
|
60
|
-
fun setDuplicateForgetTime(filterId: String, resultItemTypes: Int, time: Int) {
|
|
61
|
-
getMultiCrossFilterById(filterId)?.setDuplicateForgetTime(resultItemTypes, time)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
@ReactMethod
|
|
65
|
-
fun getDuplicateForgetTime(filterId: String, type: Int, promise: Promise) {
|
|
66
|
-
promise.resolve(getMultiCrossFilterById(filterId)?.getDuplicateForgetTime(type))
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
@ReactMethod
|
|
70
|
-
fun enableLatestOverlapping(filterId: String, resultItemTypes: Int, enable: Boolean) {
|
|
71
|
-
getMultiCrossFilterById(filterId)?.enableLatestOverlapping(resultItemTypes, enable)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
@ReactMethod
|
|
75
|
-
fun isLatestOverlappingEnabled(filterId: String, resultItemTypes: Int, promise: Promise) {
|
|
76
|
-
promise.resolve(getMultiCrossFilterById(filterId)?.isLatestOverlappingEnabled(resultItemTypes))
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
@ReactMethod
|
|
80
|
-
fun getMaxOverlappingFrames(filterId: String, resultItemType: Int, promise: Promise) {
|
|
81
|
-
promise.resolve(getMultiCrossFilterById(filterId)?.getMaxOverlappingFrames(resultItemType))
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
@ReactMethod
|
|
85
|
-
fun setMaxOverlappingFrames(filterId: String, resultItemTypes: Int, maxFrameToCheck: Int) {
|
|
86
|
-
getMultiCrossFilterById(filterId)?.setMaxOverlappingFrames(resultItemTypes, maxFrameToCheck)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
@ReactMethod
|
|
90
|
-
fun setResultCrossVerificationCriteria(filterId: String, resultItemTypes: Int, criteria: ReadableMap) {
|
|
91
|
-
getMultiCrossFilterById(filterId)?.setResultCrossVerificationCriteria(resultItemTypes, criteria.run {
|
|
92
|
-
CrossVerificationCriteria(
|
|
93
|
-
criteria.getInt("frameWindow"),
|
|
94
|
-
criteria.getInt("minConsistentFrames"),
|
|
95
|
-
)
|
|
96
|
-
})
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
@ReactMethod
|
|
100
|
-
fun getResultCrossVerificationCriteria(filterId: String, resultItemType: Int, promise: Promise) {
|
|
101
|
-
val criteria = getMultiCrossFilterById(filterId)?.getResultCrossVerificationCriteria(resultItemType)
|
|
102
|
-
if (criteria != null) {
|
|
103
|
-
promise.resolve(Arguments.createMap().apply {
|
|
104
|
-
putInt("frameWindow", criteria.frameWindow)
|
|
105
|
-
putInt("minConsistentFrames", criteria.minConsistentFrames)
|
|
106
|
-
})
|
|
107
|
-
} else {
|
|
108
|
-
promise.resolve(null)
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
1
|
+
package com.dynamsoft.reactnativelib.utility
|
|
2
|
+
|
|
3
|
+
import com.dynamsoft.reactnativelib.cvr.filterMap
|
|
4
|
+
import com.dynamsoft.utility.CrossVerificationCriteria
|
|
5
|
+
import com.dynamsoft.utility.MultiFrameResultCrossFilter
|
|
6
|
+
import com.facebook.react.bridge.Arguments
|
|
7
|
+
import com.facebook.react.bridge.Promise
|
|
8
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
9
|
+
import com.facebook.react.bridge.ReactMethod
|
|
10
|
+
import com.facebook.react.bridge.ReadableMap
|
|
11
|
+
|
|
12
|
+
class MultiCrossFilterModuleImpl(context: ReactApplicationContext) {
|
|
13
|
+
companion object {
|
|
14
|
+
const val NAME = "DynamsoftMultiCrossFilterModule"
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
fun getName() = NAME
|
|
18
|
+
|
|
19
|
+
private fun getMultiCrossFilterById(filterId: String): MultiFrameResultCrossFilter? {
|
|
20
|
+
return if (filterMap[filterId] is MultiFrameResultCrossFilter) {
|
|
21
|
+
filterMap[filterId] as MultiFrameResultCrossFilter
|
|
22
|
+
} else {
|
|
23
|
+
null
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
28
|
+
fun createInstance(): String {
|
|
29
|
+
return MultiFrameResultCrossFilter().apply {
|
|
30
|
+
filterMap[this.toString()] = this
|
|
31
|
+
}.toString()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@ReactMethod
|
|
35
|
+
fun destroy(filterId: String) {
|
|
36
|
+
filterMap.remove(filterId)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@ReactMethod
|
|
40
|
+
fun enableResultCrossVerification(filterId: String, resultItemTypes: Int, enable: Boolean) {
|
|
41
|
+
getMultiCrossFilterById(filterId)?.enableResultCrossVerification(resultItemTypes, enable)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@ReactMethod
|
|
45
|
+
fun isResultCrossVerificationEnabled(filterId: String, type: Int, promise: Promise) {
|
|
46
|
+
promise.resolve(getMultiCrossFilterById(filterId)?.isResultCrossVerificationEnabled(type))
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@ReactMethod
|
|
50
|
+
fun enableResultDeduplication(filterId: String, resultItemTypes: Int, enable: Boolean) {
|
|
51
|
+
getMultiCrossFilterById(filterId)?.enableResultDeduplication(resultItemTypes, enable)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@ReactMethod
|
|
55
|
+
fun isResultDeduplicationEnabled(filterId: String, type: Int, promise: Promise) {
|
|
56
|
+
promise.resolve(getMultiCrossFilterById(filterId)?.isResultDeduplicationEnabled(type))
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@ReactMethod
|
|
60
|
+
fun setDuplicateForgetTime(filterId: String, resultItemTypes: Int, time: Int) {
|
|
61
|
+
getMultiCrossFilterById(filterId)?.setDuplicateForgetTime(resultItemTypes, time)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
@ReactMethod
|
|
65
|
+
fun getDuplicateForgetTime(filterId: String, type: Int, promise: Promise) {
|
|
66
|
+
promise.resolve(getMultiCrossFilterById(filterId)?.getDuplicateForgetTime(type))
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
@ReactMethod
|
|
70
|
+
fun enableLatestOverlapping(filterId: String, resultItemTypes: Int, enable: Boolean) {
|
|
71
|
+
getMultiCrossFilterById(filterId)?.enableLatestOverlapping(resultItemTypes, enable)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@ReactMethod
|
|
75
|
+
fun isLatestOverlappingEnabled(filterId: String, resultItemTypes: Int, promise: Promise) {
|
|
76
|
+
promise.resolve(getMultiCrossFilterById(filterId)?.isLatestOverlappingEnabled(resultItemTypes))
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@ReactMethod
|
|
80
|
+
fun getMaxOverlappingFrames(filterId: String, resultItemType: Int, promise: Promise) {
|
|
81
|
+
promise.resolve(getMultiCrossFilterById(filterId)?.getMaxOverlappingFrames(resultItemType))
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
@ReactMethod
|
|
85
|
+
fun setMaxOverlappingFrames(filterId: String, resultItemTypes: Int, maxFrameToCheck: Int) {
|
|
86
|
+
getMultiCrossFilterById(filterId)?.setMaxOverlappingFrames(resultItemTypes, maxFrameToCheck)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
@ReactMethod
|
|
90
|
+
fun setResultCrossVerificationCriteria(filterId: String, resultItemTypes: Int, criteria: ReadableMap) {
|
|
91
|
+
getMultiCrossFilterById(filterId)?.setResultCrossVerificationCriteria(resultItemTypes, criteria.run {
|
|
92
|
+
CrossVerificationCriteria(
|
|
93
|
+
criteria.getInt("frameWindow"),
|
|
94
|
+
criteria.getInt("minConsistentFrames"),
|
|
95
|
+
)
|
|
96
|
+
})
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@ReactMethod
|
|
100
|
+
fun getResultCrossVerificationCriteria(filterId: String, resultItemType: Int, promise: Promise) {
|
|
101
|
+
val criteria = getMultiCrossFilterById(filterId)?.getResultCrossVerificationCriteria(resultItemType)
|
|
102
|
+
if (criteria != null) {
|
|
103
|
+
promise.resolve(Arguments.createMap().apply {
|
|
104
|
+
putInt("frameWindow", criteria.frameWindow)
|
|
105
|
+
putInt("minConsistentFrames", criteria.minConsistentFrames)
|
|
106
|
+
})
|
|
107
|
+
} else {
|
|
108
|
+
promise.resolve(null)
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
package/app.plugin.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
const { withProjectBuildGradle } = require("@expo/config-plugins");
|
|
2
|
-
|
|
3
|
-
const dynamsoft_allprojects_block = `
|
|
4
|
-
allprojects {
|
|
5
|
-
repositories {
|
|
6
|
-
maven {
|
|
7
|
-
url "https://download2.dynamsoft.com/maven/aar"
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
`;
|
|
12
|
-
|
|
13
|
-
module.exports = (config) => {
|
|
14
|
-
return withProjectBuildGradle(config, (config) => {
|
|
15
|
-
if(config.modResults.contents.includes('https://download2.dynamsoft.com/maven/aar')) {
|
|
16
|
-
return config;
|
|
17
|
-
}
|
|
18
|
-
config.modResults.contents += dynamsoft_allprojects_block;
|
|
19
|
-
return config;
|
|
20
|
-
});
|
|
21
|
-
};
|
|
1
|
+
const { withProjectBuildGradle } = require("@expo/config-plugins");
|
|
2
|
+
|
|
3
|
+
const dynamsoft_allprojects_block = `
|
|
4
|
+
allprojects {
|
|
5
|
+
repositories {
|
|
6
|
+
maven {
|
|
7
|
+
url "https://download2.dynamsoft.com/maven/aar"
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
module.exports = (config) => {
|
|
14
|
+
return withProjectBuildGradle(config, (config) => {
|
|
15
|
+
if(config.modResults.contents.includes('https://download2.dynamsoft.com/maven/aar')) {
|
|
16
|
+
return config;
|
|
17
|
+
}
|
|
18
|
+
config.modResults.contents += dynamsoft_allprojects_block;
|
|
19
|
+
return config;
|
|
20
|
+
});
|
|
21
|
+
};
|
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
require "json"
|
|
2
|
-
|
|
3
|
-
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
-
|
|
5
|
-
Pod::Spec.new do |s|
|
|
6
|
-
s.name = package["name"]
|
|
7
|
-
s.version = package["version"]
|
|
8
|
-
s.summary = package["description"]
|
|
9
|
-
s.homepage = package["homepage"]
|
|
10
|
-
s.license = package["license"]
|
|
11
|
-
s.authors = { package["author"]["name"] => package["author"]["email"] }
|
|
12
|
-
|
|
13
|
-
s.platforms = { :ios => "13.0" }
|
|
14
|
-
s.source = { :http => "https://registry.npmjs.org/#{s.name}/-/#{s.name}-#{s.version}.tgz" }
|
|
15
|
-
|
|
16
|
-
s.source_files = "ios/**/*.{h,hpp,c,cc,cpp,m,mm,swift}"
|
|
17
|
-
s.private_header_files = "ios/**/*.h"
|
|
18
|
-
s.requires_arc = true
|
|
19
|
-
|
|
20
|
-
s.dependency "DynamsoftCaptureVisionBundle", ">= 3.4.
|
|
21
|
-
|
|
22
|
-
install_modules_dependencies(s)
|
|
23
|
-
end
|
|
24
|
-
|
|
1
|
+
require "json"
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, "package.json")))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = package["name"]
|
|
7
|
+
s.version = package["version"]
|
|
8
|
+
s.summary = package["description"]
|
|
9
|
+
s.homepage = package["homepage"]
|
|
10
|
+
s.license = package["license"]
|
|
11
|
+
s.authors = { package["author"]["name"] => package["author"]["email"] }
|
|
12
|
+
|
|
13
|
+
s.platforms = { :ios => "13.0" }
|
|
14
|
+
s.source = { :http => "https://registry.npmjs.org/#{s.name}/-/#{s.name}-#{s.version}.tgz" }
|
|
15
|
+
|
|
16
|
+
s.source_files = "ios/**/*.{h,hpp,c,cc,cpp,m,mm,swift}"
|
|
17
|
+
s.private_header_files = "ios/**/*.h"
|
|
18
|
+
s.requires_arc = true
|
|
19
|
+
|
|
20
|
+
s.dependency "DynamsoftCaptureVisionBundle", ">= 3.4.3000", "< 4.0"
|
|
21
|
+
|
|
22
|
+
install_modules_dependencies(s)
|
|
23
|
+
end
|
|
24
|
+
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © Dynamsoft Corporation. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
#import <DynamsoftCaptureVisionBundle/DSImageData.h>
|
|
6
|
-
#include "ImageDataHostObject.hpp"
|
|
7
|
-
|
|
8
|
-
NS_ASSUME_NONNULL_BEGIN
|
|
9
|
-
|
|
10
|
-
@interface DSImageData (HostObject)
|
|
11
|
-
|
|
12
|
-
+ (DSImageData *)imageDataFromHostObject:(ImageDataHostObject)object;
|
|
13
|
-
|
|
14
|
-
- (ImageDataHostObject)hostObject;
|
|
15
|
-
|
|
16
|
-
@end
|
|
17
|
-
|
|
18
|
-
NS_ASSUME_NONNULL_END
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © Dynamsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#import <DynamsoftCaptureVisionBundle/DSImageData.h>
|
|
6
|
+
#include "ImageDataHostObject.hpp"
|
|
7
|
+
|
|
8
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
9
|
+
|
|
10
|
+
@interface DSImageData (HostObject)
|
|
11
|
+
|
|
12
|
+
+ (DSImageData *)imageDataFromHostObject:(ImageDataHostObject)object;
|
|
13
|
+
|
|
14
|
+
- (ImageDataHostObject)hostObject;
|
|
15
|
+
|
|
16
|
+
@end
|
|
17
|
+
|
|
18
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © Dynamsoft Corporation. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
#import "DSImageData+HostObject.h"
|
|
6
|
-
#include "ImageDataHostObject.hpp"
|
|
7
|
-
|
|
8
|
-
@implementation DSImageData (HostObject)
|
|
9
|
-
|
|
10
|
-
- (ImageDataHostObject)hostObject {
|
|
11
|
-
int width = (int)self.width;
|
|
12
|
-
int height = (int)self.height;
|
|
13
|
-
int stride = (int)self.stride;
|
|
14
|
-
int format = (int)self.format;
|
|
15
|
-
int orientation = (int)self.orientation;
|
|
16
|
-
NSData *data = self.bytes;
|
|
17
|
-
NSUInteger length = data.length;
|
|
18
|
-
uint8_t *buffer = (uint8_t *)malloc(length);
|
|
19
|
-
if (buffer != NULL) {
|
|
20
|
-
memcpy(buffer, data.bytes, length);
|
|
21
|
-
}
|
|
22
|
-
int bufferSize = (int)length;
|
|
23
|
-
ImageDataHostObject object = ImageDataHostObject(width, height, stride, format, orientation, buffer, bufferSize);
|
|
24
|
-
return object;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
+ (DSImageData *)imageDataFromHostObject:(ImageDataHostObject)object {
|
|
28
|
-
NSData *data = [NSData dataWithBytes:(const void *)object.buffer length:object.bufferSize];
|
|
29
|
-
NSUInteger width = object.width;
|
|
30
|
-
NSUInteger height = object.height;
|
|
31
|
-
NSUInteger stride = object.stride;
|
|
32
|
-
DSImagePixelFormat format = (DSImagePixelFormat)object.format;
|
|
33
|
-
NSUInteger orientation = object.orientation;
|
|
34
|
-
DSImageData *imageData = [[DSImageData alloc] initWithBytes:data width:width height:height stride:stride format:format orientation:orientation tag:nil];
|
|
35
|
-
return imageData;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
@end
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © Dynamsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#import "DSImageData+HostObject.h"
|
|
6
|
+
#include "ImageDataHostObject.hpp"
|
|
7
|
+
|
|
8
|
+
@implementation DSImageData (HostObject)
|
|
9
|
+
|
|
10
|
+
- (ImageDataHostObject)hostObject {
|
|
11
|
+
int width = (int)self.width;
|
|
12
|
+
int height = (int)self.height;
|
|
13
|
+
int stride = (int)self.stride;
|
|
14
|
+
int format = (int)self.format;
|
|
15
|
+
int orientation = (int)self.orientation;
|
|
16
|
+
NSData *data = self.bytes;
|
|
17
|
+
NSUInteger length = data.length;
|
|
18
|
+
uint8_t *buffer = (uint8_t *)malloc(length);
|
|
19
|
+
if (buffer != NULL) {
|
|
20
|
+
memcpy(buffer, data.bytes, length);
|
|
21
|
+
}
|
|
22
|
+
int bufferSize = (int)length;
|
|
23
|
+
ImageDataHostObject object = ImageDataHostObject(width, height, stride, format, orientation, buffer, bufferSize);
|
|
24
|
+
return object;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
+ (DSImageData *)imageDataFromHostObject:(ImageDataHostObject)object {
|
|
28
|
+
NSData *data = [NSData dataWithBytes:(const void *)object.buffer length:object.bufferSize];
|
|
29
|
+
NSUInteger width = object.width;
|
|
30
|
+
NSUInteger height = object.height;
|
|
31
|
+
NSUInteger stride = object.stride;
|
|
32
|
+
DSImagePixelFormat format = (DSImagePixelFormat)object.format;
|
|
33
|
+
NSUInteger orientation = object.orientation;
|
|
34
|
+
DSImageData *imageData = [[DSImageData alloc] initWithBytes:data width:width height:height stride:stride format:format orientation:orientation tag:nil];
|
|
35
|
+
return imageData;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
@end
|
|
@@ -1,87 +1,87 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright © Dynamsoft Corporation. All rights reserved.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
#include "ImageDataHostObject.hpp"
|
|
6
|
-
#include "MutableRawBuffer.hpp"
|
|
7
|
-
|
|
8
|
-
#define GET_VALUE(X) if(name==#X){return this->X;}
|
|
9
|
-
#define SET_INT_VALUE(X) if(name==#X){this->X = (int) value.asNumber();}
|
|
10
|
-
|
|
11
|
-
ImageDataHostObject::ImageDataHostObject(int width, int height, int stride, int format, int orientation, uint8_t *buffer, int bufferSize)
|
|
12
|
-
: width(width), height(height), stride(stride), format(format), orientation(orientation), buffer(buffer), bufferSize(bufferSize) {}
|
|
13
|
-
|
|
14
|
-
ImageDataHostObject ImageDataHostObject::getHOFromObject(Runtime &runtime, Object &jsObj) {
|
|
15
|
-
if (jsObj.isHostObject<ImageDataHostObject>(runtime)) {
|
|
16
|
-
return *((ImageDataHostObject *) (jsObj.asHostObject(runtime).get()));
|
|
17
|
-
}
|
|
18
|
-
ImageDataHostObject imageHO;
|
|
19
|
-
int width = jsObj.hasProperty(runtime, "width") ? (int) jsObj.getProperty(runtime, "width").asNumber() : 0;
|
|
20
|
-
int height = jsObj.hasProperty(runtime, "height") ? (int) jsObj.getProperty(runtime, "height").asNumber() : 0;
|
|
21
|
-
int stride = jsObj.hasProperty(runtime, "stride") ? (int) jsObj.getProperty(runtime, "stride").asNumber() : 0;
|
|
22
|
-
int format = jsObj.hasProperty(runtime, "format") ? (int) jsObj.getProperty(runtime, "format").asNumber() : 0;
|
|
23
|
-
int orientation = jsObj.hasProperty(runtime, "orientation") ? (int) jsObj.getProperty(runtime, "orientation").asNumber() : 0;
|
|
24
|
-
uint8_t *buffer = nullptr;
|
|
25
|
-
int bufferSize = 0;
|
|
26
|
-
if (jsObj.hasProperty(runtime, "buffer")) {
|
|
27
|
-
ArrayBuffer array_buffer = jsObj.getProperty(runtime, "buffer").asObject(runtime).getArrayBuffer(runtime);
|
|
28
|
-
buffer = array_buffer.data(runtime);
|
|
29
|
-
bufferSize = (int) array_buffer.length(runtime);
|
|
30
|
-
}
|
|
31
|
-
return ImageDataHostObject(width, height, stride, format, orientation, buffer, bufferSize);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
Value ImageDataHostObject::get(Runtime &runtime, const PropNameID &propName) {
|
|
35
|
-
auto name = propName.utf8(runtime);
|
|
36
|
-
GET_VALUE(width)
|
|
37
|
-
GET_VALUE(height)
|
|
38
|
-
GET_VALUE(stride)
|
|
39
|
-
GET_VALUE(format)
|
|
40
|
-
GET_VALUE(orientation)
|
|
41
|
-
GET_VALUE(bufferSize)
|
|
42
|
-
if (name == "buffer") {
|
|
43
|
-
auto mutableBuffer = std::make_shared<MutableRawBuffer>(buffer, bufferSize, false);
|
|
44
|
-
ArrayBuffer arrayBuffer(runtime, mutableBuffer);
|
|
45
|
-
auto destinationBuffer = arrayBuffer.data(runtime);
|
|
46
|
-
memcpy(destinationBuffer, buffer, sizeof(uint8_t) * bufferSize);
|
|
47
|
-
return arrayBuffer;
|
|
48
|
-
}
|
|
49
|
-
if (name == "release") {
|
|
50
|
-
auto release = [=, this](Runtime & runtime, const Value& thisValue, const Value* arguments, size_t count) -> Value {
|
|
51
|
-
if(buffer != nullptr) {
|
|
52
|
-
delete[] buffer;
|
|
53
|
-
buffer = nullptr;
|
|
54
|
-
bufferSize = 0;
|
|
55
|
-
}
|
|
56
|
-
return {};
|
|
57
|
-
};
|
|
58
|
-
return Function::createFromHostFunction(runtime, PropNameID::forUtf8(runtime, "release"), 0, release);
|
|
59
|
-
}
|
|
60
|
-
return {};
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
void ImageDataHostObject::set(Runtime &runtime, const PropNameID &propName, const Value &value) {
|
|
64
|
-
auto name = propName.utf8(runtime);
|
|
65
|
-
SET_INT_VALUE(width)
|
|
66
|
-
SET_INT_VALUE(height)
|
|
67
|
-
SET_INT_VALUE(stride)
|
|
68
|
-
SET_INT_VALUE(format)
|
|
69
|
-
SET_INT_VALUE(orientation)
|
|
70
|
-
if (name == "buffer") {
|
|
71
|
-
auto arrayBuffer = value.asObject(runtime).getArrayBuffer(runtime);
|
|
72
|
-
this->buffer = arrayBuffer.data(runtime);
|
|
73
|
-
this->bufferSize = (int) arrayBuffer.length(runtime);
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
std::vector<PropNameID> ImageDataHostObject::getPropertyNames(Runtime &rt) {
|
|
78
|
-
std::vector<PropNameID> result;
|
|
79
|
-
result.push_back(PropNameID::forUtf8(rt, std::string("width")));
|
|
80
|
-
result.push_back(PropNameID::forUtf8(rt, std::string("height")));
|
|
81
|
-
result.push_back(PropNameID::forUtf8(rt, std::string("stride")));
|
|
82
|
-
result.push_back(PropNameID::forUtf8(rt, std::string("format")));
|
|
83
|
-
result.push_back(PropNameID::forUtf8(rt, std::string("orientation")));
|
|
84
|
-
result.push_back(PropNameID::forUtf8(rt, std::string("buffer")));
|
|
85
|
-
result.push_back(PropNameID::forUtf8(rt, std::string("release")));
|
|
86
|
-
return result;
|
|
87
|
-
}
|
|
1
|
+
/*
|
|
2
|
+
* Copyright © Dynamsoft Corporation. All rights reserved.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
#include "ImageDataHostObject.hpp"
|
|
6
|
+
#include "MutableRawBuffer.hpp"
|
|
7
|
+
|
|
8
|
+
#define GET_VALUE(X) if(name==#X){return this->X;}
|
|
9
|
+
#define SET_INT_VALUE(X) if(name==#X){this->X = (int) value.asNumber();}
|
|
10
|
+
|
|
11
|
+
ImageDataHostObject::ImageDataHostObject(int width, int height, int stride, int format, int orientation, uint8_t *buffer, int bufferSize)
|
|
12
|
+
: width(width), height(height), stride(stride), format(format), orientation(orientation), buffer(buffer), bufferSize(bufferSize) {}
|
|
13
|
+
|
|
14
|
+
ImageDataHostObject ImageDataHostObject::getHOFromObject(Runtime &runtime, Object &jsObj) {
|
|
15
|
+
if (jsObj.isHostObject<ImageDataHostObject>(runtime)) {
|
|
16
|
+
return *((ImageDataHostObject *) (jsObj.asHostObject(runtime).get()));
|
|
17
|
+
}
|
|
18
|
+
ImageDataHostObject imageHO;
|
|
19
|
+
int width = jsObj.hasProperty(runtime, "width") ? (int) jsObj.getProperty(runtime, "width").asNumber() : 0;
|
|
20
|
+
int height = jsObj.hasProperty(runtime, "height") ? (int) jsObj.getProperty(runtime, "height").asNumber() : 0;
|
|
21
|
+
int stride = jsObj.hasProperty(runtime, "stride") ? (int) jsObj.getProperty(runtime, "stride").asNumber() : 0;
|
|
22
|
+
int format = jsObj.hasProperty(runtime, "format") ? (int) jsObj.getProperty(runtime, "format").asNumber() : 0;
|
|
23
|
+
int orientation = jsObj.hasProperty(runtime, "orientation") ? (int) jsObj.getProperty(runtime, "orientation").asNumber() : 0;
|
|
24
|
+
uint8_t *buffer = nullptr;
|
|
25
|
+
int bufferSize = 0;
|
|
26
|
+
if (jsObj.hasProperty(runtime, "buffer")) {
|
|
27
|
+
ArrayBuffer array_buffer = jsObj.getProperty(runtime, "buffer").asObject(runtime).getArrayBuffer(runtime);
|
|
28
|
+
buffer = array_buffer.data(runtime);
|
|
29
|
+
bufferSize = (int) array_buffer.length(runtime);
|
|
30
|
+
}
|
|
31
|
+
return ImageDataHostObject(width, height, stride, format, orientation, buffer, bufferSize);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
Value ImageDataHostObject::get(Runtime &runtime, const PropNameID &propName) {
|
|
35
|
+
auto name = propName.utf8(runtime);
|
|
36
|
+
GET_VALUE(width)
|
|
37
|
+
GET_VALUE(height)
|
|
38
|
+
GET_VALUE(stride)
|
|
39
|
+
GET_VALUE(format)
|
|
40
|
+
GET_VALUE(orientation)
|
|
41
|
+
GET_VALUE(bufferSize)
|
|
42
|
+
if (name == "buffer") {
|
|
43
|
+
auto mutableBuffer = std::make_shared<MutableRawBuffer>(buffer, bufferSize, false);
|
|
44
|
+
ArrayBuffer arrayBuffer(runtime, mutableBuffer);
|
|
45
|
+
auto destinationBuffer = arrayBuffer.data(runtime);
|
|
46
|
+
memcpy(destinationBuffer, buffer, sizeof(uint8_t) * bufferSize);
|
|
47
|
+
return arrayBuffer;
|
|
48
|
+
}
|
|
49
|
+
if (name == "release") {
|
|
50
|
+
auto release = [=, this](Runtime & runtime, const Value& thisValue, const Value* arguments, size_t count) -> Value {
|
|
51
|
+
if(buffer != nullptr) {
|
|
52
|
+
delete[] buffer;
|
|
53
|
+
buffer = nullptr;
|
|
54
|
+
bufferSize = 0;
|
|
55
|
+
}
|
|
56
|
+
return {};
|
|
57
|
+
};
|
|
58
|
+
return Function::createFromHostFunction(runtime, PropNameID::forUtf8(runtime, "release"), 0, release);
|
|
59
|
+
}
|
|
60
|
+
return {};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
void ImageDataHostObject::set(Runtime &runtime, const PropNameID &propName, const Value &value) {
|
|
64
|
+
auto name = propName.utf8(runtime);
|
|
65
|
+
SET_INT_VALUE(width)
|
|
66
|
+
SET_INT_VALUE(height)
|
|
67
|
+
SET_INT_VALUE(stride)
|
|
68
|
+
SET_INT_VALUE(format)
|
|
69
|
+
SET_INT_VALUE(orientation)
|
|
70
|
+
if (name == "buffer") {
|
|
71
|
+
auto arrayBuffer = value.asObject(runtime).getArrayBuffer(runtime);
|
|
72
|
+
this->buffer = arrayBuffer.data(runtime);
|
|
73
|
+
this->bufferSize = (int) arrayBuffer.length(runtime);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
std::vector<PropNameID> ImageDataHostObject::getPropertyNames(Runtime &rt) {
|
|
78
|
+
std::vector<PropNameID> result;
|
|
79
|
+
result.push_back(PropNameID::forUtf8(rt, std::string("width")));
|
|
80
|
+
result.push_back(PropNameID::forUtf8(rt, std::string("height")));
|
|
81
|
+
result.push_back(PropNameID::forUtf8(rt, std::string("stride")));
|
|
82
|
+
result.push_back(PropNameID::forUtf8(rt, std::string("format")));
|
|
83
|
+
result.push_back(PropNameID::forUtf8(rt, std::string("orientation")));
|
|
84
|
+
result.push_back(PropNameID::forUtf8(rt, std::string("buffer")));
|
|
85
|
+
result.push_back(PropNameID::forUtf8(rt, std::string("release")));
|
|
86
|
+
return result;
|
|
87
|
+
}
|