I am implementing the freehand cropping on the image in android. I am able to draw the arbitrary shape on the image using touch and collect all the points on the path in the array list. But I am not able to extract the part of image inside the arbitrary shape.
I searched quite a lot but was not able to find the appropriate answer. Does any body have a working example of this.
EDIT: I am able to create a arbitrary shape using the below code on the bitmap.
@Override
protected void onDraw(Canvas canvas) {
canvas.drawBitmap(scaledBitmap, 0, 0,null);
path.reset();
boolean firstTouchPoint = true;
for (int i = 0; i < lastPath.size(); i += 2) {
Point point = lastPath.get(i);
if (firstTouchPoint) {
firstTouchPoint = false;
path.moveTo(point.fXPosition, point.fYPosition);
} else if (i < lastPath.size() - 1) {
Point next = lastPath.get(i + 1);
path.quadTo(point.fXPosition, point.fYPosition, next.fXPosition, next.fYPosition);
} else {
path.lineTo(point.fXPosition, point.fYPosition);
}
}
canvas.drawPath(path, paint);
}
but I am not able to extract the bitmap region inside this path.