Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cropped image doesn't match selected crop are when CropSize doesn't have same aspect ratio as SourceImage #7

Open
Heroico opened this issue Jan 8, 2014 · 0 comments

Comments

@Heroico
Copy link

Heroico commented Jan 8, 2014

Hi There! Before anything else, I want to thank the contributors for all the hard work into this component.

I am experiencing the following issue, in iOS 7.0:

  1. I take a picture with the ipad rear camera
  2. GKImageCropViewController gets pushed, with a crop size of (612, 792) (letter size paper)
  3. I select a portion to crop, hit "use" button
  4. The cropped image has the right aspect ratio ( 792/612 ) but wasn't cropped from the same area selected in 3)

I took pictures of grids to be really sure that (4) gets the wrong area. The origin of the cropped image nearly matches the selected area, but the size is wrong.

If between (1) and (2), I process the source image to have the aspect ratio of the target CropSize, the issue doesn't happen and I get a cropped image with the right cropped area.

I am pretty sure the problem is at

//GKImageCropView
-(CGRect)_calcVisibleRectForCropArea;

When debugging this method, I see:

  1. the GKImageCropView.scrollView has size (612,792). the imageView has size around (592,792). The sourceImage has size (1936,2592).
  2. the scaleWidth is calculated from the image.size and the cropSize:
CGFloat scaleWidth = self.imageToCrop.size.width / self.cropSize.width;
// then "scale" variable gets set to this value
  1. The crop rectangle gets calculated from a transformation from scrollView to imageView
    CGRect visibleRect = [scrollView convertRect:scrollView.bounds toView:imageView];
// then visibleRect gets scaled according to "scale"

So, in short, the scale gets defined with an aspect ratio from image.size/cropSize, but the crop area gets defined from scaling the result scroll view -> imageView.

Should the scaleWidth and scaleHeight be calculated from imageView.size/cropSize?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant