Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
金聖輝 committed Feb 12, 2015
0 parents commit b5d98d9
Show file tree
Hide file tree
Showing 76 changed files with 3,112 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Created by https://www.gitignore.io

### Xcode ###
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.xcuserstate


### Objective-C ###
# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate

# CocoaPods
#
# We recommend against adding the Pods directory to your .gitignore. However
# you should judge for yourself, the pros and cons are mentioned at:
# http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
#
# Pods/
507 changes: 507 additions & 0 deletions MosiacCamera.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions MosiacCamera/AppDelegate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// AppDelegate.h
// MosiacCamera
//
// Created by 金聖輝 on 14/11/30.
// Copyright (c) 2014年 kimsungwhee.com. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;


@end

45 changes: 45 additions & 0 deletions MosiacCamera/AppDelegate.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// AppDelegate.m
// MosiacCamera
//
// Created by 金聖輝 on 14/11/30.
// Copyright (c) 2014年 kimsungwhee.com. All rights reserved.
//

#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
return YES;
}

- (void)applicationWillResignActive:(UIApplication *)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
171 changes: 171 additions & 0 deletions MosiacCamera/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions MosiacCamera/Classes/Categories/UIView+KSHAdditions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//
// UIView+KSHAdditions.h
// MosiacCamera
//
// Created by 金聖輝 on 14/11/30.
// Copyright (c) 2014年 kimsungwhee.com. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface UIView (KSHAdditions)

@property (nonatomic, assign) CGFloat frameX;
@property (nonatomic, assign) CGFloat frameY;
@property (nonatomic, assign) CGFloat frameWidth;
@property (nonatomic, assign) CGFloat frameHeight;
@property (nonatomic, assign) CGPoint frameOrigin;
@property (nonatomic, assign) CGSize frameSize;
@property (nonatomic, assign) CGFloat boundsX;
@property (nonatomic, assign) CGFloat boundsY;
@property (nonatomic, assign) CGFloat boundsWidth;
@property (nonatomic, assign) CGFloat boundsHeight;
@property (nonatomic, assign) CGFloat centerX;
@property (nonatomic, assign) CGFloat centerY;
@end
109 changes: 109 additions & 0 deletions MosiacCamera/Classes/Categories/UIView+KSHAdditions.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
//
// UIView+KSHAdditions.m
// MosiacCamera
//
// Created by 金聖輝 on 14/11/30.
// Copyright (c) 2014年 kimsungwhee.com. All rights reserved.
//

#import "UIView+KSHAdditions.h"

@implementation UIView (KSHAdditions)

- (CGFloat)frameX {
return self.frame.origin.x;
}

- (void)setFrameX:(CGFloat)newX {
self.frame = CGRectMake(newX, self.frame.origin.y, self.frame.size.width, self.frame.size.height);
}

- (CGFloat)frameY {
return self.frame.origin.y;
}

- (void)setFrameY:(CGFloat)newY {
self.frame = CGRectMake(self.frame.origin.x, newY, self.frame.size.width, self.frame.size.height);
}

- (CGFloat)frameWidth {
return self.frame.size.width;
}

- (void)setFrameWidth:(CGFloat)newWidth {
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, newWidth, self.frame.size.height);
}

- (CGFloat)frameHeight {
return self.frame.size.height;
}

- (void)setFrameHeight:(CGFloat)newHeight {
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width, newHeight);
}

- (CGPoint)frameOrigin {
return self.frame.origin;
}

- (void)setFrameOrigin:(CGPoint)newOrigin {
self.frame = CGRectMake(newOrigin.x, newOrigin.y, self.frame.size.width, self.frame.size.height);
}

- (CGSize)frameSize {
return self.frame.size;
}

- (void)setFrameSize:(CGSize)newSize {
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, newSize.width, newSize.height);
}

- (CGFloat)boundsX {
return self.bounds.origin.x;
}

- (void)setBoundsX:(CGFloat)newX {
self.bounds = CGRectMake(newX, self.bounds.origin.y, self.bounds.size.width, self.bounds.size.height);
}

- (CGFloat)boundsY {
return self.bounds.origin.y;
}

- (void)setBoundsY:(CGFloat)newY {
self.bounds = CGRectMake(self.bounds.origin.x, newY, self.bounds.size.width, self.bounds.size.height);
}

- (CGFloat)boundsWidth {
return self.bounds.size.width;
}

- (void)setBoundsWidth:(CGFloat)newWidth {
self.bounds = CGRectMake(self.bounds.origin.x, self.bounds.origin.y, newWidth, self.bounds.size.height);
}

- (CGFloat)boundsHeight {
return self.bounds.size.height;
}

- (void)setBoundsHeight:(CGFloat)newHeight {
self.bounds = CGRectMake(self.bounds.origin.x, self.bounds.origin.y, self.bounds.size.width, newHeight);
}

- (CGFloat)centerX {
return self.center.x;
}

- (void)setCenterX:(CGFloat)newX {
self.center = CGPointMake(newX, self.center.y);
}

- (CGFloat)centerY {
return self.center.y;
}

- (void)setCenterY:(CGFloat)newY {
self.center = CGPointMake(self.center.x, newY);
}

@end
16 changes: 16 additions & 0 deletions MosiacCamera/Classes/Common/KSHContextManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// KSHContextManager.h
// MosiacCamera
//
// Created by 金聖輝 on 14/12/14.
// Copyright (c) 2014年 kimsungwhee.com. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <GLKit/GLKit.h>

@interface KSHContextManager : NSObject
+ (instancetype)sharedInstance;
@property (strong, nonatomic, readonly) EAGLContext *eaglContext;
@property (strong, nonatomic, readonly) CIContext *ciContext;
@end
30 changes: 30 additions & 0 deletions MosiacCamera/Classes/Common/KSHContextManager.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
//
// KSHContextManager.m
// MosiacCamera
//
// Created by 金聖輝 on 14/12/14.
// Copyright (c) 2014年 kimsungwhee.com. All rights reserved.
//

#import "KSHContextManager.h"

@implementation KSHContextManager

+ (instancetype)sharedInstance {
static dispatch_once_t predicate;
static KSHContextManager *instance = nil;
dispatch_once(&predicate, ^{instance = [[self alloc] init];});
return instance;
}

- (instancetype)init {
self = [super init];
if (self) {
_eaglContext = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2];
NSDictionary *options = @{kCIContextWorkingColorSpace : [NSNull null]};
_ciContext = [CIContext contextWithEAGLContext:_eaglContext options:options];
}
return self;
}

@end
53 changes: 53 additions & 0 deletions MosiacCamera/Classes/Controllers/KSHCameraController.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// KSHCameraController.h
// MosiacCamera
//
// Created by 金聖輝 on 14/11/30.
// Copyright (c) 2014年 kimsungwhee.com. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
#import "KSHImageTarget.h"


#define KSHThumbnailCreatedNotification @"KSHThumbnailCreated"

@protocol KSHCameraControllerDelegate <NSObject>
- (void)deviceConfigurationFailedWithError:(NSError*)error;
- (void)mediaCaptureFailedWithError:(NSError*)error;
- (void)assetLibraryWriteFailedWithError:(NSError*)error;
@end

@interface KSHCameraController : NSObject
@property (nonatomic, weak) id <KSHCameraControllerDelegate> delegate;
@property (nonatomic, strong, readonly) AVCaptureSession *captureSession;
@property (nonatomic, assign, readonly) NSUInteger cameraCount;
@property (nonatomic, assign, readonly) BOOL cameraHasTorch;
@property (nonatomic, assign, readonly) BOOL cameraHasFlash;
@property (nonatomic, assign, readonly) BOOL cameraSupportsTapToFocus;
@property (nonatomic, assign, readonly) BOOL cameraSupportsTapToExpose;
@property (nonatomic, assign) AVCaptureTorchMode torchMode;
@property (nonatomic, assign) AVCaptureFlashMode flashMode;
@property (nonatomic, assign, readonly) NSTimeInterval recordedDuration;
@property (nonatomic, copy) NSString *sessionPreset;
@property (nonatomic, weak) id<KSHImageTarget> imageTarget;
@property (nonatomic, assign) BOOL filterEnable;

- (BOOL)setupSession:(NSError **)error;
- (void)startSession;
- (void)stopSession;

- (BOOL)switchCameras;
- (BOOL)canSwitchCameras;

- (void)focusAtPoint:(CGPoint)point;
- (void)exposeAtPoint:(CGPoint)point;
- (void)resetFocusAndExposureModes;

- (void)captureStillImage;

- (void)startRecording;
- (void)stopRecording;
- (BOOL)isRecording;
@end
Loading

0 comments on commit b5d98d9

Please sign in to comment.