gpt4 book ai didi

上下文中的 iOS 渲染图像在横向方向上无法按预期工作

转载 作者:行者123 更新时间:2023-11-28 22:36:03 25 4
gpt4 key购买 nike

下面的代码似乎可以很好地从视网膜分辨率的 View 中渲染图像。问题是当我的设备处于横向时它似乎不起作用。它返回旋转 90 度的图像。

我是否需要添加图像或上下文方向的选项?

    CGSize panelRect = CGSizeMake(selectedPanelView.frame.size.width, selectedPanelView.frame.size.height);

UIGraphicsBeginImageContextWithOptions(panelRect, 1, 2);

[[selectedPanelView layer] renderInContext:UIGraphicsGetCurrentContext()];
renderedImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

最佳答案

问题似乎可以通过使用:UIImage imageWithCGImage:scale:orientation: 解决,如下所示。

UIImage *renderedImageWithOrientation = [UIImage imageWithCGImage:renderedImage.CGImage scale:1 orientation:0];

我在渲染图像后运行它,然后将图像添加到 imageView。

关于上下文中的 iOS 渲染图像在横向方向上无法按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15997241/

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