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 ...
随机推荐
- NMS—卷积神经网络
1-传统的NMS NMS,非极大值抑制,在很多计算机视觉问题中有着重要应用,尤其是目标检测领域. 以人脸检测为例,通常的流程为3步: (1)通过滑动窗口或者其它的object proposals方法产 ...
- CART树
算法概述 CART(Classification And Regression Tree)算法是一种决策树分类方法. 它采用一种二分递归分割的技术,分割方法采用基于最小距离的基尼指数估计函数,将当前的 ...
- java-双大括号实例初始化的反模式
今天在看springboot的batch时, 看到这样一段代码, 直接把我看懵了, 于是找了一下, 发现这 两个大括号 {{ 叫实例初始化器 FlatFileItemReader<Person ...
- mysql空间扩展 VS PostGIS
http://www.cnblogs.com/LBSer/p/3629149.html 功能 Mysql spatial extension PostGIS 空间索引 仅MyISAM支持R树索引,I ...
- java 序列化与解序列化
小例 import java.io.*; public class Box implements Serializable{ private int width; private int height ...
- JDK动态代理[2]----JDK动态代理的底层实现之Proxy源码分析
在上一篇里为大家简单介绍了什么是代理模式?为什么要使用代理模式?并用例子演示了一下静态代理和动态代理的实现,分析了静态代理和动态代理各自的优缺点.在这一篇中笔者打算深入源码为大家剖析JDK动态代理实现 ...
- c#与IronPython Clojure-clr的调用
一,python 安装ironpython http://ironpython.net/ 新建控制台程序,引入 IronPython,Microsoft.Scripting 新建xxx.py文件 va ...
- 如何在 Ubuntu 14.04 上安装 Elasticsearch,Logstash 和 Kibana
介绍 在本教程中,我们将去的 Elasticsearch 麋鹿堆栈安装 Ubuntu 14.04 — — 那就是,Elasticsearch 5.2.x,Logstash 2.2.x 和 Kibana ...
- [javaSE] 位运算符(&|^)
位运算是直接对二进制进行计算 左移 << 右移 >> 先把整数换成四个8bit 0000-0000 0000-0000 0000-0000 0000-0000 这个二进制左右移 ...
- Python import搜索的路径顺序
在程序中导入时,如下顺序 1.Python 标准库模块2.Python 第三方模块3.应用程序自定义模块 import的搜索顺序: 首先判断这个module是不是built-in即内建模块,如果是 ...