Created
September 19, 2017 23:20
-
-
Save puelocesar/d3f0bbed74d97ec94de212e17e7adba1 to your computer and use it in GitHub Desktop.
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
UIGraphicsBeginImageContextWithOptions(self.size, NO, [[UIScreen mainScreen] scale]); | |
CGContextRef outputContext = UIGraphicsGetCurrentContext(); | |
CGContextScaleCTM(outputContext, 1.0, -1.0); | |
CGContextTranslateCTM(outputContext, 0, -self.size.height); | |
// draw base image | |
CGContextDrawImage(outputContext, imageRect, self.CGImage); | |
// draw effect image | |
if (hasBlur) { | |
CGContextSaveGState(outputContext); | |
if (maskImage) { | |
CGContextClipToMask(outputContext, imageRect, maskImage.CGImage); | |
} | |
CGContextDrawImage(outputContext, imageRect, effectImage.CGImage); | |
CGContextRestoreGState(outputContext); | |
} | |
// output image is ready | |
UIImage *outputImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment