I am working on a filtering application, similar to the GPUImage "filterShowCase" project, but am focusing on filtering static images (selected from the user's library). The main view displays the image selected by the imagepicker as follows:
sourcePicture = [[GPUImagePicture alloc] initWithImage:sourceImage smoothlyScaleOutput:YES];
filter = [[GPUImageSepiaFilter alloc] init];
filterView = [[GPUImageView alloc]initWithFrame:self.view.frame];
filterView.contentMode = UIViewContentModeScaleAspectFit;
filterView.clipsToBounds = YES;
//Setup targets
[sourcePicture addTarget:filter];
[filter addTarget:filterView];
[sourcePicture processImage];
[self.view addSubview:filterView];
This all works, and the image is filtered in sepia. I am allowing a user to change filters based on user input, in aim for quick alternation between different filters - this is all done in a switch statement...
switch (filterNumber)
{
case GPUIMAGE_SEPIA:
{
self.title = @"Sepia Tone";
filter = [[GPUImageSepiaFilter alloc] init];
}; break;
//a bunch of other filters...
}
[sourcePicture removeAllTargets];
[sourcePicture addTarget:filter];
[filter addTarget:filterView];
[sourcePicture processImage];
This (^) is the current process I am using, but there is a small time interval between the filter type selection and the actual modification of the image to match that filter.
I previously tried just doing [sourcePicture processImage]
but that didn't work (didn't change the image in the GPUImageView), so what am i doing something wrong? - or is the intended performance of the system?
Thanks!
ANSWER Look at Brad Larsons' comment to this question.
As Brad Larson wrote, using the [filter forceProcessingAtSize] will reduce the execution time of the filters.