Last active
December 12, 2015 09:49
-
-
Save derektu/4754106 to your computer and use it in GitHub Desktop.
UIImage extension
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
// UIImage+UIImageExtension.h | |
// | |
#import <Foundation/Foundation.h> | |
@interface UIImage (UIImageExtension) | |
// Resample to create another image: aspect ratio is not preserved (not yet) | |
// | |
- (UIImage *)resample:(CGSize)newSize; | |
@end | |
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
// UIImage+UIImageExtension.m | |
// | |
#import "UIImage+UIImageExtension.h" | |
@implementation UIImage (UIImageExtension) | |
- (UIImage *)resample:(CGSize)newSize | |
{ | |
UIGraphicsBeginImageContext(newSize); | |
[self drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)]; | |
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return newImage; | |
} | |
@end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment