Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
chenmingbiao committed Sep 5, 2016
0 parents commit 04ea0bd
Show file tree
Hide file tree
Showing 40 changed files with 2,463 additions and 0 deletions.
13 changes: 13 additions & 0 deletions BCVideoFilter/BCFilters/BCColorInvertFilter.h
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
46 changes: 46 additions & 0 deletions BCVideoFilter/BCFilters/BCColorInvertFilter.m
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
29 changes: 29 additions & 0 deletions BCVideoFilter/BCFilters/BCFilter.h
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
18 changes: 18 additions & 0 deletions BCVideoFilter/BCFilters/BCFilter.m
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
13 changes: 13 additions & 0 deletions BCVideoFilter/BCFilters/BCGaussianBlurFilter.h
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
46 changes: 46 additions & 0 deletions BCVideoFilter/BCFilters/BCGaussianBlurFilter.m
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
13 changes: 13 additions & 0 deletions BCVideoFilter/BCFilters/BCPixellateFilter.h
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
50 changes: 50 additions & 0 deletions BCVideoFilter/BCFilters/BCPixellateFilter.m
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
15 changes: 15 additions & 0 deletions BCVideoFilter/BCFilters/BCSepiaToneFilter.h
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
45 changes: 45 additions & 0 deletions BCVideoFilter/BCFilters/BCSepiaToneFilter.m
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
18 changes: 18 additions & 0 deletions BCVideoFilter/BCGLKView.h
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
59 changes: 59 additions & 0 deletions BCVideoFilter/BCGLKView.m
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

Loading

0 comments on commit 04ea0bd

Please sign in to comment.