GPUImage

- (IBAction)slider:(UISlider*)sender {

//1.取得滑块

UISlider*slider = (UISlider*)[self.viewviewWithTag:sender.tag];

//2.取得滑块的value

CGFloat vlaue = slider.value;

//3.value值显示

self.number.text= [NSStringstringWithFormat:@"%f",vlaue];

//4.选择滑块

switch(slider.tag) {

case100:

{//            亮度

GPUImageBrightnessFilter*brightness = [[GPUImageBrightnessFilteralloc]init];//创建滤镜对象

brightness.brightness= vlaue;//设置亮度 -1.0 to 1.0 默认 0.0

[brightnessforceProcessingAtSize:self.image.size];//设置要渲染的区域

[brightnessuseNextFrameForImageCapture];//捕获图片效果

[selffilterWithObject:brightness];//渲染图片并显示

}

break;

case101:

{//            曝光度

GPUImageExposureFilter*exposure = [[GPUImageExposureFilteralloc]init];//创建滤镜对象

exposure.exposure= vlaue;//设置亮度 -10 to 10 默认 0

[exposureforceProcessingAtSize:self.image.size];//设置要渲染的区域

[exposureuseNextFrameForImageCapture];//捕获图片效果

[selffilterWithObject:exposure];//渲染图片并显示

}

break;

case102:

{//            对比度

GPUImageContrastFilter*contrast = [[GPUImageContrastFilteralloc]init];//创建滤镜对象

contrast.contrast= vlaue;//设置对比度 0 to 4 默认 1

[contrastforceProcessingAtSize:self.image.size];//设置要渲染的区域

[contrastuseNextFrameForImageCapture];//捕获图片效果

[selffilterWithObject:contrast];//渲染图片并显示

}

break;

case103:

{//            饱和度

GPUImageSaturationFilter*saturation = [[GPUImageSaturationFilteralloc]init];//创建滤镜对象

saturation.saturation= vlaue;//设置饱和度 0 to 2 默认 1

[saturationforceProcessingAtSize:self.image.size];//设置要渲染的区域

[saturationuseNextFrameForImageCapture];//捕获图片效果

[selffilterWithObject:saturation];//渲染图片并显示

}

break;

case104:

{//            锐化

GPUImageSharpenFilter*sharpen = [[GPUImageSharpenFilteralloc]init];//创建滤镜对象

sharpen.sharpness= vlaue;//设置饱和度 -4 to 4 默认 0

[sharpenforceProcessingAtSize:self.image.size];//设置要渲染的区域

[sharpenuseNextFrameForImageCapture];//捕获图片效果

[selffilterWithObject:sharpen];//渲染图片并显示

}

break;

case105:

{//            形变

GPUImageTransformFilter*transform = [[GPUImageTransformFilteralloc]init];//创建滤镜对象

transform.transform3D= CATransform3DMakeScale(vlaue, vlaue, vlaue);//设置属性

[transformforceProcessingAtSize:self.image.size];//设置要渲染的区域

[transformuseNextFrameForImageCapture];//捕获图片效果

[selffilterWithObject:transform];//渲染图片并显示

}

break;

case106:

{//            高斯模糊

GPUImageGaussianBlurFilter*gaussianBlur = [[GPUImageGaussianBlurFilteralloc]init];//创建滤镜对象

gaussianBlur.texelSpacingMultiplier= vlaue;

[gaussianBlurforceProcessingAtSize:self.image.size];//设置要渲染的区域

[gaussianBluruseNextFrameForImageCapture];//捕获图片效果

[selffilterWithObject:gaussianBlur];//渲染图片并显示

}

break;

case107:

{//            卡通效果

GPUImageToonFilter*sketch = [[GPUImageToonFilteralloc]init];//创建滤镜对象

sketch.quantizationLevels=10;

[sketchforceProcessingAtSize:self.image.size];//设置要渲染的区域

[sketchuseNextFrameForImageCapture];//捕获图片效果

[selffilterWithObject:sketch];//渲染图片并显示

}

break;

case108:

{//            球形倒立效果

GPUImageSphereRefractionFilter*glass = [[GPUImageSphereRefractionFilteralloc]init];//创建滤镜对象

glass.radius= vlaue;//设置球 半径

[glassforceProcessingAtSize:self.image.size];//设置要渲染的区域

[glassuseNextFrameForImageCapture];//捕获图片效果

[selffilterWithObject:glass];//渲染图片并显示

}

break;

case109:

{//            怀旧效果

GPUImageSepiaFilter*sepia = [[GPUImageSepiaFilteralloc]init];//创建滤镜对象

[sepiaforceProcessingAtSize:self.image.size];//设置要渲染的区域

[sepiauseNextFrameForImageCapture];//捕获图片效果

[selffilterWithObject:sepia];//渲染图片并显示

}

break;

case110:

{//            反色效果

GPUImageColorInvertFilter*colorInvert = [[GPUImageColorInvertFilteralloc]init];//创建滤镜对象

[colorInvertforceProcessingAtSize:self.image.size];//设置要渲染的区域

[colorInvertuseNextFrameForImageCapture];//捕获图片效果

[selffilterWithObject:colorInvert];//渲染图片并显示

}

break;

case111:

{//            色彩丢失效果

GPUImageColorPackingFilter*colorPacking = [[GPUImageColorPackingFilteralloc]init];//创建滤镜对象

[colorPackingforceProcessingAtSize:self.image.size];//设置要渲染的区域

[colorPackinguseNextFrameForImageCapture];//捕获图片效果

[selffilterWithObject:colorPacking];//渲染图片并显示

}

break;

case112:

{//            晕影效果

GPUImageVignetteFilter*vigette = [[GPUImageVignetteFilteralloc]init];//创建滤镜对象

vigette.vignetteStart=0;

[vigetteforceProcessingAtSize:self.image.size];//设置要渲染的区域

[vigetteuseNextFrameForImageCapture];//捕获图片效果

[selffilterWithObject:vigette];//渲染图片并显示

}

break;

case113:

{//            交叉线效果

GPUImageCrosshatchFilter*crosshatch = [[GPUImageCrosshatchFilteralloc]init];//创建滤镜对象

crosshatch.crossHatchSpacing= vlaue;

[crosshatchforceProcessingAtSize:self.image.size];//设置要渲染的区域

[crosshatchuseNextFrameForImageCapture];//捕获图片效果

[selffilterWithObject:crosshatch];//渲染图片并显示

}

break;

case114:

{//            哈哈镜效果

GPUImageStretchDistortionFilter*stretch = [[GPUImageStretchDistortionFilteralloc]init];//创建滤镜对象

stretch.center= CGPointMake(vlaue, vlaue);

[stretchforceProcessingAtSize:self.image.size];//设置要渲染的区域

[stretchuseNextFrameForImageCapture];//捕获图片效果

[selffilterWithObject:stretch];//渲染图片并显示

}

break;

default:

break;

}

}

你可能感兴趣的:(GPUImage)