我正在使用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];
答案 0 :(得分:2)
您可以通过以下代码旋转GPUImageView
图片。
[self.filterLookup setInputRotation:kGPUImageRotateRight atIndex:0];
下面有不同的InputRotation
模式。
kGPUImageNoRotation,
kGPUImageRotateLeft,
kGPUImageRotateRight,
kGPUImageFlipVertical,
kGPUImageFlipHorizonal,
kGPUImageRotateRightFlipVertical,
kGPUImageRotateRightFlipHorizontal,
kGPUImageRotate180
希望这有帮助。