incubator-callback-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Durham (Created) (JIRA)" <j...@apache.org>
Subject [jira] [Created] (CB-183) ios camera targetWidth/Height don't match the documentation
Date Thu, 19 Jan 2012 02:30:39 GMT
ios camera targetWidth/Height don't match the documentation
-----------------------------------------------------------

                 Key: CB-183
                 URL: https://issues.apache.org/jira/browse/CB-183
             Project: Apache Callback
          Issue Type: Bug
          Components: iOS
    Affects Versions: 1.0.0
            Reporter: Durham
            Assignee: Shazron Abdullah


According to the [phonegap camera documentation|http://docs.phonegap.com/en/1.3.0/phonegap_camera_camera.md.html#cameraOptions]
using targetWidth and targetHeight should maintain the aspect ratio of the original photo
. The ios implementation does not do this. Instead it makes the shortest side match the desired
target, and crops the rest.

For example, if I take a 1920x1200 picture, and say targetWidth=1024 and targetHeight=1024,
it results in a 1024x1024 square picture with the excess removed. On android it results in
something like 1024x640, and nothing is cropped.

I'm don't know objective-c, but I believe the fix is to use the following code inside Camera.m
imageByScalingAndCroppingForSize. This is based off the android implementation.

{code:title=Camera.m}
...
if (CGSizeEqualToSize(imageSize, targetSize) == NO) 
{
    CGFloat newRatio = targetWidth / targetHeight;
    CGFloat origRatio = width / height;

    if (origRatio > newRatio) 
    {
        targetHeight = (targetWidth * height) / width
    } 
    else 
    {
        targetWidth = (targetHeight * width) / height;
    }
}

CGSize finalSize = CGSizeMake(targetWidth, targetHeight);
UIGraphicsBeginImageContext(finalSize);

CGRect thumbnailRect = CGRectZero;
thumbnailRect.size.width  = targetWidth;
thumbnailRect.size.height = targetHeight;

[sourceImage drawInRect:thumbnailRect];
...
{code}

I'm currently seeing the problem in 1.0, but from looking at the code it still looks like
a problem in 1.3.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message