mirror of
https://gitee.com/shuto/customCamera.git
synced 2026-05-02 00:07:24 +08:00
Ajout d'une option pour changer l'image en surimpression en fonction de l'orientation de l'écran.
This commit is contained in:
@@ -1,7 +1,11 @@
|
|||||||
function getGrid() {
|
function getGrid(inverse) {
|
||||||
var format = "image/png";
|
var format = "image/png";
|
||||||
var width = window.innerWidth * devicePixelRatio;
|
var width = window.innerWidth * devicePixelRatio;
|
||||||
var height = window.innerHeight * devicePixelRatio;
|
var height = window.innerHeight * devicePixelRatio;
|
||||||
|
if (inverse) {
|
||||||
|
width = window.innerHeight * devicePixelRatio;
|
||||||
|
height = window.innerWidth * devicePixelRatio;
|
||||||
|
}
|
||||||
var widthInterval = width * 0.25;
|
var widthInterval = width * 0.25;
|
||||||
var heightInterval = height * 0.25;
|
var heightInterval = height * 0.25;
|
||||||
var x = widthInterval;
|
var x = widthInterval;
|
||||||
@@ -39,6 +43,7 @@ document.getElementById("start-camera").onclick = function() {
|
|||||||
navigator.GeneanetCustomCamera.startCamera(
|
navigator.GeneanetCustomCamera.startCamera(
|
||||||
{
|
{
|
||||||
imgBackgroundBase64: getGrid(),
|
imgBackgroundBase64: getGrid(),
|
||||||
|
imgBackgroundBase64OtherOrientation: getGrid(true),
|
||||||
opacity: false,
|
opacity: false,
|
||||||
miniature: false
|
miniature: false
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -60,14 +60,29 @@ public class CameraLauncher extends CordovaPlugin {
|
|||||||
TransferBigData.setImgBackgroundBase64(imgBackgroundBase64);
|
TransferBigData.setImgBackgroundBase64(imgBackgroundBase64);
|
||||||
}
|
}
|
||||||
|
|
||||||
intent.putExtra("miniature", args.getBoolean(1));
|
if (args.getString(1) != "null") {
|
||||||
intent.putExtra("saveInGallery", args.getBoolean(2));
|
byte[] imgBackgroundBase64OtherOrientation;
|
||||||
intent.putExtra("cameraBackgroundColor", args.getString(3));
|
try {
|
||||||
intent.putExtra("cameraBackgroundColorPressed", args.getString(4));
|
imgBackgroundBase64OtherOrientation = Base64
|
||||||
if (args.getInt(5) >= 0 && args.getInt(5) <= 100) {
|
.decode(args.getString(1), Base64.NO_WRAP);
|
||||||
intent.putExtra("quality", args.getInt(5));
|
} 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,
|
cordova.startActivityForResult((CordovaPlugin) this, intent,
|
||||||
CameraLauncher.REQUEST_CODE);
|
CameraLauncher.REQUEST_CODE);
|
||||||
|
|||||||
@@ -396,7 +396,15 @@ public class CameraActivity extends Activity {
|
|||||||
/** To set background in the view. */
|
/** To set background in the view. */
|
||||||
protected void setBackground() {
|
protected void setBackground() {
|
||||||
// Get the base64 picture for the background only if it's exist.
|
// 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) {
|
if (imgBackgroundBase64 != null) {
|
||||||
// Get picture.
|
// Get picture.
|
||||||
Bitmap imgBackgroundBitmap = BitmapFactory.decodeByteArray(
|
Bitmap imgBackgroundBitmap = BitmapFactory.decodeByteArray(
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ package org.geneanet.customcamera;
|
|||||||
*/
|
*/
|
||||||
public class TransferBigData {
|
public class TransferBigData {
|
||||||
protected static byte[] imgBackgroundBase64 = null;
|
protected static byte[] imgBackgroundBase64 = null;
|
||||||
|
protected static byte[] imgBackgroundBase64OtherOrientation = null;
|
||||||
protected static byte[] imgTaken = null;
|
protected static byte[] imgTaken = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -25,6 +26,24 @@ public class TransferBigData {
|
|||||||
TransferBigData.imgBackgroundBase64 = imgBackgroundBase64;
|
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.
|
* Get bytes to represent picture taken.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
CustomCameraExport.prototype.startCamera = function(options, successFct, failFct) {
|
CustomCameraExport.prototype.startCamera = function(options, successFct, failFct) {
|
||||||
var defaultOptions = {
|
var defaultOptions = {
|
||||||
imgBackgroundBase64: null, // background picture in base64.
|
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.
|
miniature: true, // active or disable the miniature function.
|
||||||
saveInGallery: false, // save or not the picture in gallery.
|
saveInGallery: false, // save or not the picture in gallery.
|
||||||
cameraBackgroundColor: "#e26760", // color of the camera button.
|
cameraBackgroundColor: "#e26760", // color of the camera button.
|
||||||
@@ -47,6 +48,7 @@
|
|||||||
"startCamera",
|
"startCamera",
|
||||||
[
|
[
|
||||||
options.imgBackgroundBase64,
|
options.imgBackgroundBase64,
|
||||||
|
options.imgBackgroundBase64OtherOrientation,
|
||||||
options.miniature,
|
options.miniature,
|
||||||
options.saveInGallery,
|
options.saveInGallery,
|
||||||
options.cameraBackgroundColor,
|
options.cameraBackgroundColor,
|
||||||
|
|||||||
Reference in New Issue
Block a user