废话不说多说先上码:
public class CutoutView extends ImageView {
private Paint mPaint;
private Path path;
private float startX, startY, stopX, stopY;
private Bitmap maskBitmap;
private List<PointF> pointFList;
private Matrix mMatrix = new Matrix();
private float[] points;
public CutoutView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
initPaint();
initPath();
pointFList = new ArrayList<>();
this.setLayerType(LAYER_TYPE_SOFTWARE, mPaint);
}
public CutoutView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
}
public CutoutView(Context context) {
this(context, null);
}
@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.setDrawFilter(new PaintFlagsDrawFilter(0, Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG));
canvas.