iOS8 CIGlassDistortion滤镜的使用
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滤镜的使用的更多相关文章
- iOS8 Core Image In Swift:视频实时滤镜
iOS8 Core Image In Swift:自己主动改善图像以及内置滤镜的使用 iOS8 Core Image In Swift:更复杂的滤镜 iOS8 Core Image In Swift: ...
- iOS8 Core Image In Swift:更复杂的滤镜
iOS8 Core Image In Swift:自动改善图像以及内置滤镜的使用 iOS8 Core Image In Swift:更复杂的滤镜 iOS8 Core Image In Swift:人脸 ...
- iOS8 Core Image In Swift:自动改善图像以及内置滤镜的使用
iOS8 Core Image In Swift:自动改善图像以及内置滤镜的使用 iOS8 Core Image In Swift:更复杂的滤镜 iOS8 Core Image In Swift:人脸 ...
- iOS开发 滤镜的使用
iOS开发之滤镜的使用技巧(CoreImage) 一.滤镜的内容和效果是比较多并且复杂的 ,学习滤镜需要技巧 如下: 两个输出语句解决滤镜的属性选择问题: 1.查询效果分类中包含什么效果按住com ...
- iOS开发之滤镜的使用技巧(CoreImage)
一.滤镜的内容和效果是比较多并且复杂的 ,学习滤镜需要技巧 如下: 两个输出语句解决滤镜的属性选择问题: 1.查询效果分类中包含什么效果按住command 点击CIFilter 进入接口文件 找到第1 ...
- ios8及以前的特性
目前最新系统为ios8.以下为历代系统的回顾: iOS 1 关键词:iPhone的诞生 也许放在现在来看,当时的情景很难想象.当第一代iPhone正式发布时,在某些功能和方面其实是要远远落后于当时的竞 ...
- iOS8 Core Image In Swift:人脸检测以及马赛克
iOS8 Core Image In Swift:自动改善图像以及内置滤镜的使用 iOS8 Core Image In Swift:更复杂的滤镜 iOS8 Core Image In Swift:人脸 ...
- CoreImage 中的模糊滤镜
1.CoreImage 中的模糊滤镜 1.1CoreImage是苹果用来简化图片处理的框架 1.2CIImage.CIFilter与CIContext三者联系 1.3CIGaussianBlur中可能 ...
- iOS8新特性(1)——UIAlertController
一.iOS8介绍 iOS8 新特性,主要是UI上进行了统一 1.UIAlertController 2.UIPresentaionController:管理所有通过modal出来的控制器(看笔记) 3 ...
随机推荐
- go语言接受者的选取
何时使用值类型 1.如果接受者是一个 map,func 或者 chan,使用值类型(因为它们本身就是引用类型).2.如果接受者是一个 slice,并且方法不执行 reslice 操作,也不重新分配内存 ...
- 机器学习中的范数规则化之L0、L1与L2范数
今天看到一篇讲机器学习范数规则化的文章,讲得特别好,记录学习一下.原博客地址(http://blog.csdn.net/zouxy09). 今天我们聊聊机器学习中出现的非常频繁的问题:过拟合与规则化. ...
- Git的gitattributes文件详解
转自:Git的gitattributes文件详解 Git的gitattributes文件是一个文本文件,文件中的一行定义一个路径的若干个属性. 1. gitattributes文件以行为单位设置一个路 ...
- java开学考试感想及代码
上周四我们的第一节java课,王老师给我们进行啦开学考试,这也是上学期放假之前给我们约定好的 但是情况显然没有我想的那么好,其实我觉得这个atm系统比上届学生信息管理系统难的多,上届的话毕竟有小学期的 ...
- C#基础知识回顾--BackgroundWorker介绍
简介 BackgroundWorker是.net里用来执行多线程任务的控件,它允许编程者在一个单独的线程上执行一些操作.耗时的操作(如下载和数据库事务)在长时间运行时可能会导致用户界面 (UI) 始终 ...
- 给font awesome中加入自定义图片
工具:http://icomoon.io 在线工具 http://www.inkscape.org/en/download/windows/ 下载安装 参考教程 http://birchenough. ...
- IIS负载均衡-Application Request Route详解第一篇: ARR介绍
IIS负载均衡-Application Request Route详解第一篇: ARR介绍 说到负载均衡,相信大家已经不再陌生了,本系列主要介绍在IIS中可以采用的负载均衡的软件:微软的Applica ...
- Java中响应结果工具类,可自定义响应码,内容,响应消息
创建响应状态码和说明枚举类 /** * 响应状态码和说明 */public enum CodeEnum { SUCCESS(0, "成功!"), FAIL(1, &qu ...
- 理解clear:both属性(转)
理解clear:both属性 在前端开发布局中,经常会被float这个属性搞晕,尤其是新手 CSS 的 Float(浮动),会使元素向左或向右移动,其周围的元素也会重新排列.Float(浮动),往往是 ...
- EF CodeFirst 初识
随着EntityFramework的发展,原先的三种方式,{Code First ,Model First,Database First } CodeFirst基本摆脱了另外两种方式 成为了 最受欢 ...