-
-
Save ZachOrr/7c338f899dc40d29db8a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// Needs CoreImage.framework | |
- (UIImage *)blurredImageWithImage:(UIImage *)sourceImage{ | |
// Create our blurred image | |
CIContext *context = [CIContext contextWithOptions:nil]; | |
CIImage *inputImage = [CIImage imageWithCGImage:sourceImage.CGImage]; | |
// Setting up Gaussian Blur | |
CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"]; | |
[filter setValue:inputImage forKey:kCIInputImageKey]; | |
[filter setValue:[NSNumber numberWithFloat:15.0f] forKey:@"inputRadius"]; | |
CIImage *result = [filter valueForKey:kCIOutputImageKey]; | |
/* CIGaussianBlur has a tendency to shrink the image a little, this ensures it matches | |
* up exactly to the bounds of our original image */ | |
CGImageRef cgImage = [context createCGImage:result fromRect:[inputImage extent]]; | |
UIImage *retVal = [UIImage imageWithCGImage:cgImage]; | |
CGImageRelease(cgImage); | |
return retVal; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment