学习一些常用的混合模式之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。所以效果就是图片全部展示,红色矩形全部不显示。

效果图如下:

相关推荐
YUJIANYUE16 分钟前
查立得万用查分安卓版(web环境+查询系统免安装单文件一键运行包)
android·前端
天空之城--1 小时前
Android Launcher 性能优化完全指南:从启动到滑动,构建极致流畅的桌面体验
android·性能优化
hunterandroid1 小时前
Android ANR 排查实战:从线上告警到主线程卡点定位
android·前端
TimeFine2 小时前
智能眼镜开发:图片翻译与EXIF的重要性
android
律宏阔2 小时前
Android 车载蓝牙开发笔记:HFP、A2DP、AVRCP、PBAP、MAP、BLE 与系统 API
android·蓝牙
@Adzc2 小时前
Android 16 省电模式 Tile 点击导致状态栏收起
android
杉氧2 小时前
打破边界(二):在 React Native 中嵌入原生 UI 组件 (Native UI Components)
android·前端·react native
古法安卓2 小时前
Android-切换白天黑夜内存不足问题排查
android·java·android studio
聚美智数2 小时前
快递拦截-物流在途拦截-在途拦截API接口介绍
android
flower_drop3 小时前
从 QtScrcpy 到 TabQA:如何在浏览器侧边栏搞定 Android 投屏与测试提单?
android