gpt4 book ai didi

ios - didFinishPickingMediaWithInfo 方向问题

转载 作者:行者123 更新时间:2023-11-29 03:56:35 25 4
gpt4 key购买 nike

我正在尝试在imagePickerController:didFinishPickingMediaWithInfo中管理图像旋转,但经过多次尝试,我没有找到任何解决方案。我最后的尝试是:

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

// load the storyboard by name
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:[ApplicationSupport getStoryBoardName] bundle:nil];
UploadViewController *uploadView = [storyboard instantiateViewControllerWithIdentifier:@"ViewUploadFile"];

UIImage *image = [info valueForKey:UIImagePickerControllerOriginalImage];
NSDictionary *metadataImage = [info valueForKey:UIImagePickerControllerMediaMetadata];

uploadView.imageToUpload = image;

if([[metadataImage objectForKey:@"Orientation"] intValue] == 3) {
UIImage *imageRotated = [UIImage imageWithCGImage:[image CGImage] scale:[image scale] orientation:UIImageOrientationDown];
uploadView.dataToUpload = UIImagePNGRepresentation(imageRotated);
} else {
uploadView.dataToUpload = UIImagePNGRepresentation(image);
}

// ETC...
}

我不能也不想使用 JPEGRepresentation。当 iPad 处于特定位置时,我需要将照片旋转 180°。

有什么想法吗?

最佳答案

看看这个:http://www.catamount.com/blog/1015/uiimage-extensions-for-cutting-scaling-and-rotating-uiimages/

只要打电话

UIImage *rotatedImage = [originalImage imageRotatedByDegrees:180.0];

Source

关于ios - didFinishPickingMediaWithInfo 方向问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16413833/

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