You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ni...@apache.org on 2016/05/13 18:57:02 UTC
cordova-plugin-camera git commit: CB-10139 browser: Respect target
width and height
Repository: cordova-plugin-camera
Updated Branches:
refs/heads/master 2a7469e06 -> 7551778e1
CB-10139 browser: Respect target width and height
This closes #210
Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/commit/7551778e
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/tree/7551778e
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/diff/7551778e
Branch: refs/heads/master
Commit: 7551778e13ff96d1d712b7e7d2caa87ad079ca71
Parents: 2a7469e
Author: Keith M <ke...@aoeex.com>
Authored: Sat May 7 14:36:33 2016 -0400
Committer: Nikhil Khandelwal <ni...@microsoft.com>
Committed: Fri May 13 11:56:43 2016 -0700
----------------------------------------------------------------------
src/browser/CameraProxy.js | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-camera/blob/7551778e/src/browser/CameraProxy.js
----------------------------------------------------------------------
diff --git a/src/browser/CameraProxy.js b/src/browser/CameraProxy.js
index 23ace0b..89ee3cc 100644
--- a/src/browser/CameraProxy.js
+++ b/src/browser/CameraProxy.js
@@ -23,7 +23,7 @@ var HIGHEST_POSSIBLE_Z_INDEX = 2147483647;
function takePicture(success, error, opts) {
if (opts && opts[2] === 1) {
- capture(success, error);
+ capture(success, error, opts);
} else {
var input = document.createElement('input');
input.style.position = 'relative';
@@ -48,8 +48,13 @@ function takePicture(success, error, opts) {
}
}
-function capture(success, errorCallback) {
+function capture(success, errorCallback, opts) {
var localMediaStream;
+ var targetWidth = opts[3];
+ var targetHeight = opts[4];
+
+ targetWidth = targetWidth == -1?320:targetWidth;
+ targetHeight = targetHeight == -1?240:targetHeight;
var video = document.createElement('video');
var button = document.createElement('button');
@@ -59,14 +64,16 @@ function capture(success, errorCallback) {
parent.appendChild(video);
parent.appendChild(button);
- video.width = 320;
- video.height = 240;
+ video.width = targetWidth;
+ video.height = targetHeight;
button.innerHTML = 'Capture!';
button.onclick = function() {
// create a canvas and capture a frame from video stream
var canvas = document.createElement('canvas');
- canvas.getContext('2d').drawImage(video, 0, 0, 320, 240);
+ canvas.width = targetWidth;
+ canvas.height = targetHeight;
+ canvas.getContext('2d').drawImage(video, 0, 0, targetWidth, targetHeight);
// convert image stored in canvas to base64 encoded image
var imageData = canvas.toDataURL('image/png');
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org