Facebook Graph API - 图像方向错误

发布于 2024-12-14 01:12:21 字数 1177 浏览 3 评论 0原文

我将应用程序的方向修复为仅横向。

这就是我获取屏幕截图的方式。

UIImage *img = UIGraphicsGetImageFromCurrentImageContext();

来更改方向

UIImage * landscapeImage = [[UIImage alloc] initWithCGImage: img.CGImage scale: 1.0 orientation: UIImageOrientationRight];

我通过使用 fb iOS SDK 将屏幕截图发布到 facebook

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               landscapeImage, @"picture",
                               SOME_URL,@"link",
                               @"Have fun",@"name",
                               @"Join the fun",@"message",
                               @"0",@"position",
                               nil];
[_facebook requestWithGraphPath:@"me/photos"
                                andParams:params
                            andHttpMethod:@"POST"
                              andDelegate:self];

。问题是我无法控制方向,上传图像的方向始终是或者

-----
|   |
| P |
-----

-----
|   |
| q |
-----

但我希望图像水平放置(横向)。

-------
|      |  
-------

提前致谢!

I fix my app's orientation to be landscape only.

This is how I get the screenshot.

UIImage *img = UIGraphicsGetImageFromCurrentImageContext();

and I change the orientation through

UIImage * landscapeImage = [[UIImage alloc] initWithCGImage: img.CGImage scale: 1.0 orientation: UIImageOrientationRight];

I use fb iOS SDK to post the screenshot to facebook.

NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               landscapeImage, @"picture",
                               SOME_URL,@"link",
                               @"Have fun",@"name",
                               @"Join the fun",@"message",
                               @"0",@"position",
                               nil];
[_facebook requestWithGraphPath:@"me/photos"
                                andParams:params
                            andHttpMethod:@"POST"
                              andDelegate:self];

The problem is that I cannot control the orientation and the orientation of the uploaded images are always either

-----
|   |
| P |
-----

or

-----
|   |
| q |
-----

but i want the image to laid horizontally(landscape).

-------
|      |  
-------

thanks in advance!

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

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

发布评论

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

评论(1

烦人精 2024-12-21 01:12:21
 UIGraphicsBeginImageContext(CGSizeMake(1024, 768));
        [rotateImg drawInRect:CGRectMake(0, 0, 1024, 768)];
        UIImage *landscapeImage = [UIGraphicsGetImageFromCurrentImageContext() retain];
        UIGraphicsEndImageContext();

这是解决问题的方法。

UIimages的方向仅适用于“DISPLAY”,您需要重新绘制图像

 UIGraphicsBeginImageContext(CGSizeMake(1024, 768));
        [rotateImg drawInRect:CGRectMake(0, 0, 1024, 768)];
        UIImage *landscapeImage = [UIGraphicsGetImageFromCurrentImageContext() retain];
        UIGraphicsEndImageContext();

here is how to resolve the problem.

UIimages's orientation is for "DISPLAY" only, you need to redraw the image

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文