How to crop an image in between four points on Android [duplicate]

泄露秘密 提交于 2019-12-01 01:54:02

Here is a solution how to crop image if need a circle. Based on that code, you can play a bit with Graphics and you will be able to crop your shape.

I will not write code ready for copy paste.

I hope it helps!

Edit:

Maybe Here is your solution!

At first select rectangle region with Bitmap.getPixels
Then avaluate lines which bound your shape.
Change evry pixel in pixels[] which is outsidebounds and set it to 0 (or other value, it will be background of image)
And recreate you image from new dataset.

EDIT: try to use clipping technics http://www.zetcode.com/gfx/java2d/clipping/ or http://www.roseindia.net/java/example/java/swing/graphics2D/clip-area.shtml in example rectangle was used but thos methodics allows any region

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