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 ...
随机推荐
- Fiddler HTTPS抓包
现在很多带有比较重要信息的接口都使用了安全性更高的HTTPS,而Fiddler默认是抓取HTTP类型的接口,要想查看HTTPS类型接口就需要安装fiddler证书. fiddler安装教程可参考: ...
- 数据序列化导读(1)[JSON]
所谓数据序列化(Data Serialization), 就是将某个对象的状态信息转换为可以存储或传输的形式的过程. 那么,为什么要进行序列化? 首先,为了方便数据存储: 其次,为了方便数据传递. 在 ...
- mysql空间扩展 VS PostGIS
http://www.cnblogs.com/LBSer/p/3629149.html 功能 Mysql spatial extension PostGIS 空间索引 仅MyISAM支持R树索引,I ...
- 笔记四:python乱码深度剖析二
一:学习内容 获取更改系统编码 判断字符的编码类型 文件存储和读取的编码 二:获取更改系统编码 1. 获取系统编码 import sys print sys.getdefaultencoding() ...
- Mongodb同步数据到hive(二)
Mongodb同步数据到hive(二) 1. 概述 上一篇文章主要介绍了mongodb-based,通过直连mongodb的方式进行数据映射来进行数据查询,但是那种方式会对线上的 ...
- UIKit 框架之Bar、Controller
UIKit框架中有各种Bar,UITabBar.UINavigationBar.UIToolbar.Bar对应的就有一些Item,tabBarItem.navigationItem.toolbarIt ...
- Linux 命令 "cp" 代码实现简介
本blog主要是模仿Linux的cp命令的功能,未实现参数,只是基础功能部分. 本文的主要目的在于练习 文件流 和 目录流 中的函数的使用. 主要功能包括两种: 源文件属性为文件,拷贝到其它文件(内容 ...
- 求两个Linux文本文件的交集、差集、并集
一.交集 sort a.txt b.txt | uniq -d 二.并集 sort a.txt b.txt | uniq 三.差集 a.txt-b.txt: sort a.txt b.txt b.tx ...
- rabbitmq不同模式的交换机使用
交换机的功能主要是接收消息并且转发到绑定的队列,交换机不存储消息,在启用ack模式后,交换机找不到队列会返回错误.交换机有四种类型:Direct, topic, Headers and Fanout( ...
- WPF 从文件加载字体
本文告诉大家从文件加载字体.在wpf 使用 fontfamily 显示指定的 ttf 显示字体 假如有字体在 C:\Projects\MyProj\free3of9.ttf ,可以使用 Private ...