在 Landscape 中,如何将 GPUImageView 图像顺时针旋转 90 度?

How do I rotate the GPUImageView image clockwise 90 degrees when in Landscape?

我正在使用 GPUImage 创建一个照片应用程序,有问题的应用程序始终处于横向模式。我想知道如何将显示的图像顺时针旋转 90 度,因为目前它的方向不正确。

我曾尝试更改以下行,但它抛出了裁剪。

 _stillCamera.outputImageOrientation = UIInterfaceOrientationPortrait;

这是我目前使用的代码。

[_stillCamera stopCameraCapture];

if([UIScreen mainScreen].bounds.size.width == 667){

    if(cameraPosition == 1){

        _stillCamera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPreset1920x1080 cameraPosition:AVCaptureDevicePositionBack];

    }else {

        _stillCamera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPreset1920x1080 cameraPosition:AVCaptureDevicePositionFront];

    }

}
else if([UIScreen mainScreen].bounds.size.width == 568){

    if(cameraPosition == 1){

        _stillCamera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPreset1280x720 cameraPosition:AVCaptureDevicePositionBack];

    }else {

        _stillCamera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPreset1280x720 cameraPosition:AVCaptureDevicePositionFront];

    }

} else{

    if(cameraPosition == 1){

        _stillCamera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionBack];

    }else {

        _stillCamera = [[GPUImageStillCamera alloc] initWithSessionPreset:AVCaptureSessionPreset640x480 cameraPosition:AVCaptureDevicePositionFront];

    }

}

_stillCamera.outputImageOrientation = UIInterfaceOrientationPortrait;

_cropFilter = [[GPUImageCropFilter alloc] initWithCropRegion:CGRectMake(0.f, 0.125f, 1.f, .75f)];


self.lookupImageSource = [[GPUImagePicture alloc] initWithImage:[UIImage imageNamed:@"LondonTown2.png"]];
[self.lookupImageSource processImage];

self.filterLookup = [[GPUImageLookupFilter alloc] init];
[self.lookupImageSource addTarget:self.filterLookup atTextureLocation:1];



[_stillCamera addTarget:self.filterLookup];
[self.filterLookup addTarget:_cropFilter];








[_filterViewViewFinder setFillMode:kGPUImageFillModePreserveAspectRatioAndFill];

//[_stillCamera addTarget:_cropFilter];
//[_cropFilter addTarget:_filter];

[_cropFilter addTarget:_filterView];
[_cropFilter addTarget:_filterViewViewFinder];

[_stillCamera startCameraCapture];

您可以通过以下代码旋转 GPUImageView 图片。

[self.filterLookup setInputRotation:kGPUImageRotateRight atIndex:0];

下面是不同的InputRotation模式。

kGPUImageNoRotation, 
kGPUImageRotateLeft, 
kGPUImageRotateRight,
kGPUImageFlipVertical, 
kGPUImageFlipHorizonal,
kGPUImageRotateRightFlipVertical,
kGPUImageRotateRightFlipHorizontal,
kGPUImageRotate180

希望对您有所帮助。