Android 12 Developer Preview is here! Try it out, and give us your feedback!

BlendModeCompat

class BlendModeCompat
kotlin.Any
   ↳ kotlin.Enum<androidx.core.graphics.BlendModeCompat>
   ↳ androidx.core.graphics.BlendModeCompat

Compat version of android.graphics.BlendMode, usages of BlendModeCompat will map to android.graphics.PorterDuff.Mode wherever possible

Summary

Enum values

Destination pixels covered by the source are cleared to 0.

Replaces hue and saturation of destination with hue and saturation of source, leaving luminosity unchanged.

Makes destination darker to reflect source.

Makes destination brighter to reflect source.

Retains the smallest component of the source and destination pixels.

Subtracts darker from lighter with higher contrast.

The source pixels are discarded, leaving the destination intact.

Discards the destination pixels that are not covered by source pixels.

Keeps the destination pixels that cover source pixels, discards the remaining source and destination pixels.

Keeps the destination pixels that are not covered by source pixels.

The source pixels are drawn behind the destination pixels.

Subtracts darker from lighter with lower contrast.

Makes destination lighter or darker, depending on source.

Replaces hue of destination with hue of source, leaving saturation and luminosity unchanged.

Retains the largest component of the source and destination pixel.

Replaces luminosity of destination with luminosity of source, leaving hue and saturation unchanged.

Multiplies the source and destination pixels.

Multiplies the source and destination pixels.

Multiplies or screens the source and destination depending on the destination color.

Adds the source pixels to the destination pixels and saturates the result.

Replaces saturation of destination saturation hue of source, leaving hue and luminosity unchanged.

Adds the source and destination pixels, then subtracts the source pixels multiplied by the destination.

Makes destination lighter or darker, depending on source.

The source pixels replace the destination pixels.

Discards the source pixels that do not cover destination pixels.

Keeps the source pixels that cover the destination pixels, discards the remaining source and destination pixels.

Keeps the source pixels that do not cover destination pixels.

The source pixels are drawn over the destination pixels.

Discards the source and destination pixels where source pixels cover destination pixels.

Enum values

CLEAR

enum val CLEAR : BlendModeCompat

Destination pixels covered by the source are cleared to 0.

\(\alpha_{out} = 0\)

\(C_{out} = 0\)

COLOR

@RequiresApi(29) enum val COLOR : BlendModeCompat

Replaces hue and saturation of destination with hue and saturation of source, leaving luminosity unchanged.

COLOR_BURN

@RequiresApi(29) enum val COLOR_BURN : BlendModeCompat

Makes destination darker to reflect source.

\(\alpha_{out} = \alpha_{src} + \alpha_{dst} - \alpha_{src} * \alpha_{dst}\)

\begin{equation} C_{out} = \begin{cases} C_{dst} + C_{src}*(1 - \alpha_{dst}) & C_{dst} = \alpha_{dst} \\ \alpha_{dst}*(1 - \alpha_{src}) & C_{src} = 0 \\ \alpha_{src}*(\alpha_{dst} - min(\alpha_{dst}, (\alpha_{dst} - C_{dst})*\alpha_{src}/C_{src})) + C_{src} * (1 - \alpha_{dst}) + \alpha_{dst}*(1-\alpha_{src}) & otherwise \end{cases} \end{equation}