zoukankan      html  css  js  c++  java
  • CIFilter (模糊图片)

     //使用模糊图片

    #import "ViewController.h"

    @interface ViewController ()

    @end

    @implementation ViewController

    - (void)viewDidLoad {

        [super viewDidLoad];

        

        UIImage *image = [UIImage imageNamed:@"qiaodan"];

        

        //coreImage

        CIImage *ciImage = [[CIImage alloc] initWithImage:image];

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

        //设置模糊程度

        [blurFilter setValue:@(2) forKey:@"inputRadius"];

        //查询滤镜设置参数的信息

        NSLog(@"%@",[blurFilter attributes]);

        //将图片输入到滤镜中

        [blurFilter setValue:ciImage forKey:kCIInputImageKey];

        //将处理好的图片输出

        CIImage *outCiImage = [blurFilter valueForKey:kCIOutputImageKey];

        

        //CIContext

        CIContext *context = [CIContext contextWithOptions:nil];

        //获取CGImage句柄

        CGImageRef outCGImage = [context createCGImage:outCiImage fromRect:[outCiImage extent]];

        //最终获取到图片

        UIImage *blurImage = [UIImage imageWithCGImage:outCGImage];

        //释放CGImage句柄

        CGImageRelease(outCGImage);

            

        //图片初始化

        UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 640/2.f, 640/2.f)];

        imageView.image = blurImage;

        imageView.center = self.view.center;

        [self.view addSubview:imageView];   

        

        // Do any additional setup after loading the view, typically from a nib.

    }

    - (void)didReceiveMemoryWarning {

        [super didReceiveMemoryWarning];

        // Dispose of any resources that can be recreated.

    }

    @end

  • 相关阅读:
    Redis-Sp:Redis主要功能
    Redis-Sp:Redis介绍
    阿里云-Redis-Help-连接实例-Redis客户端连接:C#客户端StackExchange.Redis
    Samba通过ad域进行认证并限制空间大小《转载》
    SQL函数简述
    SELECT--UNION,UNION ALL,MINUS, INTERSECT,EXISTS
    oracle数据库常用查询一
    oracle以web方式登录EM、ISQLPlus
    关于sys、system、sysman等在EM中登录的问题
    top 命令SQLServer-sybase-oracle
  • 原文地址:https://www.cnblogs.com/jiurong001/p/5205359.html
Copyright © 2011-2022 走看看