简体   繁体   English

如何在iOS中裁剪非矩形区域

[英]How to crop a non-rectangular region in iOS

I am building a photo sharing app for iOS 5 and I'd like to enable users to trace around some portion of an image and then crop out that selected region. 我正在为iOS 5开发一个照片共享应用,我希望使用户能够跟踪图像的某些部分,然后裁剪出所选区域。 I've looked all around for how to do this, and everyone seems to assume you are trying to crop out rectangular areas. 我到处都在寻找如何执行此操作的方法,每个人似乎都认为您正在尝试裁剪矩形区域。 Is there a way to do it for a non-rectangular area? 有没有办法针对非矩形区域呢?

This answer shows how to copy an image using a path. 此答案显示了如何使用路径复制图像。 The answer adds a rectangle to the path, so you would instead add all of the line segments traced out by the user to your path. 答案会在路径上添加一个矩形,因此您应该将用户追踪到的所有线段添加到路径中。

I made this cropping tool which fits your need. 我制作了适合您需求的裁剪工具。 It gives the user control on the area to crop. 它使用户可以控制要种植的区域。

https://github.com/nicholjs/BFCropInterface https://github.com/nicholjs/BFCropInterface

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM