如何调整图像大小?

发布于 2024-07-07 17:20:09 字数 120 浏览 5 评论 0原文

我从 UIImagePickerController 获取了图像,但该文件看起来太大而无法通过互联网传输,我想调整图像大小。 我找不到任何与图像处理相关的方法。

有什么推荐吗?

I have taken an image from UIImagePickerController, but the file looks too big to be transferred through internet, I'd like to resize the image. I couldn't find any method related to the image process.

Any recommendation?

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

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

发布评论

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

评论(1

娇女薄笑 2024-07-14 17:20:09

您可以使用 UIGraphicsBeginImageContext() 创建所需大小的上下文,然后使用 UIImage 的 -drawInRect: 方法将图像绘制到上下文,最后使用 UIGraphicsGetImageFromCurrentImageContext( ) 来拉出一个新的 UIImage。

You could create a context of the desired size using UIGraphicsBeginImageContext(), then draw the image to the context using UIImage's -drawInRect: method, and finally use UIGraphicsGetImageFromCurrentImageContext() to pull a new UIImage back out.

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