mirror of
https://gitee.com/shuto/customCamera.git
synced 2024-10-06 10:22:07 +08:00
Add example with codebar application.
This commit is contained in:
parent
96a5da95ca
commit
42eb98290c
9
examples/barcode/.gitignore
vendored
Normal file
9
examples/barcode/.gitignore
vendored
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
platforms/*
|
||||||
|
!platforms/.gitkeep
|
||||||
|
|
||||||
|
plugins/*
|
||||||
|
!plugins/.gitkeep
|
||||||
|
|
||||||
|
node_modules/*
|
||||||
|
|
||||||
|
*.DS_Store
|
12
examples/barcode/config.xml
Normal file
12
examples/barcode/config.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
|
<widget id="org.geneanet.customCamera.Barcode" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
|
||||||
|
<name>Codebar</name>
|
||||||
|
<description>
|
||||||
|
Application's test.
|
||||||
|
</description>
|
||||||
|
<author href="http://www.geneanet.org/" email="">
|
||||||
|
Geneanet
|
||||||
|
</author>
|
||||||
|
<content src="index.html"/>
|
||||||
|
<access origin="*"/>
|
||||||
|
</widget>
|
BIN
examples/barcode/www/img/cadreCamera.png
Executable file
BIN
examples/barcode/www/img/cadreCamera.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
35
examples/barcode/www/index.html
Normal file
35
examples/barcode/www/index.html
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<!--
|
||||||
|
Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
or more contributor license agreements. See the NOTICE file
|
||||||
|
distributed with this work for additional information
|
||||||
|
regarding copyright ownership. The ASF licenses this file
|
||||||
|
to you under the Apache License, Version 2.0 (the
|
||||||
|
"License"); you may not use this file except in compliance
|
||||||
|
with the License. You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing,
|
||||||
|
software distributed under the License is distributed on an
|
||||||
|
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
KIND, either express or implied. See the License for the
|
||||||
|
specific language governing permissions and limitations
|
||||||
|
under the License.
|
||||||
|
-->
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8" />
|
||||||
|
<meta name="format-detection" content="telephone=no" />
|
||||||
|
<meta name="msapplication-tap-highlight" content="no" />
|
||||||
|
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
|
||||||
|
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
|
||||||
|
<title>Codebar</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<img src="img/cadreCamera.png" />
|
||||||
|
<button id="start-camera">Start camera</button>
|
||||||
|
<script type="text/javascript" src="cordova.js"></script>
|
||||||
|
<script type="text/javascript" src="js/index.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
30
examples/barcode/www/js/index.js
Normal file
30
examples/barcode/www/js/index.js
Normal file
@ -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");
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user