cordova-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF subversion and git services (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CB-2737) WP8: Camera.getPicture(); aspect ratio resize patch
Date Tue, 08 Apr 2014 18:53:17 GMT

    [ https://issues.apache.org/jira/browse/CB-2737?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13963300#comment-13963300
] 

ASF subversion and git services commented on CB-2737:
-----------------------------------------------------

Commit e7a3d70fe969f75b795ca216dd9173f8df1635ee in cordova-plugin-camera's branch refs/heads/dev
from [~purplecabbage]
[ https://git-wip-us.apache.org/repos/asf?p=cordova-plugin-camera.git;h=e7a3d70 ]

Fix camera issues, cropping, memory leaks CB-4027, CB-5102, CB-2737, CB-2387


> 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
>            Assignee: Jesse MacFadyen
>
> 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.2#6252)

Mime
View raw message