[ 
https://issues.apache.org/jira/browse/CB-2737?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Dimitri Adamou updated CB-2737:
-------------------------------

    Description: 
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

  was:
Hey there, noticed windows8 phone proj. was missing aspect ratio resize so 
added it in (Essentially copied iOS code)

---

        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;
        }

---

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

    
> Camera.getPicture(); aspect ratio resize. Camera.cs
> ---------------------------------------------------
>
>                 Key: CB-2737
>                 URL: https://issues.apache.org/jira/browse/CB-2737
>             Project: Apache Cordova
>          Issue Type: Improvement
>          Components: CordovaJS
>    Affects Versions: 2.5.0
>         Environment: Windows8. Camera.cs
>            Reporter: Dimitri Adamou
>            Assignee: Filip Maj
>
> 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 is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to