iOS:GPUImage麻烦让ForceProcessingAtSize工作?

时间:2016-08-27 03:40:19

标签: ios objective-c gpuimage avcapturesession

目前我正在使用GPUImage拍摄方形照片。除输出大小外,一切正常。输出为2448 x 2448,但我想将其强制为1080 x 1080。

这是我目前的设置:

//Setup Photo Camera
self.photoCamera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPresetPhoto cameraPosition:AVCaptureDevicePositionBack];
self.photoCamera.outputImageOrientation = UIInterfaceOrientationPortrait;
self.photoCamera.horizontallyMirrorFrontFacingCamera = YES;

//Setup Crop Filter
self.cropFilter = [[GPUImageCropFilter alloc] initWithCropRegion:CroppedCenterRectPhoto];
[self.cropFilter forceProcessingAtSize:CGSizeMake(1080, 1080)];

//Setup CameraView
self.cameraView = [[GPUImageView alloc] init];

//Add Targets
[self.photoCamera addTarget:self.cropFilter];
[self.cropFilter addTarget:self.cameraView];
self.cameraView.fillMode = kGPUImageFillModePreserveAspectRatioAndFill;

我正在使用几个网站上推荐的-(void)forceProcessingAtSize:方法,但它没有做任何事情。我使用不正确吗?

1 个答案:

答案 0 :(得分:0)

尝试替换

self.photoCamera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPresetPhoto cameraPosition:AVCaptureDevicePositionBack];

self.photoCamera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPreset1920x1080 cameraPosition:AVCaptureDevicePositionBack];