zoukankan      html  css  js  c++  java
  • CoreImage的模糊滤镜

        //1.原始图片
        UIImage * image = [UIImage imageNamed:@"1.jpg"];
        
        /****************core image******************/
        //a.图片
        CIImage * ciImage = [[CIImage alloc] initWithImage:image];
        //b.滤镜
        CIFilter * ciFilter = [CIFilter filterWithName:@"CIGaussianBlur"];
        NSLog(@"%@",[ciFilter attributes]);
        //设置滤镜的模糊程度,默认是10
        [ciFilter setValue:@(10) forKey:@"inputRadius"];
        //将图片放到滤镜中
        [ciFilter setValue:ciImage forKey:kCIInputImageKey];
        //输出图片
        CIImage * outImage = [ciFilter valueForKey:kCIOutputImageKey];
        //c.获取CGImage的句柄
        CIContext * context = [CIContext contextWithOptions:nil];
        CGImageRef outCGImage = [context createCGImage:outImage fromRect:[outImage extent]];
        UIImage * blurImage = [UIImage imageWithCGImage:outCGImage];
        CGImageRelease(outCGImage);
        
        /********************************************/
        //2.初始化imageView
        UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 20, 320, 200)];
        imageView.image = blurImage;
        [self.view addSubview:imageView];
  • 相关阅读:
    HDU1050
    POJ3528移石头
    CodeForces230A
    lca学习题
    rmq的st算法模板题 nyoj 119
    rmq问题和lca可以相互转化
    rmq算法,利用倍增思想
    poj 1274 基础二分最大匹配
    hdu 1520 树形dp入门题
    poj 1466 最大独立集
  • 原文地址:https://www.cnblogs.com/benbenzhu/p/4707915.html
Copyright © 2011-2022 走看看