Skip to content

Commit

Permalink
Merge pull request #123 from ruslanskorb/develop
Browse files Browse the repository at this point in the history
Version 1.5.2
  • Loading branch information
ruslanskorb authored Dec 1, 2016
2 parents 5e4fcca + 7fa5d04 commit 50202a6
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.5.1</string>
<string>1.5.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion Framework/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.5.1</string>
<string>1.5.2</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion RSKImageCropper.podspec
Original file line number Diff line number Diff line change
@@ -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' }
Expand Down
12 changes: 6 additions & 6 deletions RSKImageCropper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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";
Expand All @@ -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";
Expand Down
38 changes: 21 additions & 17 deletions RSKImageCropper/UIImage+RSKImageCropper.m
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 50202a6

Please sign in to comment.