zoukankan      html  css  js  c++  java
  • 滤镜链

    滤镜链:即用一个滤镜的output image 当作 另一个滤镜的 input:

     1 CIContext *context = [CIContext contextWithOptions:nil];
     2     CIImage *image = [CIImage imageWithCGImage:[UIImage imageNamed:@"aa11.jpg"].CGImage];
     3     
     4    
     5     
     6     CIFilter *filter = [CIFilter filterWithName:@"CISepiaTone"];
     7     [filter setValue:image forKey:kCIInputImageKey];
     8     [filter setValue:@0.8f forKey:kCIInputIntensityKey];
     9     CIImage *result = [filter valueForKey:kCIOutputImageKey];
    10   
    11     CIFilter *gloom = [CIFilter filterWithName:@"CIGloom"];
    12     [gloom setValue:result forKey:kCIInputImageKey];
    13     [gloom setValue:@15.0f forKey:kCIInputRadiusKey];
    14     [gloom setValue:@0.55f forKey:kCIInputIntensityKey];
    15     result = [gloom valueForKey:kCIOutputImageKey];
    16     
    17     CIFilter *bumpDistortion = [CIFilter filterWithName:@"CIBumpDistortion"];
    18     [bumpDistortion setValue:result forKey:kCIInputImageKey];
    19     [bumpDistortion setValue:[CIVector vectorWithX:300 Y:50] forKey:kCIInputCenterKey];
    20     [bumpDistortion setValue:@100.0f forKey:kCIInputRadiusKey];
    21     [bumpDistortion setValue:@3.0f forKey:kCIInputScaleKey];
    22     result = [bumpDistortion valueForKey:kCIOutputImageKey];
    23   
    24     
    25     CGRect extent = [result extent];
    26     CGImageRef cgImage = [context createCGImage:result fromRect:extent];
    27     
    28     UIImage *resultImg = [UIImage imageWithCGImage:cgImage];
    29     
    30     UIImageView *imgView = [[UIImageView alloc]initWithFrame:self.view.bounds];
    31     [imgView setImage:resultImg];
    32     [self.view addSubview:imgView];
  • 相关阅读:
    IntelliJ IDEA 编译方式介绍
    IntelliJ IDEA 缓存和索引介绍和清理方法
    无线鼠标没反应了
    L1-039 古风排版 (20 分)
    L1-043 阅览室 (20 分)
    数学思想
    输入
    2018年湘潭大学程序设计竞赛 E 吃货
    问题 1936: [蓝桥杯][算法提高VIP]最大乘积
    指针 链表
  • 原文地址:https://www.cnblogs.com/grq186/p/4602535.html
Copyright © 2011-2022 走看看