From d4188a9157a0400bef44fd7c250d1ae4a4d372cb Mon Sep 17 00:00:00 2001 From: Carlos Rios Date: Tue, 12 Jan 2016 04:25:54 -0200 Subject: [PATCH 1/4] Method to stop the camera preview, so all memory consuption, processor and energy drops --- www/CanvasCamera.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/www/CanvasCamera.js b/www/CanvasCamera.js index 720b0cc..78e9d46 100755 --- a/www/CanvasCamera.js +++ b/www/CanvasCamera.js @@ -40,7 +40,7 @@ cordova.define("cordova/plugin/CanvasCamera", function(require, exports, module) // rotate 90 _this._context.translate(_this._width/2, _this._height/2); _this._context.rotate((90 - window.orientation) *Math.PI/180); - _this._context.drawImage(_this._camImage, 0, 0, 352, 288, -_this._width/2, -_this._height/2, _this._width, _this._height); + _this._context.drawImage(_this._camImage, 0, 0, 320, 320, -_this._width/2, -_this._height/2, _this._width, _this._height); // _this._context.restore(); } @@ -50,7 +50,7 @@ cordova.define("cordova/plugin/CanvasCamera", function(require, exports, module) // rotate 90 _this._context.translate(_this._width/2, _this._height/2); _this._context.rotate((90 - window.orientation)*Math.PI/180); - _this._context.drawImage(_this._camImage, 0, 0, 352, 288, -_this._height/2, -_this._width/2, _this._height, _this._width); + _this._context.drawImage(_this._camImage, 0, 0, 320, 320, -_this._height/2, -_this._width/2, _this._height, _this._width); // _this._context.restore(); } @@ -66,6 +66,10 @@ cordova.define("cordova/plugin/CanvasCamera", function(require, exports, module) cordova.exec(false, false, "CanvasCamera", "startCapture", [options]); }; + CanvasCamera.prototype.stop = function() { + cordova.exec(false, false, "CanvasCamera", "stopCapture", []); + }; + CanvasCamera.prototype.capture = function(data) { From 072278018eafe213e775e7ba2be21cb993d43233 Mon Sep 17 00:00:00 2001 From: Carlos Rios Date: Tue, 12 Jan 2016 04:50:23 -0200 Subject: [PATCH 2/4] backing to 352, 288 --- www/CanvasCamera.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/www/CanvasCamera.js b/www/CanvasCamera.js index 78e9d46..6edf3ce 100755 --- a/www/CanvasCamera.js +++ b/www/CanvasCamera.js @@ -40,7 +40,7 @@ cordova.define("cordova/plugin/CanvasCamera", function(require, exports, module) // rotate 90 _this._context.translate(_this._width/2, _this._height/2); _this._context.rotate((90 - window.orientation) *Math.PI/180); - _this._context.drawImage(_this._camImage, 0, 0, 320, 320, -_this._width/2, -_this._height/2, _this._width, _this._height); + _this._context.drawImage(_this._camImage, 0, 0, 352, 288, -_this._width/2, -_this._height/2, _this._width, _this._height); // _this._context.restore(); } @@ -50,7 +50,7 @@ cordova.define("cordova/plugin/CanvasCamera", function(require, exports, module) // rotate 90 _this._context.translate(_this._width/2, _this._height/2); _this._context.rotate((90 - window.orientation)*Math.PI/180); - _this._context.drawImage(_this._camImage, 0, 0, 320, 320, -_this._height/2, -_this._width/2, _this._height, _this._width); + _this._context.drawImage(_this._camImage, 0, 0, 352, 288, -_this._height/2, -_this._width/2, _this._height, _this._width); // _this._context.restore(); } From f014875b91ef86d4b4eaa4561e47964388ec9ed1 Mon Sep 17 00:00:00 2001 From: Carlos Rios Date: Tue, 12 Jan 2016 04:55:22 -0200 Subject: [PATCH 3/4] Update README.md --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index 8d106ad..bcd64e2 100644 --- a/README.md +++ b/README.md @@ -99,6 +99,13 @@ function onStartClicked() } ``` +### stop +stop video preview, then CPU and Memory consumption will drop.
+ +```javascript +window.CanvasCamera.stop(); +``` + ### takePicture take a photo.
@@ -256,6 +263,7 @@ CanvasCamera.PictureSourceType = {
+ @@ -327,6 +335,12 @@ CanvasCamera.PictureSourceType = { function onTakeSuccess(data) { // } + + function onStopPreview() { + CanvasCamera.stop(); + } + + From b8ebf673782af0b293842d6db10fc0c80d7ee8b4 Mon Sep 17 00:00:00 2001 From: Carlos Rios Date: Tue, 12 Jan 2016 04:56:25 -0200 Subject: [PATCH 4/4] bump minor version --- plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin.xml b/plugin.xml index 8e9874b..2dce916 100644 --- a/plugin.xml +++ b/plugin.xml @@ -2,7 +2,7 @@ + version="1.1.0"> CanvasCamera