Keeps the destination pixels that cover source pixels, discards the remaining source and destination pixels
公式:

代码:
js
canvas.saveLayer(Rect.fromLTWH(0, 0, width, height), Paint());
Paint dstPaint = Paint()..color = Colors.red;
dstPaint.style = ui.PaintingStyle.fill;
canvas.drawImageRect(image1!, Rect.fromLTWH(0, 0, image!.width.toDouble(), image!.height.toDouble()), Rect.fromLTWH(0, 0, width/2, height/2), dstPaint);
var srcPaint = Paint()
..color = Colors.red
..blendMode = ui.BlendMode.dstIn; // 源颜色:蓝色; // 混合模式
canvas.drawRect(Rect.fromLTWH(0, 0, width, height).deflate(30), srcPaint);
canvas.restore();
效果图:

可以看到重合部分保留了dst,非重合部分dst保留,src全部清空。