ImageView tint 属性及PorterDuff.Mode

概念

偶然机会要给一个图片添加一个蒙层,半透明-淡淡的雾状效果。于是用到setColorFilter,这个颜色过滤器使用到了android.graphics.PorterDuff.Mode ,于是去官网看下具体使用。很多文章把tint解释为着色。

  • Tint: 着色,就是当前设置的颜色和原目标关联,形成最终的UI效果。
  • Mode:原数据和目标数据它们之间处于什么样的关系。
  String tint = ”#44ffffff“;
  img.setColorFilter(Color.parseColor(tint) );

图解

蓝色是原图片,红色目标图片
sourceImg destinationImg

1. add

Adds the source pixels to the destination pixels and saturates the result.
添加原数据到目标数据,且重叠部分饱和颜色、
add

2. clear

Destination pixels covered by the source are cleared to 0.
清除所有
在这里插入图片描述

2. DARKEN

Retains the smallest component of the source and destination pixels.
保留两者最小的颜色分量
在这里插入图片描述

2. DST

The source pixels are discarded, leaving the destination intact.
保留目标像素
在这里插入图片描述

2. DST_ATOP

Discards the destination pixels that are not covered by source pixels.
丢失没有被原数据覆盖的部分像素
在这里插入图片描述

2.DST_IN

Keeps the destination pixels that cover source pixels, discards the remaining source and destination pixels.
保留覆盖原数据的目标像素,丢弃其他。
在这里插入图片描述

2. DST_OUT

Keeps the destination pixels that are not covered by source pixels.
保留没有被原数据覆盖的像素

在这里插入图片描述

2. DST_OVER

The source pixels are drawn behind the destination pixels.
原数据在目标数据后面
在这里插入图片描述

2. LIGHTEN

Retains the largest component of the source and destination pixel.
保留两者最大的颜色分量
在这里插入图片描述

2. MULTIPLY

Multiplies the source and destination pixels.
混合重叠像素
在这里插入图片描述

2. OVERLAY

Multiplies or screens the source and destination depending on the destination color.
混合两种
在这里插入图片描述

2. SCREEN

Adds the source and destination pixels, then subtracts the source pixels multiplied by the destination.
在这里插入图片描述

2. SRC

The source pixels replace the destination pixels.

在这里插入图片描述

2. SRC_ATOP

Discards the source pixels that do not cover destination pixels.
在这里插入图片描述

2. SRC_IN

Keeps the source pixels that cover the destination pixels, discards the remaining source and destination pixels.
在这里插入图片描述

2. SRC_OUT

Keeps the source pixels that do not cover destination pixels.
在这里插入图片描述

2. SRC_OVER

The source pixels are drawn over the destination pixels.
在这里插入图片描述

2. XOR

Discards the source and destination pixels where source pixels cover destination pixels.
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值