As Brad Larson wrote, using the [filter forceProcessingAtSize] will reduce the execution time of the filters.
比如拉尔森写道,使用[过滤forceprocessingatsize ]将减少过滤器的执行时间。
答案 (Answer) 2
I have an app that sort of does the same, and what I do is that I keep my baseImage at hand, and once I am done applying the filter and showing the image with filter I reset everything. The moment a user selects a different filter I use the baseImage again to create the new filtered image and show it.
So in this example you could for example move the [sourcePicture removeAllTargets]; to right after this [self.view addSubview:filterView];
That saves you work when you want to apply a new filter. Also, there is a quicker (dirtier way to filter a picture when you are working with an image that already exists. I got this from the documentation that came with GPUImage and it works like a charm.
GPUImageSketchFilter *stillImageFilter2 = [[GPUImageSketchFilter alloc] init];
tmp = [stillImageFilter2 imageByFilteringImage:[self baseImage]];
[self.imageView setImage: tmp];
tmp = nil;
Hope it helps you on your way.
我有一个应用程序,这样做同样的,和我所做的是,我把我的baseimage在手,又一次我做了应用过滤器和显示图像的滤波重置一切。当用户选择不同的滤波器,我用baseimage再次创造了新的图像滤波,显示它。
所以在这个例子中,例如你可以把[ sourcepicture removealltargets ];这[ self.view addsubview后右:filterview ];
保存你的时候你要申请一个新的过滤器的工作。同时,有一个更快的(脏的方式过滤的图片时,你是一个图像,已经存在的工作。我从来gpuimage文件和它的工作就像一个魅力。
GPUImageSketchFilter *stillImageFilter2 = [[GPUImageSketchFilter alloc] init];
tmp = [stillImageFilter2 imageByFilteringImage:[self baseImage]];
[self.imageView setImage: tmp];
tmp = nil;
希望它能帮助你对你的方式。
答案 (Answer) 3
Use this method for switch filtering , just pass your filter name string in Method
-(void)filterImage:(NSString *)aStrFilterOption {
CIImage *_inputImage = [CIImage imageWithCGImage:[imgOriginal CGImage]];
CIFilter *filter = [CIFilter filterWithName:aStrFilterOption];
[filter setValue:_inputImage forKey:kCIInputImageKey];
CGImageRef moi3 = [[CIContext contextWithOptions:nil]
createCGImage:filter.outputImage
fromRect:_inputImage.extent];
imgView.image = [UIImage imageWithCGImage:moi3];
CFRelease(moi3);
}
用这种方法开关滤波,只是通过你的过滤器中的名称字符串的方法
-(void)filterImage:(NSString *)aStrFilterOption {
CIImage *_inputImage = [CIImage imageWithCGImage:[imgOriginal CGImage]];
CIFilter *filter = [CIFilter filterWithName:aStrFilterOption];
[filter setValue:_inputImage forKey:kCIInputImageKey];
CGImageRef moi3 = [[CIContext contextWithOptions:nil]
createCGImage:filter.outputImage
fromRect:_inputImage.extent];
imgView.image = [UIImage imageWithCGImage:moi3];
CFRelease(moi3);
}