IOS 使用CoreImage实现图片模糊效果
2015-05-27 18:55
627 查看
//原始图片 UIImage*image = [UIImage imageNamed:@"sourceImage.jpg"]; /*.....coreImage部分....*/ //CIImage(图片输入源类似于UIImage) CIImage *ciImage = [[CIImage alloc]initWithImage:image]; //CIFilter(滤镜)CIGaussianBlue是一款滤镜名字 CIFilter *blurFilter = [CIFilter filterWithName:@"CIGaussianBlur"]; //将图片输入到滤镜中 [blurFilter setValue:ciImage forKey:kCIInputImageKey]; //设置模糊长度(不模糊为0,模糊最大为100) [blurFilter setValue:@(0) forKey:@"inputRadius"]; //将处理好的图片输出 CIImage *outCiImage = [blurFilter valueForKey:kCIOutputImageKey]; //输入该滤镜中所有可以设置的参数以及相关的信息 NSLog(@"%@",[blurFilter attributes]); //CIContext(CIImage的操作句柄)nil表示默认有CPU渲染图片(如果让GPU渲染提高效率,则应设置contextWithOptions的字典数据) CIContext *context = [CIContext contextWithOptions:nil]; //获取CGImage句柄 CGImageRef outCGImage = [context createCGImage:outCiImage fromRect:[outCiImage extent]]; //最终获取到图片 UIImage *blurImage = [UIImage imageWithCGImage:outCGImage]; //释放CGImage句柄 CGImageRelease(outCGImage); /*.........................*/ //初始化ImageView UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(10,10,300,300)]; // imageView.backgroundColor = [UIColor redColor]; imageView.image = blurImage; imageView.center = self.view.center; [self.view addSubview:imageView];
相关文章推荐
- iOS开发之使用UIimage+ImageEffects实现图片模糊效果
- ios-day18-10(使用CAKeyframeAnimation实现图片的抖动效果)
- 使用GPUImage实现iOS 7的模糊效果
- 使用GPUImage实现iOS 7的模糊效果
- 使用viewpager嵌套实现上下左右滑动切换图片(IOS双向滚动翻页效果相同)
- iOS简单实现图片模糊渐变效果
- iOS简单实现图片模糊渐变效果
- 使用GPUImage实现iOS 7的模糊效果
- iOS项目开发实战——使用CALayer实现图片的淡入淡出效果
- iOS毛玻璃效果的实现及图片模糊效果的三种方法
- 使用HTML5技术实现的全屏图片模糊效果
- 使用viewpager嵌套实现上下左右滑动切换图片(IOS双向滚动翻页效果相同)
- IOS_使用coreImage实现图片中的人脸识别
- [IOS 开发] 使用UIVisualEffectView实现模糊效果
- iOS开发之实现毛玻璃效果及图片模糊效果
- IOS进阶之Accelebrate.framework 实现图片模糊效果
- IOS实现图片的模糊效果
- iOS 图片模糊效果三种实现方式
- iOS 毛玻璃效果和高斯图片模糊实现
- iOS程序开发之使用PlaceholderImageView实现优雅的图片加载效果