BlendModeCompat
public enum BlendModeCompat
Compat version of android.graphics.BlendMode, usages of BlendModeCompat will map to android.graphics.PorterDuff.Mode wherever possible
Summary
Enum Values |
|
|---|---|
CLEAR |
Destination pixels covered by the source are cleared to 0. |
COLOR |
Replaces hue and saturation of destination with hue and saturation of source, leaving luminosity unchanged. |
COLOR_BURN |
Makes destination darker to reflect source. |
COLOR_DODGE |
Makes destination brighter to reflect source. |
DARKEN |
Retains the smallest component of the source and destination pixels. |
DIFFERENCE |
Subtracts darker from lighter with higher contrast. |
DST |
The source pixels are discarded, leaving the destination intact. |
DST_ATOP |
Discards the destination pixels that are not covered by source pixels. |
DST_IN |
Keeps the destination pixels that cover source pixels, discards the remaining source and destination pixels. |
DST_OUT |
Keeps the destination pixels that are not covered by source pixels. |
DST_OVER |
The source pixels are drawn behind the destination pixels. |
EXCLUSION |
Subtracts darker from lighter with lower contrast. |
HARD_LIGHT |
Makes destination lighter or darker, depending on source. |
HUE |
Replaces hue of destination with hue of source, leaving saturation and luminosity unchanged. |
LIGHTEN |
Retains the largest component of the source and destination pixel. |
LUMINOSITY |
Replaces luminosity of destination with luminosity of source, leaving hue and saturation unchanged. |
MODULATE |
Multiplies the source and destination pixels. |
MULTIPLY |
Multiplies the source and destination pixels. |
OVERLAY |
Multiplies or screens the source and destination depending on the destination color. |
PLUS |
Adds the source pixels to the destination pixels and saturates the result. |
SATURATION |
Replaces saturation of destination saturation hue of source, leaving hue and luminosity unchanged. |
SCREEN |
Adds the source and destination pixels, then subtracts the source pixels multiplied by the destination. |
SOFT_LIGHT |
Makes destination lighter or darker, depending on source. |
SRC |
The source pixels replace the destination pixels. |
SRC_ATOP |
Discards the source pixels that do not cover destination pixels. |
SRC_IN |
Keeps the source pixels that cover the destination pixels, discards the remaining source and destination pixels. |
SRC_OUT |
Keeps the source pixels that do not cover destination pixels. |
SRC_OVER |
The source pixels are drawn over the destination pixels. |
XOR |
Discards the source and destination pixels where source pixels cover destination pixels. |
Public methods |
|
|---|---|
static BlendModeCompat |
Returns the enum constant of this type with the specified name. |
static BlendModeCompat[] |
values()Returns an array containing the constants of this enum type, in the order they're declared. |
Enum Values
CLEAR
BlendModeCompat BlendModeCompat.CLEAR
\(\alpha_{out} = 0\)
\(C_{out} = 0\)
COLOR
BlendModeCompat BlendModeCompat.COLOR
Replaces hue and saturation of destination with hue and saturation of source, leaving luminosity unchanged.
COLOR_BURN
BlendModeCompat BlendModeCompat.COLOR_BURN
\(\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
BlendModeCompat BlendModeCompat.COLOR_DODGE
\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
BlendModeCompat BlendModeCompat.DARKEN
\(\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
BlendModeCompat BlendModeCompat.DIFFERENCE
\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
BlendModeCompat BlendModeCompat.DST
\(\alpha_{out} = \alpha_{dst}\)
\(C_{out} = C_{dst}\)
DST_ATOP
BlendModeCompat BlendModeCompat.DST_ATOP
\(\alpha_{out} = \alpha_{src}\)
\(C_{out} = \alpha_{src} * C_{dst} + (1 - \alpha_{dst}) * C_{src}\)
DST_IN
BlendModeCompat BlendModeCompat.DST_IN
\(\alpha_{out} = \alpha_{src} * \alpha_{dst}\)
\(C_{out} = C_{dst} * \alpha_{src}\)
DST_OUT
BlendModeCompat BlendModeCompat.DST_OUT
\(\alpha_{out} = (1 - \alpha_{src}) * \alpha_{dst}\)
\(C_{out} = (1 - \alpha_{src}) * C_{dst}\)
DST_OVER
BlendModeCompat BlendModeCompat.DST_OVER
\(\alpha_{out} = \alpha_{dst} + (1 - \alpha_{dst}) * \alpha_{src}\)
\(C_{out} = C_{dst} + (1 - \alpha_{dst}) * C_{src}\)
EXCLUSION
BlendModeCompat BlendModeCompat.EXCLUSION
\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
BlendModeCompat BlendModeCompat.HARD_LIGHT
\(\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
BlendModeCompat BlendModeCompat.HUE
Replaces hue of destination with hue of source, leaving saturation and luminosity unchanged.
LIGHTEN
BlendModeCompat BlendModeCompat.LIGHTEN
\(\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
BlendModeCompat BlendModeCompat.LUMINOSITY
Replaces luminosity of destination with luminosity of source, leaving hue and saturation unchanged.
MODULATE
BlendModeCompat BlendModeCompat.MODULATE
\(\alpha_{out} = \alpha_{src} * \alpha_{dst}\)
\(C_{out} = C_{src} * C_{dst}\)
MULTIPLY
BlendModeCompat BlendModeCompat.MULTIPLY
\(\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
BlendModeCompat BlendModeCompat.OVERLAY
\(\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
BlendModeCompat BlendModeCompat.PLUS
\(\alpha_{out} = max(0, min(\alpha_{src} + \alpha_{dst}, 1))\)
\(C_{out} = max(0, min(C_{src} + C_{dst}, 1))\)
SATURATION
BlendModeCompat BlendModeCompat.SATURATION
Replaces saturation of destination saturation hue of source, leaving hue and luminosity unchanged.
SCREEN
BlendModeCompat BlendModeCompat.SCREEN
\(\alpha_{out} = \alpha_{src} + \alpha_{dst} - \alpha_{src} * \alpha_{dst}\)
\(C_{out} = C_{src} + C_{dst} - C_{src} * C_{dst}\)
SOFT_LIGHT
BlendModeCompat BlendModeCompat.SOFT_LIGHT
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
BlendModeCompat BlendModeCompat.SRC
\(\alpha_{out} = \alpha_{src}\)
\(C_{out} = C_{src}\)
SRC_ATOP
BlendModeCompat BlendModeCompat.SRC_ATOP
\(\alpha_{out} = \alpha_{dst}\)
\(C_{out} = \alpha_{dst} * C_{src} + (1 - \alpha_{src}) * C_{dst}\)
SRC_IN
BlendModeCompat BlendModeCompat.SRC_IN
\(\alpha_{out} = \alpha_{src} * \alpha_{dst}\)
\(C_{out} = C_{src} * \alpha_{dst}\)
SRC_OUT
BlendModeCompat BlendModeCompat.SRC_OUT
\(\alpha_{out} = (1 - \alpha_{dst}) * \alpha_{src}\)
\(C_{out} = (1 - \alpha_{dst}) * C_{src}\)
SRC_OVER
BlendModeCompat BlendModeCompat.SRC_OVER
\(\alpha_{out} = \alpha_{src} + (1 - \alpha_{src}) * \alpha_{dst}\)
\(C_{out} = C_{src} + (1 - \alpha_{src}) * C_{dst}\)
XOR
BlendModeCompat BlendModeCompat.XOR
\(\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 methods
valueOf
public static BlendModeCompat valueOf(String name)
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 |
the enum constant with the specified name |
| Throws | |
|---|---|
java.lang.IllegalArgumentException |
if this enum type has no constant with the specified name |
values
public static BlendModeCompat[] values()
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 | |
|---|---|
BlendModeCompat[] |
an array containing the constants of this enum type, in the order they're declared |