Skip to content

Instantly share code, notes, and snippets.

View yushulx's full-sized avatar

Xiao Ling yushulx

View GitHub Profile
let out_dir = env::var("OUT_DIR").unwrap();
let debug_offset = out_dir.find("debug").unwrap_or(0);
let release_offset = out_dir.find("release").unwrap_or(0);
let mut path = String::from("");
if debug_offset > 0 {
println!(">>> where is debug {}", debug_offset);
path.push_str(&format!("{}", &out_dir[..debug_offset]));
path.push_str("debug");
println!("{}", path);
let _src: String = String::from("./platforms/win/DynamsoftBarcodeReaderx64.dll");
path.push_str("/DynamsoftBarcodeReaderx64.dll");
let _result = fs::copy(_src, &path);
use std::ffi::CStr;
use std::ffi::CString;
use std::os::raw::c_char;
use std::env;
mod bridge;
use bridge::*;
extern "C" fn callback(index: i32, barcode_type: *const c_char, barcode_value: *const c_char) {
unsafe {
extern crate cc;
extern crate bindgen;
use std::env;
use std::fs;
fn main() {
// Link Dynamsoft Barcode Reader.
println!("cargo:rustc-link-search=./platforms/win");
println!("cargo:rustc-link-lib=DBRx64");
#include <windows.h>
typedef u_char *address;
address current_stack_base()
{
MEMORY_BASIC_INFORMATION minfo;
address stack_bottom;
size_t stack_size;
cmake_minimum_required (VERSION 2.6)
project (dbr)
MESSAGE( STATUS "PROJECT_NAME: " ${PROJECT_NAME} )
# Check platforms
if (CMAKE_HOST_WIN32)
set(WINDOWS 1)
set(JAVA_HOME "E:/Program Files (x86)/Java/jdk1.8.0_191")
set(JAVA_INCLUDE "${JAVA_HOME}/include")
set(JAVA_INCLUDE_OS "${JAVA_HOME}/include/win32")
public
static void main(String[] args)
{
int count = 1;
JNABarcode jnaReader = new JNABarcode();
System.out.println("JNA start.");
long start = System.currentTimeMillis();
for (int i = 0; i < count; i++)
@Override
public void dispatch(RCTEventEmitter rctEventEmitter) {
rctEventEmitter.receiveEvent(getViewTag(), getEventName(), serializeEventData());
}
private WritableMap serializeEventData() {
WritableArray barcodesList = Arguments.createArray();
for (int i = 0; i < mBarcodes.size(); i++) {
Barcode barcode = mBarcodes.valueAt(i);
_convertNativeProps(props: PropsType) {
const newProps = mapValues(props, this._convertProp);
if (props.onBarCodeRead) {
newProps.barCodeScannerEnabled = true;
}
if (props.onGoogleVisionBarcodesDetected) {
newProps.googleVisionBarcodeDetectorEnabled = true;
}
@Override
protected SparseArray<Barcode> doInBackground(Void... ignored) {
if (isCancelled() || mDelegate == null || mBarcodeDetector == null || !mBarcodeDetector.isOperational()) {
return null;
}
RNFrame frame = RNFrameFactory.buildFrame(mImageData, mWidth, mHeight, mRotation);
return mBarcodeDetector.detect(frame);
}