简体   繁体   中英

How to crop a UIImage by selecting an area

I'm searching for a posibility to crop UIImages. I've found lots of examples via google how to do this, but I want to do a bit more than just croping the image.

It would be nice if the user can choose which area of the UIImage will be crop. In other languages, for example Javascript, there are many plugins to do that. I'm looking to find something like this:

http://odyniec.net/projects/imgareaselect/

Does anybody know if some similar project exists for objective-c? Thank you!

after days of searching I found out that there is no "plugin" which is similar to ImgAreaSelect. :-(

The best thing I found was this: https://github.com/barrettj/BJImageCropper

It wasn't very hard to adapt this project to my needs: now I can choose a proportional area with min size. :-)

You could always make a black&white mask of this area and then mask the image (white area on mask will result in transparent area on masked image).

Link to nice tutorial on how to mask an image .

As an addition you could later calculate the miminum square frame that holds complete masked (cropped) image and crop the result - to get rid of excess transparent areas.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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