我试图在 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?
}