# BlendModeCompat

# BlendModeCompat

Artifact:[androidx.core:core](https://developer.android.com/jetpack/androidx/releases/core)  
[View Source](https://cs.android.com/search?q=file:androidx/core/graphics/BlendModeCompat.java+class:androidx.core.graphics.BlendModeCompat)  
Added in[1.2.0](https://developer.android.com/jetpack/androidx/releases/core#1.2.0)

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/androidx/core/graphics/BlendModeCompat "View this page in Java")

<br />

```
enum BlendModeCompat
```

<br />

*** ** * ** ***

Compat version of[android.graphics.BlendMode](https://developer.android.com/reference/android/graphics/BlendMode.html), usages of[BlendModeCompat](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat)will map to[android.graphics.PorterDuff.Mode](https://developer.android.com/reference/android/graphics/PorterDuff.Mode.html)wherever possible

## Summary

|                                                 ### Enum Values                                                  |
|------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------|
| [CLEAR](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#CLEAR)             | Destination pixels covered by the source are cleared to 0.                                                       |
| [COLOR](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#COLOR)             | Replaces hue and saturation of destination with hue and saturation of source, leaving luminosity unchanged.      |
| [COLOR_BURN](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#COLOR_BURN)   | Makes destination darker to reflect source.                                                                      |
| [COLOR_DODGE](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#COLOR_DODGE) | Makes destination brighter to reflect source.                                                                    |
| [DARKEN](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#DARKEN)           | Retains the smallest component of the source and destination pixels.                                             |
| [DIFFERENCE](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#DIFFERENCE)   | Subtracts darker from lighter with higher contrast.                                                              |
| [DST](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#DST)                 | The source pixels are discarded, leaving the destination intact.                                                 |
| [DST_ATOP](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#DST_ATOP)       | Discards the destination pixels that are not covered by source pixels.                                           |
| [DST_IN](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#DST_IN)           | Keeps the destination pixels that cover source pixels, discards the remaining source and destination pixels.     |
| [DST_OUT](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#DST_OUT)         | Keeps the destination pixels that are not covered by source pixels.                                              |
| [DST_OVER](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#DST_OVER)       | The source pixels are drawn behind the destination pixels.                                                       |
| [EXCLUSION](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#EXCLUSION)     | Subtracts darker from lighter with lower contrast.                                                               |
| [HARD_LIGHT](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#HARD_LIGHT)   | Makes destination lighter or darker, depending on source.                                                        |
| [HUE](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#HUE)                 | Replaces hue of destination with hue of source, leaving saturation and luminosity unchanged.                     |
| [LIGHTEN](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#LIGHTEN)         | Retains the largest component of the source and destination pixel.                                               |
| [LUMINOSITY](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#LUMINOSITY)   | Replaces luminosity of destination with luminosity of source, leaving hue and saturation unchanged.              |
| [MODULATE](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#MODULATE)       | Multiplies the source and destination pixels.                                                                    |
| [MULTIPLY](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#MULTIPLY)       | Multiplies the source and destination pixels.                                                                    |
| [OVERLAY](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#OVERLAY)         | Multiplies or screens the source and destination depending on the destination color.                             |
| [PLUS](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#PLUS)               | Adds the source pixels to the destination pixels and saturates the result.                                       |
| [SATURATION](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#SATURATION)   | Replaces saturation of destination saturation hue of source, leaving hue and luminosity unchanged.               |
| [SCREEN](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#SCREEN)           | Adds the source and destination pixels, then subtracts the source pixels multiplied by the destination.          |
| [SOFT_LIGHT](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#SOFT_LIGHT)   | Makes destination lighter or darker, depending on source.                                                        |
| [SRC](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#SRC)                 | The source pixels replace the destination pixels.                                                                |
| [SRC_ATOP](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#SRC_ATOP)       | Discards the source pixels that do not cover destination pixels.                                                 |
| [SRC_IN](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#SRC_IN)           | Keeps the source pixels that cover the destination pixels, discards the remaining source and destination pixels. |
| [SRC_OUT](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#SRC_OUT)         | Keeps the source pixels that do not cover destination pixels.                                                    |
| [SRC_OVER](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#SRC_OVER)       | The source pixels are drawn over the destination pixels.                                                         |
| [XOR](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#XOR)                 | Discards the source and destination pixels where source pixels cover destination pixels.                         |

|                                                                                             ### Public functions                                                                                              |
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `java-static `[BlendModeCompat](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat)`!`                                                                                     | [valueOf](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#valueOf(java.lang.String))`(name: `[String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)`!)` Returns the enum constant of this type with the specified name. |
| `java-static `[Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[BlendModeCompat](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat)`!>!` | [values](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat#values())`()` Returns an array containing the constants of this enum type, in the order they're declared.                                                                                 |

## Enum Values

### CLEAR

```
val BlendModeCompat.CLEAR: BlendModeCompat
```

Destination pixels covered by the source are cleared to 0.

\\(\\alpha_{out} = 0\\)

\\(C_{out} = 0\\)  

### COLOR

```
val BlendModeCompat.COLOR: BlendModeCompat
```

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

### COLOR_BURN

```
val BlendModeCompat.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}  

### COLOR_DODGE

```
val BlendModeCompat.COLOR_DODGE: BlendModeCompat
```

Makes destination brighter to reflect source. \\(\\alpha_{out} = \\alpha_{src} + \\alpha_{dst} - \\alpha_{src} \* \\alpha_{dst}\\)

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

### DARKEN

```
val BlendModeCompat.DARKEN: BlendModeCompat
```

Retains the smallest component of the source and destination pixels.

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

\\(C_{out} = (1 - \\alpha_{dst}) \* C_{src} + (1 - \\alpha_{src}) \* C_{dst} + min(C_{src}, C_{dst})\\)  

### DIFFERENCE

```
val BlendModeCompat.DIFFERENCE: BlendModeCompat
```

Subtracts darker from lighter with higher contrast.

\\begin{equation} \\alpha_{out} = \\alpha_{src} + \\alpha_{dst} - \\alpha_{src} \* \\alpha_{dst} \\end{equation}

\\begin{equation} C_{out} = C_{src} + C_{dst} - 2 \* min(C_{src} \* \\alpha_{dst}, C_{dst} \* \\alpha_{src}) \\end{equation}  

### DST

```
val BlendModeCompat.DST: BlendModeCompat
```

The source pixels are discarded, leaving the destination intact.

\\(\\alpha_{out} = \\alpha_{dst}\\)

\\(C_{out} = C_{dst}\\)  

### DST_ATOP

```
val BlendModeCompat.DST_ATOP: BlendModeCompat
```

Discards the destination pixels that are not covered by source pixels. Draws remaining destination pixels over source pixels.

\\(\\alpha_{out} = \\alpha_{src}\\)

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

### DST_IN

```
val BlendModeCompat.DST_IN: BlendModeCompat
```

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

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

\\(C_{out} = C_{dst} \* \\alpha_{src}\\)  

### DST_OUT

```
val BlendModeCompat.DST_OUT: BlendModeCompat
```

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

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

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

### DST_OVER

```
val BlendModeCompat.DST_OVER: BlendModeCompat
```

The source pixels are drawn behind the destination pixels.

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

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

### EXCLUSION

```
val BlendModeCompat.EXCLUSION: BlendModeCompat
```

Subtracts darker from lighter with lower contrast.

\\begin{equation} \\alpha_{out} = \\alpha_{src} + \\alpha_{dst} - \\alpha_{src} \* \\alpha_{dst} \\end{equation}

\\begin{equation} C_{out} = C_{src} + C_{dst} - 2 \* C_{src} \* C_{dst} \\end{equation}  

### HARD_LIGHT

```
val BlendModeCompat.HARD_LIGHT: BlendModeCompat
```

Makes destination lighter or darker, depending on source.

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

\\begin{equation} C_{out} = \\begin{cases} 2\*C_{src}\*C_{dst} \&C_{src}\*(1-\\alpha_{dst}) + C_{dst}\*(1-\\alpha_{src}) + 2\*C_{src} \\leq \\alpha_{src} \\\\ \\alpha_{src}\*\\alpha_{dst}- 2\*(\\alpha_{dst} - C_{dst})\*(\\alpha_{src} - C_{src}) \&otherwise \\end{cases} \\end{equation}  

### HUE

```
val BlendModeCompat.HUE: BlendModeCompat
```

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

### LIGHTEN

```
val BlendModeCompat.LIGHTEN: BlendModeCompat
```

Retains the largest component of the source and destination pixel.

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

\\(C_{out} = (1 - \\alpha_{dst}) \* C_{src} + (1 - \\alpha_{src}) \* C_{dst} + max(C_{src}, C_{dst})\\)  

### LUMINOSITY

```
val BlendModeCompat.LUMINOSITY: BlendModeCompat
```

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

### MODULATE

```
val BlendModeCompat.MODULATE: BlendModeCompat
```

Multiplies the source and destination pixels.

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

\\(C_{out} = C_{src} \* C_{dst}\\)  

### MULTIPLY

```
val BlendModeCompat.MULTIPLY: BlendModeCompat
```

Multiplies the source and destination pixels.

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

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

### OVERLAY

```
val BlendModeCompat.OVERLAY: BlendModeCompat
```

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

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

\\(\\begin{equation} C_{out} = \\begin{cases} 2 \* C_{src} \* C_{dst} \&2 \* C_{dst} \\lt \\alpha_{dst} \\\\ \\alpha_{src} \* \\alpha_{dst} - 2 (\\alpha_{dst} - C_{src}) (\\alpha_{src} - C_{dst}) \&otherwise \\end{cases} \\end{equation}\\)  

### PLUS

```
val BlendModeCompat.PLUS: BlendModeCompat
```

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

\\(\\alpha_{out} = max(0, min(\\alpha_{src} + \\alpha_{dst}, 1))\\)

\\(C_{out} = max(0, min(C_{src} + C_{dst}, 1))\\)  

### SATURATION

```
val BlendModeCompat.SATURATION: BlendModeCompat
```

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

### SCREEN

```
val BlendModeCompat.SCREEN: BlendModeCompat
```

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

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

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

### SOFT_LIGHT

```
val BlendModeCompat.SOFT_LIGHT: BlendModeCompat
```

Makes destination lighter or darker, depending on source.

Where \\begin{equation} m = \\begin{cases} C_{dst} / \\alpha_{dst} \&\\alpha_{dst} \\gt 0 \\\\ 0 \&otherwise \\end{cases} \\end{equation}

\\begin{equation} g = \\begin{cases} (16 \* m \* m + 4 \* m) \* (m - 1) + 7 \* m \&4 \* C_{dst} \\leq \\alpha_{dst} \\\\ \\sqrt m - m \&otherwise \\end{cases} \\end{equation}

\\begin{equation} f = \\begin{cases} C_{dst} \* (\\alpha_{src} + (2 \* C_{src} - \\alpha_{src}) \* (1 - m)) \&2 \* C_{src} \\leq \\alpha_{src} \\\\ C_{dst} \* \\alpha_{src} + \\alpha_{dst} \* (2 \* C_{src} - \\alpha_{src}) \* g \&otherwise \\end{cases} \\end{equation}

\\begin{equation} \\alpha_{out} = \\alpha_{src} + \\alpha_{dst} - \\alpha_{src} \* \\alpha_{dst} \\end{equation} \\begin{equation} C_{out} = C_{src} / \\alpha_{dst} + C_{dst} / \\alpha_{src} + f \\end{equation}  

### SRC

```
val BlendModeCompat.SRC: BlendModeCompat
```

The source pixels replace the destination pixels.

\\(\\alpha_{out} = \\alpha_{src}\\)

\\(C_{out} = C_{src}\\)  

### SRC_ATOP

```
val BlendModeCompat.SRC_ATOP: BlendModeCompat
```

Discards the source pixels that do not cover destination pixels. Draws remaining source pixels over destination pixels.

\\(\\alpha_{out} = \\alpha_{dst}\\)

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

### SRC_IN

```
val BlendModeCompat.SRC_IN: BlendModeCompat
```

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

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

\\(C_{out} = C_{src} \* \\alpha_{dst}\\)  

### SRC_OUT

```
val BlendModeCompat.SRC_OUT: BlendModeCompat
```

Keeps the source pixels that do not cover destination pixels. Discards source pixels that cover destination pixels. Discards all destination pixels.

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

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

### SRC_OVER

```
val BlendModeCompat.SRC_OVER: BlendModeCompat
```

The source pixels are drawn over the destination pixels.

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

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

### XOR

```
val BlendModeCompat.XOR: BlendModeCompat
```

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

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

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

## Public functions

### valueOf

Added in 1.2.0  

```
java-static fun valueOf(name: String!): BlendModeCompat!
```

Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)  

|                                                   Returns                                                   |
|-------------------------------------------------------------------------------------------------------------|-------------------------------------------|
| [BlendModeCompat](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat)`!` | the enum constant with the specified name |

|                                                        Throws                                                         |
|-----------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------|
| [java.lang.IllegalArgumentException](https://developer.android.com/reference/java/lang/IllegalArgumentException.html) | if this enum type has no constant with the specified name |

### values

Added in 1.2.0  

```
java-static fun values(): Array<BlendModeCompat!>!
```

Returns an array containing the constants of this enum type, in the order they're declared. This method may be used to iterate over the constants.  

|                                                                                             Returns                                                                                             |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------|
| [Array](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html)`<`[BlendModeCompat](https://developer.android.com/reference/kotlin/androidx/core/graphics/BlendModeCompat)`!>!` | an array containing the constants of this enum type, in the order they're declared |