iOS - GPUImage失真

时间:2014-07-02 09:07:40

标签: ios ios7 uiimage gpuimage gpuimagestillcamera

我正在使用GPUImage在相机视图上应用实时过滤器。问题是,一旦我捕获图像,它就会变得像素化 这是我的代码:

在viewDidLoad中:

imageCamera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPresetPhoto cameraPosition:AVCaptureDevicePositionBack];
imageCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
normalImgView = [[GPUImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width, self.view.frame.size.height-100)];
[normalImgView setFillMode:kGPUImageFillModePreserveAspectRatioAndFill];

这就是我拍摄图像的方式:

[imageCamera capturePhotoAsImageProcessedUpToFilter:selectedFilter withCompletionHandler:^(UIImage *processedImage, NSError *error){
    NSLog(@"processedImage %@", processedImage);

    NSData *dataForPNGFile = UIImageJPEGRepresentation(processedImage, 1.0);

    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];

    NSError *error2 = nil;
    if (![dataForPNGFile writeToFile:[documentsDirectory stringByAppendingPathComponent:@"FilteredPhoto.jpg"] options:NSAtomicWrite error:&error2])
    {
        return;
    }

    if (processedImage) {
        //Display it in an image view
    }
}];

我添加了断点来跟踪执行情况,并确定图像在哪个部分确切地像素化。这是GPUImageOutput的imageFromCurrentFramebufferWithOrientation:在这一行:

CGImageRef cgImageFromBytes = [self newCGImageFromCurrentlyProcessedOutput];

newCGImageFromCurrentlyProcessedOutput始终返回nil

- (CGImageRef)newCGImageFromCurrentlyProcessedOutput;
{
    return nil;
}

我该如何解决这个问题?

0 个答案:

没有答案