Return-Path: X-Original-To: apmail-cordova-issues-archive@minotaur.apache.org Delivered-To: apmail-cordova-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1448D10DD6 for ; Mon, 7 Oct 2013 19:35:44 +0000 (UTC) Received: (qmail 80847 invoked by uid 500); 7 Oct 2013 19:35:43 -0000 Delivered-To: apmail-cordova-issues-archive@cordova.apache.org Received: (qmail 80799 invoked by uid 500); 7 Oct 2013 19:35:43 -0000 Mailing-List: contact issues-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cordova.apache.org Delivered-To: mailing list issues@cordova.apache.org Received: (qmail 80684 invoked by uid 99); 7 Oct 2013 19:35:42 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 07 Oct 2013 19:35:42 +0000 Date: Mon, 7 Oct 2013 19:35:42 +0000 (UTC) From: "Steve Gill (JIRA)" To: issues@cordova.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Updated] (CB-2737) WP8: Camera.getPicture(); aspect ratio resize patch MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/CB-2737?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Steve Gill updated CB-2737: --------------------------- Assignee: (was: Steve Gill) > WP8: Camera.getPicture(); aspect ratio resize patch > --------------------------------------------------- > > Key: CB-2737 > URL: https://issues.apache.org/jira/browse/CB-2737 > Project: Apache Cordova > Issue Type: Improvement > Components: Plugin Camera, WP8 > Affects Versions: 2.5.0 > Environment: Windows8. Camera.cs > Reporter: Dimitri Adamou > > Hey there, noticed windows8 phone proj. was missing aspect ratio resize so added it in (Essentially copied iOS code) > --- > {code:title=Camera.cs|borderStyle=solid} > private struct ResizeDimension > { > public int width; > public int height; > } > private ResizeDimension ResizeAspectRatio(int oWidth, int oHeight, int tWidth, int tHeight) > { > ResizeDimension tgt; > float widthFactor = (float)tWidth / (float)oWidth; > float heightFactor = (float)tHeight / (float)oHeight; > float scaleFactor; > if (widthFactor > heightFactor) > scaleFactor = heightFactor; > else > scaleFactor = widthFactor; > tgt.width = (int)Math.Min((float)oWidth * scaleFactor, tWidth); > tgt.height= (int)Math.Min((float)oHeight * scaleFactor, tHeight); > return tgt; > } > {code} > --- > and works via > ResizeDimension rd = ResizeAspectRatio(image.PixelWidth, image.PixelHeight, cameraOptions.TargetWidth, cameraOptions.TargetHeight); > > image.SaveJpeg(stream, rd.width, rd.height, 0, cameraOptions.Quality); > Cheers, > Dim -- This message was sent by Atlassian JIRA (v6.1#6144)