学习一些常用的混合模式之BlendMode. dst

The source pixels are discarded, leaving the destination intact.

代码

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.dst; // 源颜色:蓝色; // 混合模式
    canvas.drawRect(Rect.fromLTWH(0, 0, width, height), srcPaint);

    canvas.restore();

重叠部分只保留dst的内容,清空所有的src。非重叠部分只保留dst的内容,清空所有的src。所以效果就是图片全部展示,红色矩形全部不显示。

效果图如下:

相关推荐
wxson728214 小时前
【Android视频监控系统技术总结】
android·音视频
GitLqr15 小时前
玩转 Flutter 中的 Stack 与 Positioned:解决 UI 重叠问题的实战指南
flutter·面试·全栈
hunterandroid16 小时前
[Android 从零到一] LiveData 粘性事件与单次消费:从重复触发到可靠事件总线
android
hunterandroid16 小时前
[Android 从零到一] Android 事件分发机制:从 ACTION_DOWN 到 View 事件消费链路
android
阿巴斯甜16 小时前
adb‑shell 全套命令实操总结
android
奔跑的架构师18 小时前
[A-49]ARMv9/v8-PSCI接口规范与工作流程简介
android·linux·arm开发·arm
AFinalStone18 小时前
Android 7系统国际化(七)Resources 与 AssetManager 源码剖析
android·国际化·local
Android-Flutter18 小时前
Android 内存泄漏详解
android·kotlin
catchadmin19 小时前
Fiber 与 PHP 8.6 Polling API 异步初探
android·开发语言·php