Skip to content

Instantly share code, notes, and snippets.

@daikini
Forked from atnan/CameraTestAppDelegate.h
Created August 2, 2009 02:00
Show Gist options
  • Save daikini/159892 to your computer and use it in GitHub Desktop.
Save daikini/159892 to your computer and use it in GitHub Desktop.
#import <UIKit/UIKit.h>
@interface CameraTestAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
}
@property (nonatomic, retain) IBOutlet UIWindow *window;
- (void) cameraControllerReadyStateChanged:(NSNotification*)aNotification;
- (void) cameraController:(id)sender tookPicture:(UIImage*)picture withPreview:(UIImage*)preview jpegData:(NSData*)rawData imageProperties:(struct __CFDictionary*) imageProperties;
@end
#import "CameraTestAppDelegate.h"
#import "PLCameraController.h"
@implementation CameraTestAppDelegate
@synthesize window;
- (void)applicationDidFinishLaunching:(UIApplication *)application {
[application setStatusBarHidden:YES animated:NO];
PLCameraController* cameraController = [PLCameraController sharedInstance];
// [cameraController setDelegate:self];
[cameraController startPreview];
UIView *view = [cameraController previewView];
view.frame = CGRectMake(0, 0, 320, 480);
[window addSubview:view];
[window makeKeyAndVisible];
}
- (void) cameraControllerReadyStateChanged:(NSNotification*)aNotification {
}
- (void) cameraController:(id)sender tookPicture:(UIImage*)picture withPreview:(UIImage*)preview jpegData:(NSData*)rawData imageProperties:(struct __CFDictionary*) imageProperties {
// UIImageWriteToSavedPhotosAlbum(preview, self, nil, nil);
// NSString *filePath = [NSString stringWithFormat:@"%@%@", NSHomeDirectory(), @"/Documents/image.jpg"];
// [rawData writeToFile:filePath atomically:YES];
//
// CGImageRef *cGImageRef = [window _createCGImageRefRepresentationInFrame: [window bounds]];
// NSData *rawData = UIImageJPEGRepresentation([UIImage imageWithCGImage: cGImageRef], compressRatio);
}
- (void)dealloc {
[window release];
[super dealloc];
}
@end
@interface PLCameraController : NSObject
{
CALayer *_cameraLayer;
struct CameraDevice *_camera;
struct CameraImageQueueHelper *_cameraHelper;
id _delegate;
UIView *_previewView;
BOOL _isPreviewing;
BOOL _isLocked;
BOOL _wasPreviewingBeforeDeviceLock;
}
+ (id)sharedInstance;
- (id)init;
- (void)dealloc;
- (void)_setIsReady;
- (BOOL)isReady;
- (void)_applicationSuspended;
- (void)_applicationResumed;
- (void)_tookPicture:(struct __CoreSurfaceBuffer *)fp8;
- (void)_tookPicture:(struct CGImage *)fp8 jpegData:(struct __CFData *)fp12 imageProperties:(struct __CFDictionary *)fp16;
- (struct CameraImageQueueHelper *)_cameraHelper;
- (BOOL)_setupCamera;
- (void)_tearDownCamera;
- (void)setDelegate:(id)fp8;
- (id)delegate;
- (struct CGRect)_cameraFrame;
- (id)previewView;
- (void)startPreview;
- (void)stopPreview;
- (void)capturePhoto;
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment