我想在android中实现多点裁剪,如何裁剪路径线内的图像(如图所示的白线)?
我使用的代码是:
private Bitmap image;
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ImageView iv = (ImageView) findViewById(R.id.imageView1);
image = BitmapFactory.decodeResource(getResources(), R.drawable.splash);
Bitmap resultingImage = Bitmap.createBitmap(image.getWidth(),
image.getHeight(), image.getConfig());
Canvas canvas = new Canvas(resultingImage);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setColor(Color.WHITE);
paint.setStyle(Paint.Style.STROKE);
paint.setStrokeJoin(Paint.Join.ROUND);
paint.setStrokeCap(Paint.Cap.ROUND);
paint.setStrokeWidth(3);
Path path = new Path();
path.lineTo(150, 0);
path.lineTo(210, 120);
path.lineTo(150, 240);
path.lineTo(70, 120);
path.lineTo(150, 0);
canvas.drawPath(path, paint);
canvas.drawBitmap(resultingImage, 0, 0, paint);
iv.setImageBitmap(resultingImage);
}
}