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 0000000..0fd1ded Binary files /dev/null and b/examples/barcode/www/img/cadreCamera.png differ 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