summaryrefslogtreecommitdiff
path: root/Juick/UIImage+Crop.m
diff options
context:
space:
mode:
Diffstat (limited to 'Juick/UIImage+Crop.m')
-rw-r--r--Juick/UIImage+Crop.m28
1 files changed, 28 insertions, 0 deletions
diff --git a/Juick/UIImage+Crop.m b/Juick/UIImage+Crop.m
new file mode 100644
index 0000000..d51b94e
--- /dev/null
+++ b/Juick/UIImage+Crop.m
@@ -0,0 +1,28 @@
+//
+// UIImage+Crop.m
+// Juick
+//
+// Created by Vitaly Takmazov on 05.11.13.
+// Copyright (c) 2013 com.juick. All rights reserved.
+//
+
+#import "UIImage+Crop.h"
+
+@implementation UIImage (Crop)
+
+- (UIImage *)crop:(CGRect)rect {
+
+ rect = CGRectMake(rect.origin.x*self.scale,
+ rect.origin.y*self.scale,
+ rect.size.width*self.scale,
+ rect.size.height*self.scale);
+
+ CGImageRef imageRef = CGImageCreateWithImageInRect([self CGImage], rect);
+ UIImage *result = [UIImage imageWithCGImage:imageRef
+ scale:self.scale
+ orientation:self.imageOrientation];
+ CGImageRelease(imageRef);
+ return result;
+}
+
+@end