-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 04ea0bd
Showing
40 changed files
with
2,463 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// BCColorInvertFilter.h | ||
// BCVideoFilterDemo | ||
// | ||
// Created by 陈明标 on 9/5/16. | ||
// Copyright © 2016 陈明标. All rights reserved. | ||
// | ||
|
||
#import "BCFilter.h" | ||
|
||
@interface BCColorInvertFilter : BCFilter | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// BCColorInvertFilter.m | ||
// BCVideoFilterDemo | ||
// | ||
// Created by 陈明标 on 9/5/16. | ||
// Copyright © 2016 陈明标. All rights reserved. | ||
// | ||
|
||
#import "BCColorInvertFilter.h" | ||
|
||
@implementation BCColorInvertFilter | ||
|
||
/** | ||
* 反转颜色滤镜-CIColorInvert | ||
* | ||
* @param image 处理前的图片 | ||
* @param content 上下文 | ||
* | ||
* @return 滤镜处理后的图片 | ||
*/ | ||
- (CIImage *)colorInvertWithImage:(CIImage *)ciImage | ||
{ | ||
if (!ciImage) { | ||
return nil; | ||
} | ||
|
||
CIFilter *filter = [CIFilter filterWithName:@"CIColorInvert"]; | ||
[filter setValue:ciImage forKey:kCIInputImageKey]; | ||
CIImage *outPutImg = [filter outputImage]; | ||
return outPutImg; | ||
} | ||
|
||
|
||
/** | ||
* 重写函数 | ||
* | ||
* @param image 处理前的图片 | ||
* | ||
* @return 处理后的图片 | ||
*/ | ||
- (CIImage *)getFilterHanldeImage:(CIImage *)image | ||
{ | ||
return [self colorInvertWithImage:image]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// | ||
// BCFilter.h | ||
// BCVideoFilterDemo | ||
// | ||
// Created by 陈明标 on 9/2/16. | ||
// Copyright © 2016 陈明标. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface BCFilter : NSObject | ||
|
||
// 当前滤镜说明 | ||
@property (nonatomic, copy) NSString *currentFilter; | ||
|
||
// 滤镜参数 | ||
@property (nonatomic, copy) NSArray *parameters; | ||
|
||
|
||
/** | ||
* 获取处理后的图片 | ||
* | ||
* @param image 处理前的图片 | ||
* | ||
* @return 处理后的图片 | ||
*/ | ||
- (CIImage *)getFilterHanldeImage:(CIImage *)image; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// BCFilter.m | ||
// BCVideoFilterDemo | ||
// | ||
// Created by 陈明标 on 9/2/16. | ||
// Copyright © 2016 陈明标. All rights reserved. | ||
// | ||
|
||
#import "BCFilter.h" | ||
|
||
@implementation BCFilter | ||
|
||
- (CIImage *)getFilterHanldeImage:(CIImage *)image | ||
{ | ||
return image; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// BCGaussianBlurFilter.h | ||
// BCVideoFilterDemo | ||
// | ||
// Created by 陈明标 on 9/5/16. | ||
// Copyright © 2016 陈明标. All rights reserved. | ||
// | ||
|
||
#import "BCFilter.h" | ||
|
||
@interface BCGaussianBlurFilter : BCFilter | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// | ||
// BCGaussianBlurFilter.m | ||
// BCVideoFilterDemo | ||
// | ||
// Created by 陈明标 on 9/5/16. | ||
// Copyright © 2016 陈明标. All rights reserved. | ||
// | ||
|
||
#import "BCGaussianBlurFilter.h" | ||
|
||
@implementation BCGaussianBlurFilter | ||
|
||
/** | ||
* 高斯模糊滤镜-CIGaussianBlur | ||
* | ||
* @param ciImage 处理前的图片 | ||
* @param radius 半径 | ||
* @param content 上下文 | ||
* | ||
* @return 滤镜处理后的图片 | ||
*/ | ||
- (CIImage *)gaussianBlurWithImage:(CIImage *)ciImage | ||
radius:(CGFloat)radius | ||
{ | ||
CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"]; | ||
[filter setValue:ciImage forKey:kCIInputImageKey]; | ||
if (radius >= 0 && radius <= 100) { | ||
[filter setValue:@(radius) forKey:@"inputRadius"]; | ||
} | ||
CIImage *outPutImg = [filter outputImage]; | ||
return outPutImg; | ||
} | ||
|
||
/** | ||
* 重写函数 | ||
* | ||
* @param image 处理前的图片 | ||
* | ||
* @return 处理后的图片 | ||
*/ | ||
- (CIImage *)getFilterHanldeImage:(CIImage *)image | ||
{ | ||
return [self gaussianBlurWithImage:image radius:2.0]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// BCPixellateFilter.h | ||
// BCVideoFilterDemo | ||
// | ||
// Created by 陈明标 on 9/5/16. | ||
// Copyright © 2016 陈明标. All rights reserved. | ||
// | ||
|
||
#import "BCFilter.h" | ||
|
||
@interface BCPixellateFilter : BCFilter | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// | ||
// BCPixellateFilter.m | ||
// BCVideoFilterDemo | ||
// | ||
// Created by 陈明标 on 9/5/16. | ||
// Copyright © 2016 陈明标. All rights reserved. | ||
// | ||
|
||
#import "BCPixellateFilter.h" | ||
|
||
@implementation BCPixellateFilter | ||
|
||
/** | ||
* 像素滤镜-CIPixellate | ||
* | ||
* @param ciImage 处理前的图片 | ||
* @param center 中心点 | ||
* @param scale 比列 | ||
* @param content 上下文 | ||
* | ||
* @return 滤镜处理后的图片 | ||
*/ | ||
- (CIImage *)pixellateWithImage:(CIImage *)ciImage | ||
center:(CGPoint)center | ||
scale:(CGFloat)scale | ||
{ | ||
CIFilter *filter = [CIFilter filterWithName:@"CIPixellate"]; | ||
[filter setValue:ciImage forKey:kCIInputImageKey]; | ||
if (scale >= 1 && scale <= 100) { | ||
[filter setValue:@(scale) forKey:@"inputScale"]; | ||
} | ||
CIVector *vector = [CIVector vectorWithCGPoint:center]; | ||
[filter setValue:vector forKey:@"inputCenter"]; | ||
CIImage *outPutImg = [filter outputImage]; | ||
return outPutImg; | ||
} | ||
|
||
/** | ||
* 重写函数 | ||
* | ||
* @param image 处理前的图片 | ||
* | ||
* @return 处理后的图片 | ||
*/ | ||
- (CIImage *)getFilterHanldeImage:(CIImage *)image | ||
{ | ||
return [self pixellateWithImage:image center:CGPointMake(300, 300) scale:8]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// | ||
// BCSepiaToneFilter.h | ||
// BCVideoFilterDemo | ||
// | ||
// Created by 陈明标 on 9/5/16. | ||
// Copyright © 2016 陈明标. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#import "BCFilter.h" | ||
|
||
@interface BCSepiaToneFilter : BCFilter | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// BCSepiaToneFilter.m | ||
// BCVideoFilterDemo | ||
// | ||
// Created by 陈明标 on 9/5/16. | ||
// Copyright © 2016 陈明标. All rights reserved. | ||
// | ||
|
||
#import "BCSepiaToneFilter.h" | ||
|
||
@implementation BCSepiaToneFilter | ||
|
||
/** | ||
* 棕色滤镜-CISepiaTone | ||
* | ||
* @param image 处理前的图片 | ||
* @param intentsity 强度 | ||
* | ||
* @return 滤镜处理后的图片 | ||
*/ | ||
- (CIImage *)sepiaToneWithImage:(CIImage *)ciImage | ||
intentsity:(CGFloat)intentsity | ||
{ | ||
CIFilter *filter = [CIFilter filterWithName:@"CISepiaTone"]; | ||
[filter setValue:ciImage forKey:kCIInputImageKey]; | ||
if (intentsity >= 0 && intentsity <= 1) { | ||
[filter setValue:@(intentsity) forKey:@"inputIntensity"]; | ||
} | ||
CIImage *outPutImg = [filter outputImage]; | ||
return outPutImg; | ||
} | ||
|
||
/** | ||
* 重写函数 | ||
* | ||
* @param image 处理前的图片 | ||
* | ||
* @return 处理后的图片 | ||
*/ | ||
- (CIImage *)getFilterHanldeImage:(CIImage *)image | ||
{ | ||
return [self sepiaToneWithImage:image intentsity:0.8]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// | ||
// BCGLKView.h | ||
// BCVideoFilterDemo | ||
// | ||
// Created by 陈明标 on 8/24/16. | ||
// Copyright © 2016 陈明标. All rights reserved. | ||
// | ||
|
||
#import <GLKit/GLKit.h> | ||
|
||
@interface BCGLKView : GLKView | ||
|
||
@property (strong, nonatomic) CIImage * image; | ||
|
||
@property GLfloat preferredRotation; | ||
@property CGSize presentationRect; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
// | ||
// BCCoreImageView.m | ||
// BCVideoFilterDemo | ||
// | ||
// Created by 陈明标 on 8/19/16. | ||
// Copyright © 2016 陈明标. All rights reserved. | ||
// | ||
|
||
#import "BCGLKView.h" | ||
|
||
#import <GLKit/GLKit.h> | ||
|
||
@interface BCGLKView () { | ||
CIContext *coreImageContext; | ||
} | ||
|
||
@end | ||
|
||
@implementation BCGLKView | ||
|
||
- (instancetype) initWithFrame:(CGRect)frame { | ||
|
||
self = [super initWithFrame:frame]; | ||
|
||
if (self) { | ||
EAGLContext *context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; | ||
self = [self initWithFrame:frame context:context]; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (instancetype) initWithFrame:(CGRect)frame context:(EAGLContext *)context { | ||
self = [super initWithFrame:frame context:context]; | ||
|
||
if (self) { | ||
coreImageContext = [CIContext contextWithEAGLContext:context]; | ||
[self setEnableSetNeedsDisplay:false]; | ||
} | ||
|
||
return self; | ||
} | ||
|
||
- (void) drawRect:(CGRect)rect { | ||
|
||
// 构造解码比例 | ||
CGRect origninalRect = CGRectMake(0, 260, 760, 520); | ||
|
||
// 获取比例屏幕相对比例 | ||
// CGFloat widthScale = (rect.size.width / origninalRect.size.width) * 2; | ||
// CGFloat heightScale = (rect.size.height / origninalRect.size.height) * 2; | ||
|
||
// CGRect destRect = CGRectApplyAffineTransform(origninalRect, CGAffineTransformMakeScale(widthScale, heightScale)); | ||
[coreImageContext drawImage:self.image inRect:origninalRect fromRect:self.image.extent]; | ||
|
||
} | ||
|
||
@end | ||
|
Oops, something went wrong.