-
Notifications
You must be signed in to change notification settings - Fork 1
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
Rob Abbott
committed
Apr 2, 2011
0 parents
commit 7b3fa04
Showing
30 changed files
with
1,979 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 @@ | ||
:) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,62 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<script src="http://10.20.80.103:9393/webcamera.js"></script> | ||
<style> | ||
body { | ||
background: url('background.png'); | ||
text-align: center; | ||
} | ||
a { | ||
color: #fff; | ||
} | ||
input[type=submit] { | ||
font-size: 20px; | ||
} | ||
#x100 { | ||
width: 100px; | ||
height: 100px; | ||
border: 1px solid #fff; | ||
} | ||
#h100w200 { | ||
width: 200px; | ||
height: 100px; | ||
border: 1px solid #fff; | ||
} | ||
#x25 { | ||
width: 25px; | ||
height: 25px; | ||
border: 1px solid #fff; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<br /> | ||
|
||
<div id="x100"> | ||
<a href="webcamera:choose_photo?div_id=x100&input_id=x100_encoded&height=100&width=100">100x100</a> | ||
</div> | ||
|
||
<br /> | ||
|
||
<div id="h100w200"> | ||
<a href="webcamera:choose_photo?div_id=h100w200&input_id=h100w200_encoded&height=100&width=200">200x100</a> | ||
</div> | ||
|
||
<br /> | ||
|
||
<div id="x25"></div> | ||
|
||
<a href="webcamera:choose_photo?div_id=x25&input_id=x25_encoded&height=25&width=25">x25</a> | ||
|
||
<br /> | ||
|
||
<form action="http://10.20.80.103:9393/upload" method="post"> | ||
<input type="hidden" name="x100_encoded" id="x100_encoded" /> | ||
<input type="hidden" name="h100w200_encoded" id="h100w200_encoded" /> | ||
<input type="hidden" name="x25_encoded" id="x25_encoded" /> | ||
<input type="submit" value="Upload" /> | ||
</form> | ||
</body> | ||
</html> |
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,7 @@ | ||
function setPhoto(div_id, input_id, data) { | ||
var div = document.getElementById(div_id), | ||
input = document.getElementById(input_id); | ||
|
||
div.style.backgroundImage = 'url(data:image/png;base64,' + data + ')' | ||
input.setAttribute('value', data); | ||
} |
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 @@ | ||
require 'sinatra' | ||
|
||
set :public, File.dirname(__FILE__) | ||
|
||
post '/upload' do | ||
haml :response | ||
end | ||
|
||
__END__ | ||
|
||
@@ response | ||
- params.each do |k,v| | ||
%img{:src => "data:image/png;base64,#{v}"} |
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,5 @@ | ||
build | ||
*.mode1v3 | ||
*.pbxuser | ||
|
||
*.perspectivev3 |
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,16 @@ | ||
// | ||
// NSString+ContainsString.h | ||
// WebCamera | ||
// | ||
// Created by Shayne Sweeney on 5/27/10. | ||
// Copyright 2010 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
|
||
@interface NSString (ContainsString) | ||
|
||
- (BOOL)containsString:(NSString*)string options:(NSStringCompareOptions)options; | ||
|
||
@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 @@ | ||
// | ||
// NSString+ContainsString.m | ||
// WebCamera | ||
// | ||
// Created by Shayne Sweeney on 5/27/10. | ||
// Copyright 2010 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import "NSString+ContainsString.h" | ||
|
||
|
||
@implementation NSString (ContainsString) | ||
|
||
- (BOOL)containsString:(NSString*)string options:(NSStringCompareOptions)options { | ||
return [self rangeOfString:string options:options].location == NSNotFound ? NO : YES; | ||
} | ||
|
||
@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,16 @@ | ||
// | ||
// UIImage+Resize.h | ||
// WebCamera | ||
// | ||
// Created by Shayne Sweeney on 5/26/10. | ||
// Copyright 2010 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
|
||
@interface UIImage (Resize) | ||
|
||
- (UIImage *)imageByScalingToWidth:(CGFloat)targetWidth; | ||
- (UIImage *)imageByScalingToHeight:(CGFloat)targetHeight; | ||
- (UIImage *)imageByScalingToSize:(CGSize)targetSize; | ||
|
||
@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,74 @@ | ||
// | ||
// UIImage+Resize.m | ||
// WebCamera | ||
// | ||
// Created by Shayne Sweeney on 5/26/10. | ||
// Copyright 2010 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import "UIImage+Resize.h" | ||
|
||
@implementation UIImage (Resize) | ||
|
||
- (UIImage *)imageByScalingToWidth:(CGFloat)targetWidth { | ||
CGFloat width = self.size.width; | ||
CGFloat height = self.size.height; | ||
CGFloat targetHeight = round(height / (width / targetWidth)); | ||
return [self imageByScalingToSize:CGSizeMake(targetWidth, targetHeight)]; | ||
} | ||
|
||
- (UIImage *)imageByScalingToHeight:(CGFloat)targetHeight { | ||
CGFloat width = self.size.width; | ||
CGFloat height = self.size.height; | ||
CGFloat targetWidth = round(width / (height / targetHeight)); | ||
return [self imageByScalingToSize:CGSizeMake(targetWidth, targetHeight)]; | ||
} | ||
|
||
- (UIImage *)imageByScalingToSize:(CGSize)targetSize { | ||
NSInteger targetWidth = targetSize.width; | ||
NSInteger targetHeight = targetSize.height; | ||
|
||
CGImageRef imageRef = [self CGImage]; | ||
// color space of the bitmap: RGB, GRAY, CMYK, etc... | ||
CGColorSpaceRef colorSpaceRef = CGImageGetColorSpace(imageRef); | ||
// how is the bitmap data stored? do we have an alpha channel? how is that stored? | ||
CGBitmapInfo bitmapInfo = CGImageGetBitmapInfo(imageRef); | ||
// I guess there's weirdness with kCGImageAlphaNone and CGBitmapContextCreate | ||
// only certain alpha values are supported with RGB 8 bit | ||
if (bitmapInfo == kCGImageAlphaNone) | ||
bitmapInfo = kCGImageAlphaNoneSkipLast; | ||
|
||
// swap width and height if orientation is left or right | ||
if (self.imageOrientation == UIImageOrientationLeft || self.imageOrientation == UIImageOrientationRight) | ||
targetWidth = targetHeight, targetHeight = targetWidth; | ||
|
||
// Build a bitmap context of the target size | ||
CGContextRef bitmapRef = CGBitmapContextCreate(NULL, targetWidth, targetHeight, CGImageGetBitsPerComponent(imageRef), CGImageGetBytesPerRow(imageRef), colorSpaceRef, bitmapInfo); | ||
|
||
if (self.imageOrientation == UIImageOrientationLeft) { | ||
CGContextRotateCTM(bitmapRef, M_PI/2); | ||
CGContextTranslateCTM(bitmapRef, -targetWidth, 0); | ||
} else if (self.imageOrientation == UIImageOrientationRight) { | ||
CGContextRotateCTM(bitmapRef, -M_PI/2); | ||
CGContextTranslateCTM(bitmapRef, 0, -targetHeight); | ||
} else if (self.imageOrientation == UIImageOrientationUp) { | ||
// nada | ||
} else if (self.imageOrientation == UIImageOrientationDown) { | ||
CGContextRotateCTM(bitmapRef, -M_PI); | ||
CGContextTranslateCTM(bitmapRef, targetWidth, targetHeight); | ||
} | ||
|
||
// Draw into the context (this scales the image) | ||
CGContextDrawImage(bitmapRef, CGRectMake(0, 0, targetWidth, targetHeight), imageRef); | ||
|
||
// Get an image from the context and a UIImage | ||
CGImageRef resizedImageRef = CGBitmapContextCreateImage(bitmapRef); | ||
UIImage *resizedImage = [UIImage imageWithCGImage:resizedImageRef]; | ||
|
||
CGContextRelease(bitmapRef); | ||
CGImageRelease(resizedImageRef); | ||
|
||
return resizedImage; | ||
} | ||
|
||
@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,26 @@ | ||
// | ||
// WebViewController.h | ||
// WebCamera | ||
// | ||
// Created by Shayne Sweeney on 5/25/10. | ||
// Copyright 2010 __MyCompanyName__. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
|
||
@interface WebViewController : UIViewController <UIWebViewDelegate, UINavigationControllerDelegate, UIImagePickerControllerDelegate, UIActionSheetDelegate> { | ||
UIWebView *webView_; | ||
UIImagePickerController *imagePickerController_; | ||
CGFloat targetHeight_; | ||
CGFloat targetWidth_; | ||
NSString *divID_; | ||
NSString *inputID_; | ||
} | ||
|
||
@property (nonatomic, readonly) UIWebView *webView; | ||
@property (nonatomic, readonly) UIImagePickerController *imagePickerController; | ||
@property (nonatomic, copy) NSString *divID; | ||
@property (nonatomic, copy) NSString *inputID; | ||
|
||
@end |
Oops, something went wrong.