mirror of
https://gitee.com/shuto/customCamera.git
synced 2026-05-02 00:07:24 +08:00
Merge branch 'master' into feature-flash
This commit is contained in:
+16
-1
@@ -31,6 +31,10 @@ L'objet `options` contient les options de configuration de l'appareil photo.
|
||||
- **Type :** `string`
|
||||
- **Valeur par défaut :** `null`
|
||||
|
||||
+ **imgBackgroundBase64OtherOrientation :** Image qui sera présente en surimpression de l'appareil photo lorsque l'on tourne l'appareil dans l'autre sens que celui de démarrage du plugin. Elle doit être en base64. Si à `null`, on utilisera `imgBackgroundBase64` en redimensionnant l'image.
|
||||
- **Type :** `string`
|
||||
- **Valeur par défaut :** `null`
|
||||
|
||||
+ **miniature :** Permet d'activer ou non la fonction de miniature. `true` : Active l'option. `false` : Désactive l'option.
|
||||
- **Type :** `boolean`
|
||||
- **Valeur par défaut :** `true`
|
||||
@@ -113,6 +117,18 @@ navigator.GeneanetCustomCamera.startCamera(
|
||||
);
|
||||
```
|
||||
|
||||
### Application de code barre
|
||||
|
||||
[Voir le code](https://github.com/geneanet/customCamera/tree/master/examples/barcode)
|
||||
|
||||

|
||||
|
||||
### Application avec grille
|
||||
|
||||
[Voir le code](https://github.com/geneanet/customCamera/tree/master/examples/grid)
|
||||
|
||||

|
||||
|
||||
### AngularJS
|
||||
|
||||
Une implémentation dans AngularJS a été réalisée pour faciliter son utilisation : [$geneanetCustomCamera](https://github.com/geneanet/customCameraAngular.git).
|
||||
@@ -122,4 +138,3 @@ Une implémentation dans AngularJS a été réalisée pour faciliter son utilisa
|
||||
Pour contribuer à ce projet, merci de respecter les règles suivantes :
|
||||
+ **Les bugs, suggestions, etc :** Ils doivent être remontés via le système d'issues de Github. Merci de vérifier que votre sujet n'a pas déjà été traité.
|
||||
+ **Développement Javascript :** Le code javascript doit être valide avec JSHint.
|
||||
+ **Développement Java :** Le code java doit être valide [Checkstyle](http://eclipse-cs.sourceforge.net/#!/).
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 858 KiB |
@@ -0,0 +1,9 @@
|
||||
platforms/*
|
||||
!platforms/.gitkeep
|
||||
|
||||
plugins/*
|
||||
!plugins/.gitkeep
|
||||
|
||||
node_modules/*
|
||||
|
||||
*.DS_Store
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<widget id="org.geneanet.customCamera.grid" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
|
||||
<name>grid</name>
|
||||
<description>
|
||||
A sample Apache Cordova application that responds to the deviceready event.
|
||||
</description>
|
||||
<author email="dev@cordova.apache.org" href="http://cordova.io">
|
||||
Apache Cordova Team
|
||||
</author>
|
||||
<content src="index.html" />
|
||||
<access origin="*" />
|
||||
</widget>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 826 KiB |
@@ -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>Grid</title>
|
||||
</head>
|
||||
<body>
|
||||
<canvas id="my-canvas"></canvas>
|
||||
<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>
|
||||
@@ -0,0 +1,57 @@
|
||||
function getGrid(inverse) {
|
||||
var format = "image/png";
|
||||
var width = window.innerWidth * devicePixelRatio;
|
||||
var height = window.innerHeight * devicePixelRatio;
|
||||
if (inverse) {
|
||||
width = window.innerHeight * devicePixelRatio;
|
||||
height = window.innerWidth * devicePixelRatio;
|
||||
}
|
||||
var widthInterval = width * 0.25;
|
||||
var heightInterval = height * 0.25;
|
||||
var x = widthInterval;
|
||||
var y = heightInterval;
|
||||
|
||||
var canvas = document.getElementById('my-canvas');;
|
||||
canvas.width = width;
|
||||
canvas.height = height;
|
||||
|
||||
var ctx = canvas.getContext("2d");
|
||||
|
||||
ctx.beginPath();
|
||||
|
||||
while (x < width) {
|
||||
ctx.moveTo(x, 0);
|
||||
ctx.lineTo(x, height);
|
||||
x += widthInterval;
|
||||
}
|
||||
|
||||
while (y < height) {
|
||||
ctx.moveTo(0, y);
|
||||
ctx.lineTo(width, y);
|
||||
y += heightInterval;
|
||||
}
|
||||
ctx.stroke();
|
||||
|
||||
ctx.closePath();
|
||||
|
||||
var base64 = canvas.toDataURL(format);
|
||||
|
||||
return base64.replace(/data:[^\/]*\/[^\,]*,/, "");
|
||||
};
|
||||
|
||||
document.getElementById("start-camera").onclick = function() {
|
||||
navigator.GeneanetCustomCamera.startCamera(
|
||||
{
|
||||
imgBackgroundBase64: getGrid(),
|
||||
imgBackgroundBase64OtherOrientation: getGrid(true),
|
||||
opacity: false,
|
||||
miniature: false
|
||||
},
|
||||
function() {
|
||||
window.console.log("success");
|
||||
},
|
||||
function() {
|
||||
window.console.log("fail");
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -60,14 +60,29 @@ public class CameraLauncher extends CordovaPlugin {
|
||||
TransferBigData.setImgBackgroundBase64(imgBackgroundBase64);
|
||||
}
|
||||
|
||||
intent.putExtra("miniature", args.getBoolean(1));
|
||||
intent.putExtra("saveInGallery", args.getBoolean(2));
|
||||
intent.putExtra("cameraBackgroundColor", args.getString(3));
|
||||
intent.putExtra("cameraBackgroundColorPressed", args.getString(4));
|
||||
if (args.getInt(5) >= 0 && args.getInt(5) <= 100) {
|
||||
intent.putExtra("quality", args.getInt(5));
|
||||
if (args.getString(1) != "null") {
|
||||
byte[] imgBackgroundBase64OtherOrientation;
|
||||
try {
|
||||
imgBackgroundBase64OtherOrientation = Base64
|
||||
.decode(args.getString(1), Base64.NO_WRAP);
|
||||
} catch (IllegalArgumentException e) {
|
||||
this.callbackContext.error(generateError(CameraLauncher.RESULT_ERROR,
|
||||
"Error decode base64 picture."));
|
||||
|
||||
return false;
|
||||
}
|
||||
TransferBigData.setImgBackgroundBase64OtherOrientation(imgBackgroundBase64OtherOrientation);
|
||||
}
|
||||
intent.putExtra("opacity", args.getBoolean(6));
|
||||
|
||||
intent.putExtra("miniature", args.getBoolean(2));
|
||||
intent.putExtra("saveInGallery", args.getBoolean(3));
|
||||
intent.putExtra("cameraBackgroundColor", args.getString(4));
|
||||
intent.putExtra("cameraBackgroundColorPressed", args.getString(5));
|
||||
if (args.getInt(6) >= 0 && args.getInt(6) <= 100) {
|
||||
intent.putExtra("quality", args.getInt(6));
|
||||
}
|
||||
intent.putExtra("opacity", args.getBoolean(7));
|
||||
intent.putExtra("startOrientation", this.cordova.getActivity().getResources().getConfiguration().orientation);
|
||||
|
||||
cordova.startActivityForResult((CordovaPlugin) this, intent,
|
||||
CameraLauncher.REQUEST_CODE);
|
||||
|
||||
@@ -2,7 +2,12 @@
|
||||
.project
|
||||
.classpath
|
||||
project.properties
|
||||
ant.properties
|
||||
build.xml
|
||||
local.properties
|
||||
proguard-project.txt
|
||||
|
||||
nbandroid/*
|
||||
bin/*
|
||||
gen/*
|
||||
libs/*
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
# This file is automatically generated by Android Tools.
|
||||
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system edit
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
#
|
||||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
|
||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||
|
||||
# Project target.
|
||||
target=Google Inc.:Google APIs:14
|
||||
@@ -398,7 +398,16 @@ public class CameraActivity extends Activity {
|
||||
/** To set background in the view. */
|
||||
protected void setBackground() {
|
||||
// Get the base64 picture for the background only if it's exist.
|
||||
byte[] imgBackgroundBase64 = TransferBigData.getImgBackgroundBase64();
|
||||
byte[] imgBackgroundBase64;
|
||||
if (
|
||||
TransferBigData.getImgBackgroundBase64OtherOrientation() == null ||
|
||||
this.getIntent().getIntExtra("startOrientation", 1)
|
||||
== this.getResources().getConfiguration().orientation
|
||||
) {
|
||||
imgBackgroundBase64 = TransferBigData.getImgBackgroundBase64();
|
||||
} else {
|
||||
imgBackgroundBase64 = TransferBigData.getImgBackgroundBase64OtherOrientation();
|
||||
}
|
||||
if (imgBackgroundBase64 != null) {
|
||||
// Get picture.
|
||||
Bitmap imgBackgroundBitmap = BitmapFactory.decodeByteArray(
|
||||
|
||||
@@ -5,6 +5,7 @@ package org.geneanet.customcamera;
|
||||
*/
|
||||
public class TransferBigData {
|
||||
protected static byte[] imgBackgroundBase64 = null;
|
||||
protected static byte[] imgBackgroundBase64OtherOrientation = null;
|
||||
protected static byte[] imgTaken = null;
|
||||
|
||||
/**
|
||||
@@ -25,6 +26,24 @@ public class TransferBigData {
|
||||
TransferBigData.imgBackgroundBase64 = imgBackgroundBase64;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bytes to represent background picture for OtherOrientation.
|
||||
*
|
||||
* @return byte[]
|
||||
*/
|
||||
public static byte[] getImgBackgroundBase64OtherOrientation() {
|
||||
return TransferBigData.imgBackgroundBase64OtherOrientation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set bytes to represent background picture for OtherOrientation.
|
||||
*
|
||||
* @param byte[] imgBackgroundBase64OtherOrientation
|
||||
*/
|
||||
public static void setImgBackgroundBase64OtherOrientation(byte[] imgBackgroundBase64OtherOrientation) {
|
||||
TransferBigData.imgBackgroundBase64OtherOrientation = imgBackgroundBase64OtherOrientation;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get bytes to represent picture taken.
|
||||
*
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
CustomCameraExport.prototype.startCamera = function(options, successFct, failFct) {
|
||||
var defaultOptions = {
|
||||
imgBackgroundBase64: null, // background picture in base64.
|
||||
imgBackgroundBase64OtherOrientation: null, // background picture in base64 for second orientation. If it's not defined, imgBackgroundBase64 is used.
|
||||
miniature: true, // active or disable the miniature function.
|
||||
saveInGallery: false, // save or not the picture in gallery.
|
||||
cameraBackgroundColor: "#e26760", // color of the camera button.
|
||||
@@ -47,6 +48,7 @@
|
||||
"startCamera",
|
||||
[
|
||||
options.imgBackgroundBase64,
|
||||
options.imgBackgroundBase64OtherOrientation,
|
||||
options.miniature,
|
||||
options.saveInGallery,
|
||||
options.cameraBackgroundColor,
|
||||
|
||||
Reference in New Issue
Block a user