GPUImage imageFromCurrentFramebuffer有时为GPUImageLookupFilter返回nil及其子类

时间:2014-05-22 09:54:54

标签: ios objective-c gpuimage

我一直在使用GPUImage用于我的项目,我遇到了这个问题,其中imageFromCurrentFramebufferGPUImageLookupFilter's的某些内容返回nil。

我将GPUImageFilterGroup中的GPUImageAmatorkaFilter子类化为-(MTLookupFilter *) initWithLookupImageName:(NSString *) lookupImageName { self = [super init]; if (self) { UIImage *image = [UIImage imageNamed:lookupImageName]; self.lookupImageSource = [[GPUImagePicture alloc] initWithImage:image]; GPUImageLookupFilter *lookupFilter = [[GPUImageLookupFilter alloc] init]; [self addFilter:lookupFilter]; [self.lookupImageSource addTarget:lookupFilter atTextureLocation:1]; [self.lookupImageSource processImage]; self.initialFilters = [NSArray arrayWithObjects:lookupFilter, nil]; self.terminalFilter = lookupFilter; } return self; } 我的代码如下:

- (IBAction)filterAction:(id)sender {
      NSInteger index = arc4random()%self.filtersArray.count;
      id filter = self.filtersArray[index];
      GPUImagePicture *stillImageSource = [[GPUImagePicture alloc] initWithImage:self.fullImage];
      UIImage *filteredimage = nil;
      [stillImageSource addTarget:filter];
      [stillImageSource processImage];
      [filter useNextFrameForImageCapture];
      filteredimage = [filter imageFromCurrentFramebuffer];

      if (filteredimage) {
          self.imageView.image = filteredimage;
      } else {
          NSLog(@"Filtered image is nil");
      }
  }

我将这个类的几个对象添加到数组中并使用:

imageFromCurrentFramebuffer

来自GPUImageAmatorkaFilter的返回图片有时为零,我不明白它的原因。我会感谢任何帮助。有时即使对于过滤器GPUImageSoftEleganceFilter,{{1}}和`GPUImageMissEtikateFilter,图像也是零,所以我知道它对我的子类来说不是问题。

0 个答案:

没有答案