Skip to content

Instantly share code, notes, and snippets.

View yushulx's full-sized avatar

Xiao Ling yushulx

View GitHub Profile
<?php
$fileName = $_FILES['afile']['name'];
$fileType = $_FILES['afile']['type'];
$fileContent = file_get_contents($_FILES['afile']['tmp_name']);
$dataUrl = 'data:' . $fileType . ';base64,' . base64_encode($fileContent);
$json = json_encode(array(
'name' => $fileName,
'type' => $fileType,
'dataUrl' => $dataUrl,
@yushulx
yushulx / app.js
Last active June 14, 2019 02:13
How to use Dynamic Web TWAIN with Vue.js
var app = new Vue({
el: '#app',
data: {
title: 'DWT + Vue.js',
button: 'Scan'
},
methods: {
acquireImage: function () {
var DWObject = Dynamsoft.WebTwainEnv.GetWebTwain('dwtcontrolContainer');
DWObject.IfDisableSourceAfterAcquire = true;
@yushulx
yushulx / index.htm
Created December 7, 2017 02:15
How to Use Dynamic Web TWAIN with Dojo
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tutorial: Hello Dojo!</title>
<link rel="stylesheet" href="bower_components/dijit/themes/claro/claro.css">
<script>dojoConfig = {parseOnLoad: true}</script>
<script src="bower_components/dojo/dojo.js"></script>
<script type="text/javascript" src="https://www.dynamsoft.com/library/dwt/dynamsoft.webtwain.min.js"></script>
@yushulx
yushulx / index.htm
Created December 7, 2017 02:28
How to use Dynamsoft Camera SDK with Dojo
<!DOCTYPE html>
<html>
<head>
<title>Hello World</title>
<link rel="stylesheet" href="bower_components/dijit/themes/claro/claro.css">
<script>
dojoConfig = {
parseOnLoad: true
}
@yushulx
yushulx / wasm.htm
Last active August 20, 2018 06:19
How to use Dynamsoft Pure JavaScript barcode SDK
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>
<div id="divLoadInfo">loading...</div>
<input id="uploadImage" type="file" accept="image/bmp,image/jpeg,image/png,image/gif">
<script src="https://demo.dynamsoft.com/dbr_wasm/js/dbr-6.3.0.min.js"></script>
use std::env;
fn main() {
let args: Vec<String> = env::args().collect();
if args.len() == 1 {
println!("Please input an image file.");
return
}
let file_name = env::args().nth(1).expect("Missing argument");
println!("{}", file_name);
typedef struct Barcode {
char* barcode_type;
char* barcode_value;
} Barcode;
typedef __int32 int32_t;
typedef void (*RustCallback)(int32_t, const char *, const char *);
int32_t register_callback(RustCallback callback);
void c_decodeFile(const char *fileName, const char *pszLicense);
#include "bridge.h"
#include "DynamsoftBarcodeReader.h"
#include <stdio.h>
RustCallback cb;
int32_t register_callback(RustCallback callback) {
cb = callback;
return 1;
}
extern crate cc;
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");
extern crate bindgen;
fn main() {
// Generates Rust FFI bindings.
let bindings = bindgen::Builder::default()
// The input header we would like to generate
// bindings for.
.header("src/bridge.h")
// Finish the builder and generate the bindings.
.generate()