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

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

问题描述

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

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 less 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天全站免登陆