Created
September 24, 2014 23:32
-
-
Save mutablestudio/ec8c2576289e869f0be8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/* | |
* This is a GPUImageFilter Factory concept, essentially to reuse common GPUImage code that's | |
* required for most GPUImageFilter calls. Access to these methods then becomes a one liner... | |
* | |
* Be sure to wrap each new Class method you create with @autoreleasepool for improved performance. | |
* | |
*/ | |
#import "GPUImage.h" | |
#import "mach/mach.h" | |
@interface MUTDefectImageFactory : NSObject | |
@end | |
@implementation MUTDefectImageFactory | |
+ (UIImage *)finalImageWithGPUImagePicture:(GPUImageFilter *)filtr | |
image:(UIImage *)img | |
{ | |
GPUImagePicture *gpuImage = [[GPUImagePicture alloc] initWithImage:img]; | |
[gpuImage addTarget:filtr]; | |
[filtr prepareForImageCapture]; | |
[gpuImage processImage]; | |
UIImage *newImg = [filtr imageFromCurrentlyProcessedOutputWithOrientation:img.imageOrientation]; | |
return newImg; | |
} | |
+ (UIImage *)swirl:(CGPoint)pnt angle:(double)angl radius:(double)rad image:(UIImage *)img | |
{ | |
@autoreleasepool { | |
GPUImageSwirlFilter *stillImageFilter = [[GPUImageSwirlFilter alloc] init]; | |
[stillImageFilter setCenter:pnt]; | |
[stillImageFilter setRadius:rad]; | |
[stillImageFilter setAngle:angl]; | |
UIImage *newImg = [MUTDefectImageFactory finalImageWithGPUImagePicture:stillImageFilter image:img]; | |
stillImageFilter = nil; | |
return newImg; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment