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

限于喜欢 提交于 2019-11-30 20:58:54

问题


Am new to work on bitmaps in android, and am unable to crop the image between four point ( clearly its not a rectangle in shape).

I convert the image into bitmap and set as background to layout. now i have four different points(p0,p1,p2,p3)

I have the values of these points . Now its time to crop the image between these region and show as rectangle shaped bitmap..(ie, as background to another layout.).

Am again mention clearly ,, crop the image between only these points.. ie, inside the region only. Which way i can solve this problem,? can i use any third-party tool.. the suggest me which those ones.........

Thanks to @all


回答1:


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!




回答2:


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



来源:https://stackoverflow.com/questions/17721111/how-to-crop-an-image-in-between-four-points-on-android

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