ios - 如何在 UIImage (GPUImage) 的不同滤镜之间正确切换

标签 ios objective-c gpuimage

我正在开发一个过滤应用程序,类似于 GPUImage“filterShowCase”项目,但我专注于过滤静态图像(从用户库中选择)。主视图显示图像选择器选择的图像如下:

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];

一切正常,图像以棕褐色过滤。我允许用户根据用户输入更改过滤器,目的是在不同过滤器之间快速切换 - 这一切都在 switch 语句中完成...

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];

这个 (^) 是我正在使用的当前过程,但是在选择过滤器类型和实际修改图像以匹配该过滤器之间有一个很小的时间间隔。

我之前尝试过只是[sourcePicture processImage]但是那没有用(没有改变GPUImageView中的图像),所以我在做什么错误的? - 还是系统的预期性能?

谢谢!

回答 查看 Brad Larsons 对这个问题的评论。

最佳答案

正如 Brad Larson 所写,使用 [filter forceProcessingAtSize] 将减少过滤器的执行时间。

关于ios - 如何在 UIImage (GPUImage) 的不同滤镜之间正确切换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22138140/

相关文章:

ios - 如何以编程方式截取 iPad 主屏幕的屏幕截图?

gpuimage - GPU 图像 - 组合来自两组不同案例的两个 GPUImageFilterGroup

iphone - 将合成(保留)属性设置为 nil 时的 EXC_BAD_ACCESS

objective-c - 具有自动换行的UITextField

aspect-ratio - 使用GPUImage时如何保持宽高比?

ios - GPUImage锁定 View

ios - 约束 - 设计、预览和模拟器/设备之间不一致

ios - 使用 Xcode Beta 6 的 MPMoviePlayerPlaybackDidFinishNotification 架构 arm64 的 undefined symbol

ios - 当我创建 XMLDocument 的自动发布目标时,我的应用程序崩溃了

ios - 有什么方法可以从点击位置获取 cgpoint 而不必使用触摸方法,例如触摸开始或触摸移动?