Skip to content Skip to sidebar Skip to footer

Select An Area On Bitmap With 4 Points Using Matrix.setpolytopoly

I am playing with bitmap on Android and I am facing an issue when selecting an area on the bitmap using the 4 points. Not all the sets of 4 points work for me. In some cases, the r

Solution 1:

Finally, I solve my issue using OpenCV. Thanks for the answer in this question! It seems that Matrix.setPolyToPoly does not work for all the cases.

Solution 2:

Everything is much simpler..

@OverrideprotectedvoidonDraw(Canvas canvas) {
    super.onDraw(canvas);
    Matrixmatrix=newMatrix();

    matrix.setPolyToPoly(src, 0, dst, 0, 4);
    canvas.setMatrix(matrix);
    canvas.drawBitmap(bit,0,0,null );
}

Solution 3:

The bug you see is not in Matrix.setPolyToPloy but in CPU rasterization. To workaround it, you can simply creating a new transformed Bitmap without using a Canvas, then crop the Bitmap to get desired result.

Post a Comment for "Select An Area On Bitmap With 4 Points Using Matrix.setpolytopoly"