iOS8 CIGlassDistortion滤镜的使用

此为CoreImage滤镜的使用

素材

效果

混合用图片

源码:

//
// ViewController.m
// CIGlass
//
// Created by XianMingYou on 15/3/15.
// Copyright (c) 2015年 XianMingYou. All rights reserved.
// #import "ViewController.h" @interface ViewController ()
@property (nonatomic, strong) UIImage *orgImage;
@end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad]; // 设置背景色
self.view.backgroundColor = [UIColor blackColor]; self.orgImage = [UIImage imageNamed:@"bg.png"]; // 数据源 + 设置
CIImage *ciImage = [[CIImage alloc] initWithImage:self.orgImage];
NSDictionary *params = @{
kCIInputImageKey: ciImage,
}; // 初始化滤镜
CIFilter *filter = [CIFilter filterWithName:@"CIGlassDistortion"
withInputParameters:params];
[filter setDefaults]; // 输入变形参数
if ([filter respondsToSelector:NSSelectorFromString(@"inputTexture")]) {
CIImage *ciTextureImage = [[CIImage alloc] initWithImage:[UIImage imageNamed:@"grassdistortion.png"]];
[filter setValue:ciTextureImage forKey:@"inputTexture"];
} // 创建上下文 + 输出图片
CIContext *context = [CIContext contextWithOptions:nil];
CIImage *outputImage = [filter outputImage]; // 获取图片
CGImageRef cgImage = [context createCGImage:outputImage
fromRect:[outputImage extent]]; // 获取图片
UIImage *image = [UIImage imageWithCGImage:cgImage]; // 释放资源
CGImageRelease(cgImage); // 加载图片
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.frame = self.view.bounds;
[self.view addSubview:imageView];
} @end

需要注意的细节:

iOS8 CIGlassDistortion滤镜的使用的更多相关文章

  1. iOS8 Core Image In Swift:视频实时滤镜

    iOS8 Core Image In Swift:自己主动改善图像以及内置滤镜的使用 iOS8 Core Image In Swift:更复杂的滤镜 iOS8 Core Image In Swift: ...

  2. iOS8 Core Image In Swift:更复杂的滤镜

    iOS8 Core Image In Swift:自动改善图像以及内置滤镜的使用 iOS8 Core Image In Swift:更复杂的滤镜 iOS8 Core Image In Swift:人脸 ...

  3. iOS8 Core Image In Swift:自动改善图像以及内置滤镜的使用

    iOS8 Core Image In Swift:自动改善图像以及内置滤镜的使用 iOS8 Core Image In Swift:更复杂的滤镜 iOS8 Core Image In Swift:人脸 ...

  4. iOS开发 滤镜的使用

    iOS开发之滤镜的使用技巧(CoreImage)   一.滤镜的内容和效果是比较多并且复杂的 ,学习滤镜需要技巧 如下: 两个输出语句解决滤镜的属性选择问题: 1.查询效果分类中包含什么效果按住com ...

  5. iOS开发之滤镜的使用技巧(CoreImage)

    一.滤镜的内容和效果是比较多并且复杂的 ,学习滤镜需要技巧 如下: 两个输出语句解决滤镜的属性选择问题: 1.查询效果分类中包含什么效果按住command 点击CIFilter 进入接口文件 找到第1 ...

  6. ios8及以前的特性

    目前最新系统为ios8.以下为历代系统的回顾: iOS 1 关键词:iPhone的诞生 也许放在现在来看,当时的情景很难想象.当第一代iPhone正式发布时,在某些功能和方面其实是要远远落后于当时的竞 ...

  7. iOS8 Core Image In Swift:人脸检测以及马赛克

    iOS8 Core Image In Swift:自动改善图像以及内置滤镜的使用 iOS8 Core Image In Swift:更复杂的滤镜 iOS8 Core Image In Swift:人脸 ...

  8. CoreImage 中的模糊滤镜

    1.CoreImage 中的模糊滤镜 1.1CoreImage是苹果用来简化图片处理的框架 1.2CIImage.CIFilter与CIContext三者联系 1.3CIGaussianBlur中可能 ...

  9. iOS8新特性(1)——UIAlertController

    一.iOS8介绍 iOS8 新特性,主要是UI上进行了统一 1.UIAlertController 2.UIPresentaionController:管理所有通过modal出来的控制器(看笔记) 3 ...

随机推荐

  1. maven私服配置

    1.maven私服setting.xml的配置 <?xml version="1.0" encoding="UTF-8"?> <setting ...

  2. jvm间歇性崩溃分析

    http://www.cnblogs.com/LBSer/p/4417148.html 1 问题描述 某服务有两台机器,每隔几天会报警load高,一开始看监控发现gc时间抖动很大,以为是发生了full ...

  3. 设计模式学习--面向对象的5条设计原则之依赖倒置原则--DIP

    一.DIP简介(DIP--Dependency Inversion Principle): 1.高层模块不应该依赖于低层模块,二者都应该依赖于抽象.2.抽象不应该依赖于细节,细节应该依赖于抽象.   ...

  4. redis on windows

    https://github.com/MSOpenTech/redis 下载解压 在/bin/release里还有一个压缩包,这个压缩包是生成好的 解压 运行redis-server 乌拉乌拉说了一堆 ...

  5. CSS3文本属性

    text-shadow(文本阴影) <h1>我有文字阴影</h1> h1{ color:#ffff00; text-shadow:1px 2px 2px #000000; } ...

  6. Spring boot --- Spring Oauth(一)

       文章部分图片来自参考资料,这篇文章主要讲 spring security  oauth 概述 上一篇我们学习了 SS 中重要的工作原理和几个大概的认证和授权过程.而 spring securit ...

  7. js new Date() 获取时间

    转载:https://www.cnblogs.com/xiaoshujiang/p/5518462.html 一,Date付给初始值,并构造new Date() Date 对象用于处理日期和时间.创建 ...

  8. Java基础教程(10)--类

    一.声明类   你已经见过了以如下方式定义的类: class MyClass { // field, constructor, and method declarations }   上面是声明类的最 ...

  9. 微服务与DevOps关系

    随着IT技术的不断发展,从传统的IT建设模型逐步向新型IT建设模型过渡,建设模式的改变,必然影响应用系统的全生命周期.应用系统的建设经过单体应用.SOA应用.逐步走向微服务应用,至于何为单体应用.SO ...

  10. 使用EXCEL 完成分组统计

    表testTable 有以下数据,要统计各个电视剧的数量.在开发人员看来,使用sql操作完成select name,count(*) from TestTable where 1=1 group by ...