Skip to content

Commit

Permalink
add photo selection
Browse files Browse the repository at this point in the history
  • Loading branch information
ramonqlee committed Aug 21, 2012
1 parent f477f9f commit 28eb3c0
Show file tree
Hide file tree
Showing 12 changed files with 140 additions and 189 deletions.
21 changes: 21 additions & 0 deletions AmzPhoto/AmzPhoto.xcodeproj/project.pbxproj
Expand Up @@ -84,6 +84,8 @@
3092B95E15E2F85600AE4032 /* mvideoh.png in Resources */ = {isa = PBXBuildFile; fileRef = 3092B91B15E2F85500AE4032 /* mvideoh.png */; };
3092B95F15E2F85600AE4032 /* mvideoh@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 3092B91C15E2F85500AE4032 /* mvideoh@2x.png */; };
30970E3815E0548B00CD5117 /* libGPUImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 30970E3315E0546A00CD5117 /* libGPUImage.a */; };
30FE1AFE15E439AA0013EE24 /* SingleImageViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 30FE1AFD15E439AA0013EE24 /* SingleImageViewController.xib */; };
30FE1B4D15E447240013EE24 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 30FE1B4F15E447240013EE24 /* Localizable.strings */; };
C126B69315C4A14300613404 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C126B69215C4A14300613404 /* UIKit.framework */; };
C126B69515C4A14300613404 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C126B69415C4A14300613404 /* Foundation.framework */; };
C126B69715C4A14300613404 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C126B69615C4A14300613404 /* CoreGraphics.framework */; };
Expand Down Expand Up @@ -247,6 +249,10 @@
30970E2915E0546A00CD5117 /* GPUImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = GPUImage.xcodeproj; path = framework/GPUImage.xcodeproj; sourceTree = "<group>"; };
30970E3915E054A200CD5117 /* GPUImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = GPUImage.h; path = framework/Source/GPUImage.h; sourceTree = SOURCE_ROOT; };
30D5902615DFCCF1000C0C6A /* GPUImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = GPUImage.xcodeproj; path = GPUImage/GPUImage.xcodeproj; sourceTree = "<group>"; };
30FE1AFD15E439AA0013EE24 /* SingleImageViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = SingleImageViewController.xib; sourceTree = "<group>"; };
30FE1B4C15E4470D0013EE24 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "/Users/ramonqlee/Desktop/Project/AmazingPhoto/AmzPhoto/AmzPhoto/zh-Hans.lproj/InfoPlist.strings"; sourceTree = "<absolute>"; };
30FE1B4E15E447240013EE24 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/Localizable.strings; sourceTree = "<group>"; };
30FE1B5015E4472E0013EE24 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/Localizable.strings"; sourceTree = "<group>"; };
C126B68E15C4A14300613404 /* AmzPhoto.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AmzPhoto.app; sourceTree = BUILT_PRODUCTS_DIR; };
C126B69215C4A14300613404 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
C126B69415C4A14300613404 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
Expand Down Expand Up @@ -470,6 +476,7 @@
C126B69815C4A14300613404 /* AmzPhoto */ = {
isa = PBXGroup;
children = (
30FE1AFD15E439AA0013EE24 /* SingleImageViewController.xib */,
C1E9329315E31BC100C09B86 /* iCarouselExampleViewController.xib */,
C1E9329015E31BB700C09B86 /* iCarouselExampleViewController.h */,
C1E9329115E31BB700C09B86 /* iCarouselExampleViewController.m */,
Expand Down Expand Up @@ -499,6 +506,7 @@
C126B69B15C4A14300613404 /* InfoPlist.strings */,
C126B69E15C4A14300613404 /* main.m */,
C126B6A015C4A14300613404 /* AmzPhoto-Prefix.pch */,
30FE1B4F15E447240013EE24 /* Localizable.strings */,
);
name = "Supporting Files";
sourceTree = "<group>";
Expand Down Expand Up @@ -606,6 +614,7 @@
hasScannedForEncodings = 0;
knownRegions = (
en,
"zh-Hans",
);
mainGroup = C126B68315C4A14200613404;
productRefGroup = C126B68F15C4A14300613404 /* Products */;
Expand Down Expand Up @@ -744,6 +753,8 @@
C1E9329415E31BC100C09B86 /* iCarouselExampleViewController.xib in Resources */,
C1E9329715E31C7E00C09B86 /* background.png in Resources */,
C1E9329815E31C7E00C09B86 /* page.png in Resources */,
30FE1AFE15E439AA0013EE24 /* SingleImageViewController.xib in Resources */,
30FE1B4D15E447240013EE24 /* Localizable.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -784,10 +795,20 @@
/* End PBXTargetDependency section */

/* Begin PBXVariantGroup section */
30FE1B4F15E447240013EE24 /* Localizable.strings */ = {
isa = PBXVariantGroup;
children = (
30FE1B4E15E447240013EE24 /* en */,
30FE1B5015E4472E0013EE24 /* zh-Hans */,
);
name = Localizable.strings;
sourceTree = "<group>";
};
C126B69B15C4A14300613404 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
C126B69C15C4A14300613404 /* en */,
30FE1B4C15E4470D0013EE24 /* zh-Hans */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
Expand Down
12 changes: 0 additions & 12 deletions AmzPhoto/AmzPhoto/AppDelegate.m
Expand Up @@ -14,16 +14,6 @@
@implementation AppDelegate

@synthesize window = _window;
#pragma mark AFPhotoEditorControllerDelegate
- (void)photoEditor:(AFPhotoEditorController *)editor finishedWithImage:(UIImage *)image
{
// Handle the result image here
}

- (void)photoEditorCanceled:(AFPhotoEditorController *)editor
{
// Handle cancelation here
}

-(void)pageScrollDone
{
Expand Down Expand Up @@ -52,8 +42,6 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[editorController release];
#else
// Override point for customization after application launch.
//PhotoViewController* rootViewController = [[PhotoViewController alloc] initWithNibName:nil bundle:nil];
//ShowcaseFilterViewController *rootViewController = [[ShowcaseFilterViewController alloc] initWithFilterType:GPUIMAGE_SATURATION];
iCarouselExampleViewController* rootViewController = [[iCarouselExampleViewController alloc]initWithNibName:@"iCarouselExampleViewController" bundle:nil];
rootViewController.view.frame = [[UIScreen mainScreen] bounds];
mNavi = [[UINavigationController alloc]initWithRootViewController:rootViewController];
Expand Down
6 changes: 4 additions & 2 deletions AmzPhoto/AmzPhoto/ShowcaseFilterViewController.m
Expand Up @@ -56,21 +56,23 @@ - (IBAction)takePhoto:(id)sender;
runOnMainQueueWithoutDeadlocking(^{
// report_memory(@"Operation completed");
[photoCaptureButton setEnabled:YES];

self.navigationController.navigationBarHidden = YES;
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"image" ofType:@"png"];
UIImage* image = [UIImage imageWithContentsOfFile:filePath];
SingleImageViewController* viewController = [[SingleImageViewController alloc] initWithImage:image];
[self.navigationController pushViewController:viewController animated:YES];
[viewController release];
});
}];
[library release];
}];
#else
self.navigationController.navigationBarHidden = YES;
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"image" ofType:@"png"];
UIImage* image = [UIImage imageWithContentsOfFile:filePath];
SingleImageViewController* viewController = [[SingleImageViewController alloc] initWithImage:image];
[self.navigationController pushViewController:viewController animated:YES];
[viewController release];
#endif
}

Expand Down
1 change: 1 addition & 0 deletions AmzPhoto/AmzPhoto/en.lproj/InfoPlist.strings
@@ -1,2 +1,3 @@
/* Localized versions of Info.plist keys */
CFBundleDisplayName="AmzPhoto";

8 changes: 8 additions & 0 deletions AmzPhoto/AmzPhoto/en.lproj/Localizable.strings
@@ -0,0 +1,8 @@
/*
Localizable.strings
AmzPhoto

Created by li ming on 8/21/12.
Copyright (c) 2012 __MyCompanyName__. All rights reserved.
*/
"AppName"="AmzPhoto";
6 changes: 5 additions & 1 deletion AmzPhoto/AmzPhoto/iCarouselExampleViewController.h
Expand Up @@ -8,9 +8,10 @@

#import <UIKit/UIKit.h>
#import "iCarousel.h"
#import "AFPhotoEditorController.h"


@interface iCarouselExampleViewController : UIViewController <iCarouselDataSource, iCarouselDelegate>
@interface iCarouselExampleViewController : UIViewController <iCarouselDataSource, iCarouselDelegate,UIImagePickerControllerDelegate,UINavigationControllerDelegate,AFPhotoEditorControllerDelegate>

@property (nonatomic, retain) IBOutlet iCarousel *carousel;
@property (nonatomic, retain) IBOutlet UINavigationItem *navItem;
Expand All @@ -23,4 +24,7 @@
- (IBAction)insertItem;
- (IBAction)removeItem;

- (IBAction)camera;
- (IBAction)album;

@end
76 changes: 73 additions & 3 deletions AmzPhoto/AmzPhoto/iCarouselExampleViewController.m
Expand Up @@ -7,7 +7,9 @@
//

#import "iCarouselExampleViewController.h"

#import "ShowcaseFilterViewController.h"
#import "SingleImageViewController.h"
#import "AFPhotoEditorController.h"

#define IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)

Expand Down Expand Up @@ -83,12 +85,12 @@ - (void)dealloc

- (void)viewDidLoad
{
[super viewDidLoad];
[super viewDidLoad];

//configure carousel
carousel.decelerationRate = 0.5;
carousel.type = iCarouselTypeCoverFlow2;
navItem.title = @"CoverFlow2";
navItem.title = NSLocalizedString(@"AppName", "");
}

- (void)viewDidUnload
Expand Down Expand Up @@ -266,4 +268,72 @@ - (BOOL)carouselShouldWrap:(iCarousel *)carousel
return wrap;
}

- (IBAction)camera
{
self.navigationController.navigationBarHidden = NO;
ShowcaseFilterViewController *rootViewController = [[ShowcaseFilterViewController alloc] initWithFilterType:GPUIMAGE_SATURATION];
[self.navigationController pushViewController:rootViewController animated:YES];
[rootViewController release];
}
#pragma mark AFPhotoEditorControllerDelegate
- (void)photoEditor:(AFPhotoEditorController *)editor finishedWithImage:(UIImage *)image
{
// Handle the result image here
if (image != nil) {
SingleImageViewController* viewController = [[SingleImageViewController alloc] initWithImage:image];
[self.navigationController pushViewController:viewController animated:YES];
[viewController release];
}

//关闭图像选择器
[self dismissModalViewControllerAnimated:YES];
}

- (void)photoEditorCanceled:(AFPhotoEditorController *)editor
{
// Handle cancelation here
[editor dismissModalViewControllerAnimated:YES];
}

#pragma mark -
#pragma mark UIImagePickerControllerDelegate
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissModalViewControllerAnimated:YES];

UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
if(image)
{
AFPhotoEditorController *editorController = [[AFPhotoEditorController alloc] initWithImage:image];
[editorController setDelegate:self];
[self presentModalViewController:editorController animated:YES];
[editorController release];
}
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
[picker dismissModalViewControllerAnimated:YES];
}

#pragma action
- (IBAction)album
{
//获取图片选取器
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
//指定代理
imagePicker.delegate = self;
//打开图片后允许编辑
imagePicker.allowsEditing = YES;

//判断图片源的类型
if([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]){
//图片库
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}


//打开图片选择模态视图
[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];

}
@end

0 comments on commit 28eb3c0

Please sign in to comment.