gpt4 book ai didi

ios - UIImagePickerController 中的前置摄像头

转载 作者:IT老高 更新时间:2023-10-28 11:27:33 24 4
gpt4 key购买 nike

我正在使用 UIImagePickerController 在 iPad2 中开发前置摄像头应用程序。

当我捕获图像时,它显示为从左到右翻转。

我该如何纠正这个问题?

if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) 
{
UIImagePickerController *imgPkr = [[UIImagePickerController alloc] init];
imgPkr.delegate = self;
imgPkr.sourceType = UIImagePickerControllerSourceTypeCamera;
imgPkr.cameraDevice=UIImagePickerControllerCameraDeviceFront;


UIImageView *anImageView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:[NSString stringWithFormat:@"select%d.png",val]]];
anImageView.frame = CGRectMake(0, 0, anImageView.image.size.width, anImageView.image.size.height);
imgPkr.cameraOverlayView = anImageView;
[theApp.TabViewControllerObject presentModalViewController:imgPkr animated:YES];
[imgPkr release];
}

最佳答案

你可以使用这个从源图像翻转图像

UIImage *flippedImage = [UIImage imageWithCGImage:picture.CGImage scale:picture.scale orientation:UIImageOrientationLeftMirrored];

编辑:添加 swift 代码

let flippedImage = UIImage(CGImage: picture.CGImage, scale: picture.scale, orientation:.LeftMirrored)

关于ios - UIImagePickerController 中的前置摄像头,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9255633/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com