Skip to content

Instantly share code, notes, and snippets.

@mutablestudio
Created September 24, 2014 23:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mutablestudio/ec8c2576289e869f0be8 to your computer and use it in GitHub Desktop.
Save mutablestudio/ec8c2576289e869f0be8 to your computer and use it in GitHub Desktop.
/*
* 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