From 42eb98290cb6fa7d82b3e32160c49b5acb6c2c79 Mon Sep 17 00:00:00 2001 From: Christophe Boucaut Date: Tue, 27 Jan 2015 11:42:44 +0100 Subject: [PATCH] Add example with codebar application. --- examples/barcode/.gitignore | 9 ++++++ examples/barcode/config.xml | 12 ++++++++ examples/barcode/www/img/cadreCamera.png | Bin 0 -> 2304 bytes examples/barcode/www/index.html | 35 +++++++++++++++++++++++ examples/barcode/www/js/index.js | 30 +++++++++++++++++++ 5 files changed, 86 insertions(+) create mode 100644 examples/barcode/.gitignore create mode 100644 examples/barcode/config.xml create mode 100755 examples/barcode/www/img/cadreCamera.png create mode 100644 examples/barcode/www/index.html create mode 100644 examples/barcode/www/js/index.js diff --git a/examples/barcode/.gitignore b/examples/barcode/.gitignore new file mode 100644 index 0000000..602549b --- /dev/null +++ b/examples/barcode/.gitignore @@ -0,0 +1,9 @@ +platforms/* +!platforms/.gitkeep + +plugins/* +!plugins/.gitkeep + +node_modules/* + +*.DS_Store \ No newline at end of file diff --git a/examples/barcode/config.xml b/examples/barcode/config.xml new file mode 100644 index 0000000..c6e0298 --- /dev/null +++ b/examples/barcode/config.xml @@ -0,0 +1,12 @@ + + + Codebar + + Application's test. + + + Geneanet + + + + \ No newline at end of file diff --git a/examples/barcode/www/img/cadreCamera.png b/examples/barcode/www/img/cadreCamera.png new file mode 100755 index 0000000000000000000000000000000000000000..0fd1ded636867b4768483801ae2ec89af37a639a GIT binary patch literal 2304 zcmeAS@N?(olHy`uVBq!ia0y~yU}9!qV07UCk_^2Y&guXu#^NA%Cx&(BWL^R}Ea{HE zjtmSN`?>!lvNA9*GX(gAxB|uh|NjppN5N=%qI*bL4Lu&j4+Y`L-2QY zRbUd}EbxddW?)Db9n6w&6mUNH|5|3ldA7QL z@jnIQC%=}xaA0-OUS_F^&~@bw%wy7L|*?;fq|)(aZLpH{J(d{`CpzJV=n z>Od*}@SW|G%D(kFH!~6(rsbFzD0rJmNlZ|c=H)ptsh5o{<)j-k^QM%=jf|0-E*@wY z0?O*l4_NRnU^Ho9yTBmjz?{J_%7KN!kDLe3<)2y)r`QH3*!uhj^Pei#_zvD&hLPES j++}zSOrqCnYyL2OetV=ROy{CFsDkoz^>bP0l+XkK>g>^K literal 0 HcmV?d00001 diff --git a/examples/barcode/www/index.html b/examples/barcode/www/index.html new file mode 100644 index 0000000..6d068ce --- /dev/null +++ b/examples/barcode/www/index.html @@ -0,0 +1,35 @@ + + + + + + + + + + Codebar + + + + + + + + diff --git a/examples/barcode/www/js/index.js b/examples/barcode/www/js/index.js new file mode 100644 index 0000000..87a338d --- /dev/null +++ b/examples/barcode/www/js/index.js @@ -0,0 +1,30 @@ +function encodeBase64FromImg(picture, format) { + format = format ? format : "image/jpg"; + + var canvas = document.createElement("canvas"); + canvas.width = picture.naturalWidth; + canvas.height = picture.naturalHeight; + + var ctx = canvas.getContext("2d"); + ctx.drawImage(picture, 0, 0); + + var base64 = canvas.toDataURL(format); + + return base64.replace(/data:[^\/]*\/[^\,]*,/, ""); +}; + +document.getElementById("start-camera").onclick = function() { + navigator.GeneanetCustomCamera.startCamera( + { + imgBackgroundBase64: encodeBase64FromImg(document.getElementsByTagName("img")[0], "image/png"), + opacity: false, + miniature: false + }, + function() { + window.console.log("success"); + }, + function() { + window.console.log("fail"); + } + ); +} \ No newline at end of file