添加高斯滤镜效果 (图片模糊化)

//添加滤镜

- (UIImage *)addFilter:(NSString *)sender

{

    CIContext *context = [CIContext contextWithOptions:nil];

    CIImage *image = [CIImage imageWithContentsOfURL:[NSURL URLWithString:sender]];

    CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"];

    [filter setValue:image forKey:kCIInputImageKey];

    [filter setValue:@50.0f forKey: @"inputRadius"];

    CIImage *result = [filter valueForKey:kCIOutputImageKey];

    CGImageRef outImage = [context createCGImage: result fromRect:[result extent]];

    UIImage * blurImage = [UIImage imageWithCGImage:outImage];

    return blurImage;

}

posted @ 2016-01-12 16:04  懒懒初阳  阅读(258)  评论(0编辑  收藏  举报