diff --git a/Example/RSKImageCropperExample/RSKImageCropperExample-Info.plist b/Example/RSKImageCropperExample/RSKImageCropperExample-Info.plist
index 7428e26..8300b26 100755
--- a/Example/RSKImageCropperExample/RSKImageCropperExample-Info.plist
+++ b/Example/RSKImageCropperExample/RSKImageCropperExample-Info.plist
@@ -17,7 +17,7 @@
CFBundlePackageType
APPL
CFBundleShortVersionString
- 1.5.1
+ 1.5.2
CFBundleSignature
????
CFBundleVersion
diff --git a/Framework/Info.plist b/Framework/Info.plist
index d18bd0a..c1add73 100755
--- a/Framework/Info.plist
+++ b/Framework/Info.plist
@@ -15,7 +15,7 @@
CFBundlePackageType
FMWK
CFBundleShortVersionString
- 1.5.1
+ 1.5.2
CFBundleSignature
????
CFBundleVersion
diff --git a/RSKImageCropper.podspec b/RSKImageCropper.podspec
index 30ed304..9f04ee2 100644
--- a/RSKImageCropper.podspec
+++ b/RSKImageCropper.podspec
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'RSKImageCropper'
- s.version = '1.5.1'
+ s.version = '1.5.2'
s.summary = 'An image cropper for iOS like in the Contacts app with support for landscape orientation.'
s.homepage = 'https://github.com/ruslanskorb/RSKImageCropper'
s.license = { :type => 'MIT', :file => 'LICENSE' }
diff --git a/RSKImageCropper.xcodeproj/project.pbxproj b/RSKImageCropper.xcodeproj/project.pbxproj
index a228a97..4abade1 100755
--- a/RSKImageCropper.xcodeproj/project.pbxproj
+++ b/RSKImageCropper.xcodeproj/project.pbxproj
@@ -228,7 +228,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
- CURRENT_PROJECT_VERSION = 1.5.1;
+ CURRENT_PROJECT_VERSION = 1.5.2;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
@@ -278,7 +278,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
COPY_PHASE_STRIP = NO;
- CURRENT_PROJECT_VERSION = 1.5.1;
+ CURRENT_PROJECT_VERSION = 1.5.2;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -305,8 +305,8 @@
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
- DYLIB_COMPATIBILITY_VERSION = 1.5.1;
- DYLIB_CURRENT_VERSION = 1.5.1;
+ DYLIB_COMPATIBILITY_VERSION = 1.5.2;
+ DYLIB_CURRENT_VERSION = 1.5.2;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Framework/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
@@ -322,8 +322,8 @@
buildSettings = {
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "";
DEFINES_MODULE = YES;
- DYLIB_COMPATIBILITY_VERSION = 1.5.1;
- DYLIB_CURRENT_VERSION = 1.5.1;
+ DYLIB_COMPATIBILITY_VERSION = 1.5.2;
+ DYLIB_CURRENT_VERSION = 1.5.2;
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = Framework/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
diff --git a/RSKImageCropper/UIImage+RSKImageCropper.m b/RSKImageCropper/UIImage+RSKImageCropper.m
index 716e696..a89f837 100755
--- a/RSKImageCropper/UIImage+RSKImageCropper.m
+++ b/RSKImageCropper/UIImage+RSKImageCropper.m
@@ -110,29 +110,33 @@ - (UIImage *)fixOrientation
- (UIImage *)rotateByAngle:(CGFloat)angleInRadians
{
- // calculate the size of the rotated view's containing box for our drawing space
- UIView *rotatedViewBox = [[UIView alloc] initWithFrame:CGRectMake(0,0,self.size.width, self.size.height)];
- CGAffineTransform t = CGAffineTransformMakeRotation(angleInRadians);
- rotatedViewBox.transform = t;
- CGSize rotatedSize = rotatedViewBox.frame.size;
+ // Calculate the size of the rotated image.
+ UIView *rotatedView = [[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.size.width, self.size.height)];
+ rotatedView.transform = CGAffineTransformMakeRotation(angleInRadians);
+ CGSize rotatedViewSize = rotatedView.frame.size;
- // Create the bitmap context
- UIGraphicsBeginImageContextWithOptions(rotatedSize, NO, self.scale);
- CGContextRef bitmap = UIGraphicsGetCurrentContext();
+ // Create a bitmap-based graphics context.
+ UIGraphicsBeginImageContextWithOptions(rotatedViewSize, NO, self.scale);
- // Move the origin to the middle of the image so we will rotate and scale around the center.
- CGContextTranslateCTM(bitmap, rotatedSize.width/2, rotatedSize.height/2);
+ CGContextRef context = UIGraphicsGetCurrentContext();
- // Rotate the image context
- CGContextRotateCTM(bitmap, angleInRadians);
+ // Move the origin of the user coordinate system in the context to the middle.
+ CGContextTranslateCTM(context, rotatedViewSize.width / 2, rotatedViewSize.height / 2);
- // Now, draw the rotated/scaled image into the context
- CGContextScaleCTM(bitmap, 1.0, -1.0);
- CGContextDrawImage(bitmap, CGRectMake(-self.size.width / 2, -self.size.height / 2, self.size.width, self.size.height), [self CGImage]);
+ // Rotates the user coordinate system in the context.
+ CGContextRotateCTM(context, angleInRadians);
+
+ // Flip the handedness of the user coordinate system in the context.
+ CGContextScaleCTM(context, 1.0, -1.0);
+
+ // Draw the image into the context.
+ CGContextDrawImage(context, CGRectMake(-self.size.width / 2, -self.size.height / 2, self.size.width, self.size.height), self.CGImage);
+
+ UIImage *rotatedImage = UIGraphicsGetImageFromCurrentImageContext();
- UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
- return newImage;
+
+ return rotatedImage;
}
@end