Created
March 5, 2016 05:05
-
-
Save bauloc/c3b96fc422b70885dd74 to your computer and use it in GitHub Desktop.
Resize Image
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Resize Image | |
+ (UIImage *)ResizeImage:(UIImage*)originalImage scaledToSize:(CGSize)size | |
{ | |
//avoid redundant drawing | |
if (CGSizeEqualToSize(originalImage.size, size)) | |
{ | |
return originalImage; | |
} | |
//create drawing context | |
UIGraphicsBeginImageContextWithOptions(size, NO, 0.0f); | |
//draw | |
[originalImage drawInRect:CGRectMake(0.0f, 0.0f, size.width, size.height)]; | |
//capture resultant image | |
UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
//return image | |
return image; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment