gpt4 book ai didi

ios - 是[UIImage imageWithCIImage :scale:orientation] broken on iOS10?

转载 作者:行者123 更新时间:2023-12-02 02:12:43 25 4
gpt4 key购买 nike

以下代码不再适用于 iOS10。图像数据保持不变。

我已确认此代码适用于 iOS 8 和 9。

CIImage *i = [[CIImage alloc] initWithImage:image];
imageView.image = [UIImage imageWithCIImage:i scale:image.scale orientation:UIImageOrientationRight];

有人遇到过同样的问题吗?这是一个错误,还是有意的更改?

最佳答案

我的猜测是 UIImageView 处理图像旋转标志的方式发生了变化。我找不到任何地方提到的更改,但至少下面的代码可以工作。 Taken from here .

- (UIImage*)rotateImage:(UIImage*)sourceImage clockwise:(BOOL)clockwise
{
CGSize size = sourceImage.size;
UIGraphicsBeginImageContext(CGSizeMake(size.height, size.width));
[[UIImage imageWithCGImage:[sourceImage CGImage]
scale:1.0
orientation:clockwise ? UIImageOrientationRight : UIImageOrientationLeft]
drawInRect:CGRectMake(0,0,size.height ,size.width)];

UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

return newImage;
}

关于ios - 是[UIImage imageWithCIImage :scale:orientation] broken on iOS10?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39705993/

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