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 ...
随机推荐
- mysql保留两位小数
--这个是保留整数位 SELECT CONVERT(4545.1366,DECIMAL); --这个是保留两位小数 ,)); --这个是截取两位,并不会四舍五入保留两位小数 );
- JS的作用域和声明提前
首先介绍下Javascript的函数作用域的概念,然后了解下什么是作用域和声明提前,最后通过一个例子剖析Javascript的作用域链. 1.变量的作用域 稍微有些编程背景的都知道,变量的作用域分为两 ...
- 前端富文本编辑器 vue-html5-editor
1..项目创建与初始化 在安装好脚手架的依赖后,要执行 npm install vue-html5-editor -S 来安装这个富文本插件,由于这个富文本插件的图标是依赖font-awesome.c ...
- [PY3]——面向对象编程(1)
类的对象 有三种对象 可以做什么操作 包括什么属性 类对象 属性引用.实例化 函数方法.内置的属性.类变量 实例对象 属性引用 函数方法.类变量.实例变量 方法对象 1. 类对象.实例对象.方法对象 ...
- Jquery Easy UI初步学习(二)datagrid的使用
第一篇学的是做一个管理的外框,接着就是数据datagrid绑定了,这里我用asp.net mvc3来做的,主要就是熟悉属性.方法. 打开easyui的demo 就可以看到如下一段代码: 和上篇一样cl ...
- 《码出高效 Java开发手册》第六章 数据结构与集合
码云: https://gitee.com/forxiaoming/JavaBaseCode/blob/master/EasyCoding/src/collection/index.md 6.1 数据 ...
- Qt架构图及模块分析介绍
1.Qt框架图: 2.Qt模块组成 通用软件开发模块 QtCore 核心非图形接口类,为其他模块所调用 QtGui GUI(图形用户接口)功能模块 QtMultimedia 提供低级多媒体功能支持的类 ...
- 【 js 片段 】移动端适配简易步骤
手机端全部适配简易步骤,不确保没有bug. 1.HTML 的 head 部分中加入如下代码: <meta name="viewport" content="widt ...
- Unity3D 场景切换加载进度条实现
需要三个场景,场景A,场景B,场景C: 场景A:一个按钮,点击加载场景B: 场景B:从A切换到C过度场景,加载进度条: 场景C:目标场景: 创建OnProgress.cs脚本: using Syste ...
- Getting Started with Erlang
Getting Started with Erlang Erlang is a great language that lets you build highly concurrent applica ...