4 releases
Uses old Rust 2015
0.1.3 | Oct 16, 2018 |
---|---|
0.1.2 | Oct 16, 2018 |
0.1.1 | Oct 16, 2018 |
0.1.0 | Oct 16, 2018 |
#35 in #barcode
6MB
148 lines
Contains (Windows DLL, 6MB) DynamsoftBarcodeReaderx64.dll, (static library, 28KB) platforms/win/DBRx64.lib
Dynamsoft Barcode Reader
FFI bindings to Dynamsoft Barcode Reader SDK.
License
Get the trial license.
Contact Us
https://www.dynamsoft.com/Company/Contact.aspx
Usage
Decode barcodes from an image file:
extern crate dbr;
use std::ffi::CStr;
use std::ffi::CString;
use std::os::raw::c_char;
use std::env;
use dbr::reader::*;
extern "C" fn callback(index: i32, barcode_type: *const c_char, barcode_value: *const c_char) {
unsafe {
println!(
"Index {}, {}, {}",
index,
CStr::from_ptr(barcode_type).to_str().unwrap(),
CStr::from_ptr(barcode_value).to_str().unwrap()
);
}
}
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() == 1 {
println!("Please input an image file.");
return
}
println!("Hello Dynamsoft Barcode Reader!");
unsafe {
register_callback(Some(callback));
let image_file = CString::new(env::args().nth(1).expect("Missing argument")).unwrap();
let license = CString::new("t0068NQAAAFKYHV9xSZDEThUtClXNzxXH9TLSj/vYcY8mSKa0RxaGw3qNynyAMJ9Ib8UPxzFsbAMIugqPO313BvfiOdmZFTY=").unwrap();
c_decodeFile(image_file.as_ptr(), license.as_ptr());
}
println!("Bye!");
}
How to Customize the Package
-
Install Dynamsoft Barcode Reader.
-
Get the source code;
-
Copy
Dynamsoft\Barcode Reader <version number>\Components\C_C++\Redist\x64\DynamsoftBarcodeReaderx64.dll
toplatforms\win\DynamsoftBarcodeReaderx64.dll
.Copy
Dynamsoft\Barcode Reader <version number>\Components\C_C++\Lib\DBRx64.lib
toplatforms\win\DBRx64.lib
-
Add function definitions to
reader.h
and add function implementations toreader.c
. -
Generate
reader.rs
with bindgen.cargo install bindgen cd src bindgen reader.h -o reader.rs
-
Add the local package to your Rust project:
[dependencies] dbr = { path = "../dbr" }