UIImage+Resize.h - 为 UIImageOrientationUp 方向给出错误的仿射变换

发布于 2024-09-24 05:46:29 字数 476 浏览 0 评论 0 原文

对于 UIImage 调整大小,我使用了以下类。

http://iphone.svn.wordpress.org/trunk/UIImage+Resize。 m

但我在 iPhone 的某些方向上遇到了问题,即我将手机与垂直表面对齐。它可以正确调整大小,但图像未正确进行仿射变换。图像方向不同。我在“transformForOrientation”方法中记录了消息,该方法调用了 UIImageOrientationUp,但我没有看到对该方向进行任何操作。我相信这就是我得到无效转换的原因。所以我需要帮助来解决这个问题。是否需要添加任何“CGAffineTransformTranslate”或“CGAffineTransformRotate”以获得正确的输出。

请告诉我。

谢谢。

For the UIImage resize I used the following class.

http://iphone.svn.wordpress.org/trunk/UIImage+Resize.m

But I am having issues in some iPhone orientation where I keep the phone in lined with a vertical surface. It does the resize properly but the image is not properly affine transformed. The image orientation is different. I logged the messages in the "transformForOrientation" method where it called the UIImageOrientationUp where I do not see any manipulation done to that orientation. I believe that's the reason for me to get an invalid transformation. So I need a help to fix this issue. Is there any "CGAffineTransformTranslate" or "CGAffineTransformRotate" to add in order to get the correct output.

Please advise me.

Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏有森光若流苏 2024-10-01 05:46:29

UIImage+Resize 方法中的 - (UIImage *)croppedImage:(CGRect)bounds; 方法不考虑图像的方向。

在该方法中,将此行:替换

UIImage *croppedImage = [UIImage imageWithCGImage:imageRef];

为:

UIImage *croppedImage = [UIImage imageWithCGImage:imageRef scale:1.0 orientation:self.imageOrientation];

The - (UIImage *)croppedImage:(CGRect)bounds; method in UIImage+Resize method doesn't take into account the orientation of the image.

Within that method, replace this line:

UIImage *croppedImage = [UIImage imageWithCGImage:imageRef];

with this:

UIImage *croppedImage = [UIImage imageWithCGImage:imageRef scale:1.0 orientation:self.imageOrientation];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文