gpt4 book ai didi

ios - 从 url objective-c 调整图像大小

转载 作者:行者123 更新时间:2023-12-01 17:30:44 36 4
gpt4 key购买 nike

我从一个网址返回一张图片

 NSData *imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:Result]];

我把它存储到谷歌地图标记我想把它调整到一半大小

最佳答案

试试下面的代码:

UIImage *actualImage = [UIImage imageWithData:imageData];
UIGraphicsBeginImageContext(CGSizeMake(actualImage.size.width/2, actualImage.size.height/2);
[actualImage drawInRect:CGRectMake(0,0,actualImage.size.width/2, actualImage.size.height/2)];
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *smallData = UIImagePNGRepresentation(newImage);

关于ios - 从 url objective-c 调整图像大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23909055/

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