Crop an Image in irregular shape

纵饮孤独 提交于 2020-01-03 16:59:33

问题


I need to crop an Image in irregular shape my app, i.e., I select a portion by finger and if I click crop button, the selected portion alone in the Image will be saved in SDCard.

How to achieve it?


回答1:


You have to define a Path for the Shape you want to be cut out.
Then create a rectangle around it an set everything between your shape an the rectangle to transparent (Alpha Channel)

This source here should give you some hints:
https://github.com/lvillani/android-cropimage/blob/develop/src/com/android/camera/CropImage.java
Take a look at the onSaveClicked method, line 209




回答2:


Refer this project: https://github.com/coderush/FlexiCrop

It has the code to crop irregular shapes.



来源:https://stackoverflow.com/questions/13671456/crop-an-image-in-irregular-shape

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!