Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C830F200828 for ; Fri, 13 May 2016 20:57:03 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id C6D3C16099F; Fri, 13 May 2016 18:57:03 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 19A6F1602BE for ; Fri, 13 May 2016 20:57:02 +0200 (CEST) Received: (qmail 3373 invoked by uid 500); 13 May 2016 18:57:02 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 3364 invoked by uid 99); 13 May 2016 18:57:02 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 13 May 2016 18:57:02 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 088AEDFC4F; Fri, 13 May 2016 18:57:02 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: nikhilkh@apache.org To: commits@cordova.apache.org Message-Id: <5e756da3e729444f8d888bdcacd33582@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: cordova-plugin-camera git commit: CB-10139 browser: Respect target width and height Date: Fri, 13 May 2016 18:57:02 +0000 (UTC) archived-at: Fri, 13 May 2016 18:57:04 -0000 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 Authored: Sat May 7 14:36:33 2016 -0400 Committer: Nikhil Khandelwal 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