我遇到了最新的重构问题。每次我尝试从过滤器中获取已处理的UIImage时,它都是零。我使用过useNextFrameForImageCapture
但它仍然不起作用。
以下是我的代码片段:
self.imageView = [[GPUImageView alloc] initWithFrame:CGRectMake(0,
0,
self.view.frame.size.width,
self.view.frame.size.height)];
staticPicture = [[GPUImagePicture alloc] initWithImage:img
smoothlyScaleOutput:YES];
filter = [[GPUImageToneCurveFilter alloc] initWithACV:@"cool"];
[staticPicture addTarget:filter];
[filter addTarget:self.imageView];
GPUImageRotationMode imageViewRotationMode = kGPUImageNoRotation;
switch (staticPictureOriginalOrientation) {
case UIImageOrientationLeft:
imageViewRotationMode = kGPUImageRotateLeft;
break;
case UIImageOrientationRight:
imageViewRotationMode = kGPUImageRotateRight;
break;
case UIImageOrientationDown:
imageViewRotationMode = kGPUImageRotate180;
break;
default:
imageViewRotationMode = kGPUImageNoRotation;
break;
}
// seems like atIndex is ignored by GPUImageView...
[self.imageView setInputRotation:imageViewRotationMode atIndex:0];
[staticPicture useNextFrameForImageCapture];
[staticPicture processImage];
UIImage *processedImage = [filter imageFromCurrentFramebufferWithOrientation:staticPictureOriginalOrientation];
processedImage总是为零。非常感谢任何帮助!
答案 0 :(得分:0)
@BradLarson回答了我的问题:您需要在要捕获的过滤器上使用-useNextFrameForImageCapture,而不是输入图像。它必须告诉过滤器保持其帧缓冲。在您的情况下,您需要调用[filter useNextFrameForImageCapture]。