0

我试图在 UIViewControler 中设置一个简单的 GPUImage 环境。但是,我得到一个空白屏幕。我想在源图像保持不变的情况下为漩涡滤镜的属性设置动画。我怎样才能做到这一点?

我希望大型图像具有良好的性能(> 30 fps),因此理想情况下希望避免从 GPU 到 CPU 来回不必要的像素复制。

- (void)viewDidLoad
{
    UIImage *inputImage = [UIImage imageNamed:@"image.jpg"];

    self.stillImageSource = [[GPUImagePicture alloc] initWithImage:inputImage];
    self.swirlFilter = [[GPUImageSwirlFilter alloc] init];
    self.swirlFilter.radius = 0.8;

    self.filteredImageView =
    [[GPUImageView alloc] initWithFrame:
        CGRectMake(0.0, 0.0,
                   self.view.frame.size.width,
                   self.view.frame.size.height)];

    [self.view addSubview:self.filteredImageView];

    // GPUImagePicture -> GPUImageFilter -> GPUImageView
    [self.stillImageSource addTarget:self.swirlFilter];
    [self.swirlFilter addTarget:self.filteredImageView];

    NSAssert(inputImage && _stillImageSource && _swirlFilter && _filteredImageView,
             @"Something unexpected is nil");
}

// Set up a the display link in View Did appear     

- (void) displayLinkDidFire:(CADisplayLink*)displayLink
{
    CGFloat proportion =
    [RSHelper proportionForTime:[[NSDate date] timeIntervalSinceReferenceDate]];

    self.swirlFilter.angle = proportion;

    // Do I need to call some kind of update call here?
}
4

1 回答 1

1

好的,我找到了答案 - 我只是错过processImageGPUImagePicture

- (void) displayLinkDidFire:(CADisplayLink*)displayLink
{
    self.swirlFilter.angle = [Helper calcProportion];
    [self.stillImageSource processImage];
}

GPUImage实际上设置起来非常好,而且它看起来比GPUImage 文档CoreImage中所说的要快。在某些苹果的技术上使用 3rd 方库让我很痛苦,但我没有看到任何优势或 CoreImage。

于 2013-07-28T21:24:23.840 回答