我对GPU Image Framework的用户非常陌生。在我的应用程序中,我使用以下代码来获取图像在bundle(knee.png)中的滤镜效果,但我只得到Black ImageView。我从这个link
获取代码告诉我哪里出错了
UIImage *inputImage = [UIImage imageNamed:@"knee.png"];
GPUImagePicture *stillImageSource = [[GPUImagePicture alloc] initWithImage:inputImage];
GPUImageSepiaFilter *stillImageFilter = [[GPUImageSepiaFilter alloc] init];
[stillImageSource addTarget:stillImageFilter];
[stillImageSource processImage];
UIImage *quickFilteredImage = [stillImageFilter imageByFilteringImage:inputImage];
[self.imgView setImage:quickFilteredImage];
答案 0 :(得分:1)
您在代码示例中混合了两种完成相同操作的方法。尝试这是过滤图像的最简单方法:
UIImage *inputImage = [UIImage imageNamed:@"knee.png"];
GPUImageSepiaFilter *stillImageFilter = [[GPUImageSepiaFilter alloc] init];
UIImage *quickFilteredImage = [stillImageFilter imageByFilteringImage:inputImage];
[self.imgView setImage:quickFilteredImage];
或更长,更灵活的流程,这样可以更轻松地链接多个过滤器:
UIImage *inputImage = [UIImage imageNamed:@"knee.png"];
GPUImagePicture *stillImageSource = [[GPUImagePicture alloc] initWithImage:inputImage];
GPUImageSepiaFilter *stillImageFilter = [[GPUImageSepiaFilter alloc] init];
[stillImageSource addTarget:stillImageFilter];
[stillImageSource processImage];
UIImage *quickFilteredImage = [stillImageFilter imageFromCurrentlyProcessedOutput];
[self.imgView setImage:quickFilteredImage];
看起来您的原始代码应该会生成图像。要调试我检查输入图像(并将其添加到您的问题中),在过滤前将其显示在另一个视图中,查看GPUImageView以显示stillImageSource,并在写入另一个UIImage之前作为过滤器的目标。