我正在使用 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
希望这会有所帮助。
关于ios - 在横向时如何将 GPUImageView 图像顺时针旋转 90 度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32457231/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |