Note that there are some explanatory texts on larger screens.

plurals
  1. POCrop image by polygon area
    primarykey
    data
    text
    <p>I want to crop image by polygon area, but couldn`t find any library, which can make it. OpenCV is too big for this small thing. JJIL [<a href="https://code.google.com/p/jjil/" rel="nofollow noreferrer">enter link description here</a>] crop just rectangle area. Maybe you have any ideas how i can achieve it? Thanks for help!</p> <p><img src="https://i.stack.imgur.com/Ty1zh.jpg" alt="enter image description here"> <img src="https://i.stack.imgur.com/RPuMU.jpg" alt="enter image description here"></p> <p>FOR Nidhi: Try something like this, if doesnot work - create another canvas for path, and than get Bitmap from it (for mask), and apply this mask bitmap to your initial canvas instead drawPath.</p> <pre><code>Bitmap obmp = BitmapFactory.decodeResource(getResources(), R.drawable.image1); Bitmap resultImg = Bitmap.createBitmap(obmp.getWidth(), obmp.getHeight(), Bitmap.Config.ARGB_8888); Bitmap maskImg = Bitmap.createBitmap(obmp.getWidth(), obmp.getHeight(), Bitmap.Config.ARGB_8888); Canvas mCanvas = new Canvas(resultImg); Canvas maskCanvas = new Canvas(maskImg); Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG); paint.setAntiAlias(true); paint.setStyle(Paint.Style.FILL);; paint.setXfermode(new PorterDuffXfermode(Mode.DST_IN)); Path path = new Path(); path.moveTo(view.mx,view.my); path.lineTo(view.x1,view.y1); path.lineTo(view.x2,view.y2 ); path.lineTo(view.x3,view.y3); path.lineTo(view.x4,view.y4); path.close(); maskCanvas.drawPath(path, paint); mCanvas.drawBitmap(obmp, 0, 0, null); mCanvas.drawBitmap(maskImg, 0, 0, paint); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload