Instagram iOS挂钩与非方形图像

Instagram iOS挂钩与非方形图像,第1张

概述现在Instagram应用程序可以处理和发布该应用程序内的非方形图像,我希望我可以使用我一直在使用的相同提供的iPhone挂钩从我的应用程序向Instagram应用程序发送非方形图像( https://instagram.com/developer/iphone-hooks/?hl=en) .然而,它仍然似乎是将我的图像裁剪成方形,而不是让我选择将它们扩展到非方形尺寸(不像我从Instagram应 现在Instagram应用程序可以处理和发布该应用程序内的非方形图像,我希望我可以使用我一直在使用的相同提供的iPhone挂钩从我的应用程序向Instagram应用程序发送非方形图像( https://instagram.com/developer/iphone-hooks/?hl=en) .然而,它仍然似乎是将我的图像裁剪成方形,而不是让我选择将它们扩展到非方形尺寸(不像我从Instagram应用程序直接在图库中加载非方形照片时它让我将其扩展到非方形原始尺寸).任何人都有运气发送非方形图像?我希望有一些调整可以使它工作.解决方法 我也希望他们会在更新时拍摄非方形照片,但你仍然坚持使用旧的解决方案发布非方形照片……将它们变成白色方形.

https://github.com/ShareKit/ShareKit/blob/master/Classes/ShareKit/Sharers/Services/Instagram/SHKInstagram.m

- (UIImage *)imageByScalingImage:(UIImage*)image proportionallyToSize:(CGSize)targetSize {UIImage *sourceImage = image;UIImage *newImage = nil;CGSize imageSize = sourceImage.size;CGfloat wIDth = imageSize.wIDth;CGfloat height = imageSize.height;CGfloat targetWIDth = targetSize.wIDth;CGfloat targetHeight = targetSize.height;CGfloat scaleFactor = 0.0;CGfloat scaleDWIDth = targetWIDth;CGfloat scaledHeight = targetHeight;CGPoint thumbnailPoint = CGPointMake(0.0,0.0);if (CGSizeEqualToSize(imageSize,targetSize) == NO) {    CGfloat wIDthFactor = targetWIDth / wIDth;    CGfloat heightFactor = targetHeight / height;    if (wIDthFactor < heightFactor)        scaleFactor = wIDthFactor;    else        scaleFactor = heightFactor;    scaleDWIDth  = wIDth * scaleFactor;    scaledHeight = height * scaleFactor;    // center the image    if (wIDthFactor < heightFactor) {        thumbnailPoint.y = (targetHeight - scaledHeight) * 0.5;    } else if (wIDthFactor > heightFactor) {        thumbnailPoint.x = (targetWIDth - scaleDWIDth) * 0.5;    }}// this is actually the interesting part:UIGraphicsBeginImageContext(targetSize);[(UIcolor*)SHKCONfig(instagramLetterBoxcolor) set];CGContextFillRect(UIGraphicsGetCurrentContext(),CGRectMake(0,targetSize.wIDth,targetSize.height));CGRect thumbnailRect = CGRectZero;thumbnailRect.origin = thumbnailPoint;thumbnailRect.size.wIDth  = scaleDWIDth;thumbnailRect.size.height = scaledHeight;[sourceImage drawInRect:thumbnailRect];newImage = UIGraphicsGetimageFromCurrentimageContext();UIGraphicsEndImageContext();if(newImage == nil) NSLog(@"Could not scale image");return newImage ;

}

总结

以上是内存溢出为你收集整理的Instagram iOS挂钩与非方形图像全部内容,希望文章能够帮你解决Instagram iOS挂钩与非方形图像所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1099942.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-28
下一篇 2022-05-28

发表评论

登录后才能评论

评论列表(0条)

保存