Created
August 5, 2015 13:02
-
-
Save DrustZ/147001e75251cb6d7d4b to your computer and use it in GitHub Desktop.
IOS function - resize a UIimage(in C style) refer to http://stackoverflow.com/questions/3177579/displaying-images-in-fix-size
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* resizeImageToSize(UIImage* image, CGSize size) | |
{ | |
UIGraphicsBeginImageContext(size); | |
CGContextRef ctx = UIGraphicsGetCurrentContext(); | |
//Account for flipped coordspace | |
CGContextTranslateCTM(ctx, 0.0, size.height); | |
CGContextScaleCTM(ctx, 1.0, -1.0); | |
CGContextDrawImage(ctx,CGRectMake(0.0f, 0.0f, size.width, size.height), image.CGImage); | |
UIImage* scaled = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
return scaled; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment