如何使用 Swift 选择图像的一部分、裁剪并保存? [英] How to select a portion of an image, crop, and save it using Swift?

查看:37
本文介绍了如何使用 Swift 选择图像的一部分、裁剪并保存?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 Swift 创建一个 iOS 应用程序来捕获图像并让用户保存图像的选定部分.在许多基于 cam 的应用程序中,我注意到提供了一个矩形框架让用户选择所需的部分.这涉及滑动矩形的边缘或移动角以适应所需区域.

I am trying to create an iOS app using Swift to capture images and let the user save a selected portion of the image. In many cam based apps, I noticed that a rectangular frame is offered to let the users choose the desired portion. This involves either sliding the edges of the rectangle or moving the corners to fit the required area.

能否请您指导我如何实现那个可移动的矩形以及如何只保存那部分图像?

Could you please guide me on how to implement that moveable rectangle and how to save only that piece of the image?

推荐答案

又找到了一个解决方案.这次是在 Swift 中.该解决方案看起来很优雅,并且相对于其他此类解决方案的代码编写的行数更少.

Found one more solution. This time it is in Swift. The solution looks elegant and the code relative to other such solutions is written in fewer number of lines.

这里..https://github.com/DuncanMC/CropImg感谢 Duncan Champney 在 github 上提供他的工作.

Here it is.. https://github.com/DuncanMC/CropImg Thanks to Duncan Champney for making his work available on github.

这篇关于如何使用 Swift 选择图像的一部分、裁剪并保存?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆