Skip to content

Commit

Permalink
fixes issue #21
Browse files Browse the repository at this point in the history
this fixes the issue where a landscape croparea did work. thanks
@ziweizhou for fixing this!
  • Loading branch information
gekitz committed May 19, 2013
1 parent e1d527a commit 4b7077f
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions GKClasses/GKImageCropView.m
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,19 @@ - (UIImage *)croppedImage{
//scaled width/height in regards of real width to crop width
CGFloat scaleWidth = self.imageToCrop.size.width / self.cropSize.width;
CGFloat scaleHeight = self.imageToCrop.size.height / self.cropSize.height;
CGFloat scale = MAX(scaleWidth, scaleHeight);
CGFloat scale = 0.0f;

//extract visible rect from scrollview and scale it
if (self.cropSize.width > self.cropSize.height) {
scale = (self.imageToCrop.size.width < self.imageToCrop.size.height ?
MAX(scaleWidth, scaleHeight) :
MIN(scaleWidth, scaleHeight));
}else{
scale = (self.imageToCrop.size.width < self.imageToCrop.size.height ?
MIN(scaleWidth, scaleHeight) :
MAX(scaleWidth, scaleHeight));
}

//extract visible rect from scrollview and scale it
CGRect visibleRect = [scrollView convertRect:scrollView.bounds toView:imageView];
visibleRect = GKScaleRect(visibleRect, scale);

Expand Down

0 comments on commit 4b7077f

Please sign in to comment.