Permalink
Browse files

processImage should be moved to last step

  • Loading branch information...
1 parent 9f85fcb commit fa6c310ede46531e24abbacd238b41410e9bdcd6 Matt Jarjoura committed Jul 22, 2012
Showing with 5 additions and 46 deletions.
  1. +5 −46 FilterKit/FilterKit/FKGPUFilterGroup.m
@@ -12,11 +12,11 @@
#import "GPUImagePicture.h"
#import "GPUImageView.h"
#import "GPUImageRawDataOutput.h"
+#import "GPUImageUIElement.h"
@implementation FKGPUFilterGroup {
@private
NSMutableArray *_gpuFilters;
- GPUImagePicture *_picture;
}
- (id)init
@@ -42,11 +42,10 @@ - (void)addGPUFilter:(GPUImageFilter *)filter
- (UIImage *)imageWithFilterAppliedWithImage:(UIImage *)image
{
- _picture = [[GPUImagePicture alloc] initWithImage:image smoothlyScaleOutput:YES];
- [_picture processImage];
-
- GPUImageOutput *lastFilter = _picture;
+ GPUImagePicture *picture = [[GPUImagePicture alloc] initWithImage:image smoothlyScaleOutput:YES];
+ GPUImageOutput *lastFilter = picture;
GPUImageFilter *filter = nil;
+
NSUInteger count = [_gpuFilters count];
for (NSUInteger i = 0; i < count; i++) {
filter = [_gpuFilters objectAtIndex:i];
@@ -55,48 +54,8 @@ - (UIImage *)imageWithFilterAppliedWithImage:(UIImage *)image
[lastFilter addTarget:filter];
lastFilter = filter;
}
+ [picture processImage];
return lastFilter.imageFromCurrentlyProcessedOutput;
}
-
-//- (UIImage *)imageWithFilterAppliedWithImage:(UIImage *)image
-//{
-// GPUImageView *view = [[GPUImageView alloc] initWithFrame:CGRectMake(0, 0, image.size.width, image.size.height)];
-//
-// // GPUImageRawDataOutput *raw = [[GPUImageRawDataOutput alloc] initWithImageSize:image.size resultsInBGRAFormat:YES];
-//
-// _picture = [[GPUImagePicture alloc] initWithImage:image smoothlyScaleOutput:YES];
-// GPUImageOutput *lastFilter = view;
-// GPUImageFilter *filter = nil;
-// NSUInteger count = [_gpuFilters count];
-// for (NSUInteger i = 0; i < count; i++) {
-// filter = [_gpuFilters objectAtIndex:i];
-//
-// //[lastFilter removeAllTargets];
-// [filter addTarget:lastFilter];
-// //[lastFilter addTarget:filter];
-// lastFilter = filter;
-// }
-//
-// [_picture addTarget:lastFilter];
-//
-// if ([lastFilter respondsToSelector:@selector(processImage)]) {
-// [(GPUImagePicture *)lastFilter processImage];
-// }
-//
-// // [lastFilter addTarget:raw];
-//
-// // NSData *bytes = [NSData dataWithBytes:[raw rawBytesForImage] length:(image.size.width * image.size.height * 4 * sizeof(GLubyte))];
-// //UIImage *imageFromBytes = [UIImage imageWithData:bytes];
-// //return filter.imageFromCurrentlyProcessedOutput;
-//
-// UIImage *result;
-// UIGraphicsBeginImageContextWithOptions(image.size, NO, [UIScreen mainScreen].scale);
-// [view.layer renderInContext:UIGraphicsGetCurrentContext()];
-// result = UIGraphicsGetImageFromCurrentImageContext();
-// UIGraphicsEndImageContext();
-//
-// return result;
-//}
-
@end

0 comments on commit fa6c310

Please sign in to comment.