您的位置:首页 > 产品设计 > UI/UE

GPUImage(1) 高斯模糊 亮度调整

2017-01-15 00:00 639 查看
摘要: 第1篇 直接开撸 先跑起来再说

贡献者:赵大财
博客:https://my.oschina.net/zhaodacai GitHub:https://github.com/dacaizhao
邮箱: dacai_zhao@163.com QQ:327532817
=============================

//高斯模糊
/*
let blurFilter = GPUImageGaussianBlurFilter()
blurFilter.blurRadiusInPixels = 10
var img = UIImage(named: "mark")
img = blurFilter.image(byFilteringImage: img)
let imgView = UIImageView()
imgView.frame = CGRect(x: 0, y: 200, width: 200, height: 200)
imgView.image = img
imgView.backgroundColor = UIColor.red
view.addSubview(imgView)
*/

//调整亮度
var img = UIImage(named: "mark")
//创建一个高亮度的滤镜
let passthroughFilter = GPUImageBrightnessFilter()
passthroughFilter.brightness = -0.5
passthroughFilter.forceProcessing(at: img!.size)
passthroughFilter.useNextFrameForImageCapture()
//获取数据源
let stillImageSource = GPUImagePicture(image: img)
stillImageSource?.addTarget(passthroughFilter)
stillImageSource?.processImage()
img = passthroughFilter.imageFromCurrentFramebuffer()
let imgView = UIImageView()
imgView.image = img
imgView.frame = CGRect(x: 0, y: 200, width: 200, height: 200)
view.addSubview(imgView)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息