From 89447bf11bed884824fff865927495ab4cb1f12e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?So=CC=88ren=20Busch?= Date: Tue, 29 Oct 2013 14:26:16 +0100 Subject: [PATCH 1/2] fixed wrong cropping with scaled images --- GKClasses/GKImageCropView.m | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) mode change 100644 => 100755 GKClasses/GKImageCropView.m diff --git a/GKClasses/GKImageCropView.m b/GKClasses/GKImageCropView.m old mode 100644 new mode 100755 index f0e1d01..01d7137 --- a/GKClasses/GKImageCropView.m +++ b/GKClasses/GKImageCropView.m @@ -125,27 +125,18 @@ - (CGRect)_calcVisibleRectForResizeableCropArea{ return visibleRect = GKScaleRect(visibleRect, sizeScale); } --(CGRect)_calcVisibleRectForCropArea{ - //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 = 0.0f; - - 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)); - } +-(CGRect)_calcVisibleRectForCropArea +{ + CGFloat scale = self.imageView.image.size.width / self.imageView.frame.size.width; + scale *= self.scrollView.zoomScale; + //extract visible rect from scrollview and scale it CGRect visibleRect = [scrollView convertRect:scrollView.bounds toView:imageView]; - return visibleRect = GKScaleRect(visibleRect, scale); + visibleRect = GKScaleRect(visibleRect, scale); + + return visibleRect; } - - (CGAffineTransform)_orientationTransformedRectOfImage:(UIImage *)img { CGAffineTransform rectTransform; From 73d20cde6fb37c004f72622effbfdc52894f0934 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?So=CC=88ren=20Busch?= Date: Tue, 29 Oct 2013 14:35:39 +0100 Subject: [PATCH 2/2] added pod spec --- GKImagePicker.podspec | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 GKImagePicker.podspec diff --git a/GKImagePicker.podspec b/GKImagePicker.podspec new file mode 100644 index 0000000..ddb466b --- /dev/null +++ b/GKImagePicker.podspec @@ -0,0 +1,20 @@ +Pod::Spec.new do |s| + s.name = 'GKImagePicker' + s.version = '0.0.2' + s.license = 'MIT' + s.platform = :ios, '5.0' + s.summary = 'Image Picker with support for custom crop areas.' + s.description = 'Ever wanted a custom crop area for the UIImagePickerController?' \ + 'Now you can have it with GKImagePicker. Just set your custom' \ + 'crop area and thats it. Just 4 lines of code. If you dont' \ + 'set it it uses the same crop area as the default' \ + 'UIImagePickerController.' + s.homepage = 'https://github.com/gekitz/GKImagePicker' + s.author = { 'Georg Kitz' => 'info@aurora-apps.com' } + s.source = { :git => 'https://github.com/fleshgolem/GKImagePicker.git', :commit => '89447bf11bed884824fff865927495ab4cb1f12e' } + s.resources = 'GKImages/*.png' + s.source_files = 'GKClasses/*.{h,m}' + s.preserve_paths = 'GKClasses', 'GKImages' + s.frameworks = 'UIKit' + s.requires_arc = true +end