gpt4 book ai didi

ios - Objective-C:如何在锁定人像方向锁定后拍摄后固定图像方向

转载 作者:行者123 更新时间:2023-12-01 18:41:04 27 4
gpt4 key购买 nike

当我从相机横向拍摄照片时(右侧),图像仍为纵向。我想以从人像锁定状态下从相机拍摄的方向旋转图像。如何才能做到这一点?

最佳答案

在保存或显示图像之前,请尝试以下代码。

    - (UIImage*) rotateImage:(UIImage* )originalImage {

UIImageOrientation orientation = originalImage.imageOrientation;

UIGraphicsBeginImageContext(originalImage.size);

[originalImage drawAtPoint:CGPointMake(0, 0)];
CGContextRef context = UIGraphicsGetCurrentContext();

if (orientation == UIImageOrientationRight) {
CGContextRotateCTM (context, [self radians:90]);
} else if (orientation == UIImageOrientationLeft) {
CGContextRotateCTM (context, [self radians:90]);
} else if (orientation == UIImageOrientationDown) {
// NOTHING
} else if (orientation == UIImageOrientationUp) {
CGContextRotateCTM (context, [self radians:0]);
}

return UIGraphicsGetImageFromCurrentImageContext();}

- (CGFloat) radians:(int)degree {
return (degree/180)*(22/7);
}

关于ios - Objective-C:如何在锁定人像方向锁定后拍摄后固定图像方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43044190/

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