Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Classes/DLCImagePickerController.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

#import <Foundation/Foundation.h>
#import "GPUImage.h"
#import <GPUImage/GPUImage.h>
#import "DLCBlurOverlayView.h"

@class DLCImagePickerController;
Expand All @@ -20,6 +20,7 @@

@interface DLCImagePickerController : UIViewController <UINavigationControllerDelegate,UIImagePickerControllerDelegate>

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *filterViewBottomConstraint;
@property (nonatomic, weak) IBOutlet GPUImageView *imageView;
@property (nonatomic, weak) id <DLCImagePickerDelegate> delegate;
@property (nonatomic, weak) IBOutlet UIButton *photoCaptureButton;
Expand Down
40 changes: 8 additions & 32 deletions Classes/DLCImagePickerController.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ -(id) init {
-(void)viewDidLoad {

[super viewDidLoad];
self.wantsFullScreenLayout = YES;
self.extendedLayoutIncludesOpaqueBars = YES;

//set background color
self.view.backgroundColor = [UIColor colorWithPatternImage:
[UIImage imageNamed:@"micro_carbon"]];
Expand All @@ -88,7 +89,7 @@ -(void)viewDidLoad {
self.focusView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"focus-crosshair"]];
[self.view addSubview:self.focusView];
self.focusView.alpha = 0;

[self.imageView setFillMode:kGPUImageFillModeStretch];

self.blurOverlayView = [[DLCBlurOverlayView alloc] initWithFrame:CGRectMake(0, 0,
self.imageView.frame.size.width,
Expand Down Expand Up @@ -353,7 +354,6 @@ -(IBAction) toggleBlur:(UIButton*)blurButton {
blurFilter = [[GPUImageGaussianSelectiveBlurFilter alloc] init];
[(GPUImageGaussianSelectiveBlurFilter*)blurFilter setExcludeCircleRadius:80.0/320.0];
[(GPUImageGaussianSelectiveBlurFilter*)blurFilter setExcludeCirclePoint:CGPointMake(0.5f, 0.5f)];
[(GPUImageGaussianSelectiveBlurFilter*)blurFilter setBlurRadiusInPixels:kStaticBlurSize];
[(GPUImageGaussianSelectiveBlurFilter*)blurFilter setAspectRatio:1.0f];
}
hasBlur = YES;
Expand Down Expand Up @@ -410,7 +410,7 @@ -(void)captureImage {

[self prepareFilter];
[self.retakeButton setHidden:NO];
[self.photoCaptureButton setTitle:@"Done" forState:UIControlStateNormal];
[self.photoCaptureButton setTitle:@"Finish" forState:UIControlStateNormal];
[self.photoCaptureButton setImage:nil forState:UIControlStateNormal];
[self.photoCaptureButton setEnabled:YES];
if(![self.filtersToggleButton isSelected]){
Expand Down Expand Up @@ -518,20 +518,17 @@ -(IBAction) handlePan:(UIGestureRecognizer *) sender {

if ([sender state] == UIGestureRecognizerStateBegan) {
[self showBlurOverlay:YES];
[gpu setBlurRadiusInPixels:0.0f];
if (isStatic) {
[staticPicture processImage];
}
}

if ([sender state] == UIGestureRecognizerStateBegan || [sender state] == UIGestureRecognizerStateChanged) {
[gpu setBlurRadiusInPixels:0.0f];
[self.blurOverlayView setCircleCenter:tapPoint];
[gpu setExcludeCirclePoint:CGPointMake(tapPoint.x/320.0f, tapPoint.y/320.0f)];
}

if([sender state] == UIGestureRecognizerStateEnded){
[gpu setBlurRadiusInPixels:kStaticBlurSize];
[self showBlurOverlay:NO];
if (isStatic) {
[staticPicture processImage];
Expand Down Expand Up @@ -585,14 +582,12 @@ -(IBAction) handlePinch:(UIPinchGestureRecognizer *) sender {

if ([sender state] == UIGestureRecognizerStateBegan) {
[self showBlurOverlay:YES];
[gpu setBlurRadiusInPixels:0.0f];
if (isStatic) {
[staticPicture processImage];
}
}

if ([sender state] == UIGestureRecognizerStateBegan || [sender state] == UIGestureRecognizerStateChanged) {
[gpu setBlurRadiusInPixels:0.0f];
[gpu setExcludeCirclePoint:CGPointMake(midpoint.x/320.0f, midpoint.y/320.0f)];
self.blurOverlayView.circleCenter = CGPointMake(midpoint.x, midpoint.y);
CGFloat radius = MAX(MIN(sender.scale*[gpu excludeCircleRadius], 0.6f), 0.15f);
Expand All @@ -602,7 +597,6 @@ -(IBAction) handlePinch:(UIPinchGestureRecognizer *) sender {
}

if ([sender state] == UIGestureRecognizerStateEnded) {
[gpu setBlurRadiusInPixels:kStaticBlurSize];
[self showBlurOverlay:NO];
if (isStatic) {
[staticPicture processImage];
Expand All @@ -614,23 +608,14 @@ -(IBAction) handlePinch:(UIPinchGestureRecognizer *) sender {
-(void) showFilters {
[self.filtersToggleButton setSelected:YES];
self.filtersToggleButton.enabled = NO;
CGRect imageRect = self.imageView.frame;
imageRect.origin.y -= 34;
CGRect sliderScrollFrame = self.filterScrollView.frame;
sliderScrollFrame.origin.y -= self.filterScrollView.frame.size.height;
CGRect sliderScrollFrameBackground = self.filtersBackgroundImageView.frame;
sliderScrollFrameBackground.origin.y -=
self.filtersBackgroundImageView.frame.size.height-3;

self.filterScrollView.hidden = NO;
self.filtersBackgroundImageView.hidden = NO;
[UIView animateWithDuration:0.10
delay:0.05
options: UIViewAnimationOptionCurveEaseOut
animations:^{
self.imageView.frame = imageRect;
self.filterScrollView.frame = sliderScrollFrame;
self.filtersBackgroundImageView.frame = sliderScrollFrameBackground;
_filterViewBottomConstraint.constant=42;
[self.view layoutIfNeeded];
}
completion:^(BOOL finished){
self.filtersToggleButton.enabled = YES;
Expand All @@ -639,21 +624,12 @@ -(void) showFilters {

-(void) hideFilters {
[self.filtersToggleButton setSelected:NO];
CGRect imageRect = self.imageView.frame;
imageRect.origin.y += 34;
CGRect sliderScrollFrame = self.filterScrollView.frame;
sliderScrollFrame.origin.y += self.filterScrollView.frame.size.height;

CGRect sliderScrollFrameBackground = self.filtersBackgroundImageView.frame;
sliderScrollFrameBackground.origin.y += self.filtersBackgroundImageView.frame.size.height-3;

[UIView animateWithDuration:0.10
delay:0.05
options: UIViewAnimationOptionCurveEaseOut
animations:^{
self.imageView.frame = imageRect;
self.filterScrollView.frame = sliderScrollFrame;
self.filtersBackgroundImageView.frame = sliderScrollFrameBackground;
_filterViewBottomConstraint.constant=-31;
[self.view layoutIfNeeded];
}
completion:^(BOOL finished){

Expand Down
Loading