CoreImage 中的模糊滤镜
2015-08-13 17:30
381 查看
/* * * * * *原始图片 * * * * * */
UIImage *img = [UIImage
imageNamed:@"1.jpg"];
/* * * * * *coreImage * * * * * */
CIImage *ciima = [[CIImage
alloc] initWithImage:img];
/* * * * * *滤镜处理类型 * * * * * */
CIFilter *cifilter = [CIFilter
filterWithName:@"CIGaussianBlur"];
[cifilter
setValue:ciima forKey:kCIInputImageKey];
/* * * * * *设置模糊程度 0最小 * * * * * */
[cifilter
setValue:@3
forKey:@"inputRadius"];
/* * * * * *用来查询设置可以用到的参数 * * * * * */
NSLog(@"%@",cifilter.attributes);
/* * * * * *输出的图片 * * * * * */
CIImage *outIma = [cifilter
valueForKey:kCIOutputImageKey] ;
/* * * * * *处理方式,是CPU设置为nil,默认是CPU * * * * * */
CIContext * context = [CIContext
contextWithOptions:nil];
/* * * * * *输出的处理完的图片 * * * * * */
CGImageRef imgRef = [context
createCGImage:outIma fromRect:[outIma
extent]];
/* * * * * *转化 * * * * * */
img = [UIImage
imageWithCIImage:outIma];
/* * * * * *释放内存 * * * * * */
CGImageRelease(imgRef);
UIImageView *imgV = [[UIImageView
alloc] initWithFrame:CGRectMake(0,
0, 375/2,
500/2)];
imgV.image = img ;
[self.view
addSubview:imgV];
UIImage *img = [UIImage
imageNamed:@"1.jpg"];
/* * * * * *coreImage * * * * * */
CIImage *ciima = [[CIImage
alloc] initWithImage:img];
/* * * * * *滤镜处理类型 * * * * * */
CIFilter *cifilter = [CIFilter
filterWithName:@"CIGaussianBlur"];
[cifilter
setValue:ciima forKey:kCIInputImageKey];
/* * * * * *设置模糊程度 0最小 * * * * * */
[cifilter
setValue:@3
forKey:@"inputRadius"];
/* * * * * *用来查询设置可以用到的参数 * * * * * */
NSLog(@"%@",cifilter.attributes);
/* * * * * *输出的图片 * * * * * */
CIImage *outIma = [cifilter
valueForKey:kCIOutputImageKey] ;
/* * * * * *处理方式,是CPU设置为nil,默认是CPU * * * * * */
CIContext * context = [CIContext
contextWithOptions:nil];
/* * * * * *输出的处理完的图片 * * * * * */
CGImageRef imgRef = [context
createCGImage:outIma fromRect:[outIma
extent]];
/* * * * * *转化 * * * * * */
img = [UIImage
imageWithCIImage:outIma];
/* * * * * *释放内存 * * * * * */
CGImageRelease(imgRef);
UIImageView *imgV = [[UIImageView
alloc] initWithFrame:CGRectMake(0,
0, 375/2,
500/2)];
imgV.image = img ;
[self.view
addSubview:imgV];
相关文章推荐
- [TroubleShooting] The remote copy of database xx has not been rolled forward to a point in time
- 《道德经》全文注释
- LeetCode OJ平台Sort Colors讨论主题算法
- 学习JAVA框架的心得体会
- kubernetes API Server 权限管理实践
- Android和服务器通信
- java输出获取英文字母
- 2015/8/13/客户端服务器数据库综合
- iOS设计模式汇总
- 程序员日记我们需要有条理的生活
- 【iOS官方文档翻译】UICollectionView与UICollectionViewFlowLayout
- iphone5 ios7.1 上下有黑边 解决方案
- LeetCode解题报告--Palindrome Number
- UIAlertView提示框自动消失
- UITabBarController — 标签视图控制器
- 优化Apache,提高并发
- js判断访问设备是手机端还是PC端
- 将对象里属性值相同的元素放到同一容器里
- ZOJ 1372 Networking 最小生成树 Kruscal && Prim
- HDOJ-2835(最佳置换算法)