{% setvar book_path %}/reference/androidx/_book.yaml{% endsetvar %} {% include "_shared/_reference-head-tags.html" %}

BlendMode.Companion

public static class BlendMode.Companion


Summary

Public methods

static final @NonNull BlendMode

Drop both the source and destination images, leaving nothing.

static final @NonNull BlendMode

Take the hue and saturation of the source image, and the luminosity of the destination image.

static final @NonNull BlendMode

Divide the inverse of the destination by the source, and inverse the result.

static final @NonNull BlendMode

Divide the destination by the inverse of the source.

static final @NonNull BlendMode

Composite the source and destination image by choosing the lowest value from each color channel.

static final @NonNull BlendMode

Subtract the smaller value from the bigger value for each channel.

static final @NonNull BlendMode

Drop the source image, only paint the destination image.

static final @NonNull BlendMode

Composite the destination image over the source image, but only where it overlaps the source.

static final @NonNull BlendMode

Show the destination image, but only where the two images overlap.

static final @NonNull BlendMode

Show the destination image, but only where the two images do not overlap.

static final @NonNull BlendMode

Composite the source image under the destination image.

static final @NonNull BlendMode

Subtract double the product of the two images from the sum of the two images.

static final @NonNull BlendMode

Multiply the components of the source and destination images after adjusting them to favor the source.

static final @NonNull BlendMode

Take the hue of the source image, and the saturation and luminosity of the destination image.

static final @NonNull BlendMode

Composite the source and destination image by choosing the highest value from each color channel.

static final @NonNull BlendMode

Take the luminosity of the source image, and the hue and saturation of the destination image.

static final @NonNull BlendMode

Multiply the color components of the source and destination images.

static final @NonNull BlendMode

Multiply the components of the source and destination images, including the alpha channel.

static final @NonNull BlendMode

Multiply the components of the source and destination images after adjusting them to favor the destination.

static final @NonNull BlendMode

Sum the components of the source and destination images.

static final @NonNull BlendMode

Take the saturation of the source image, and the hue and luminosity of the destination image.

static final @NonNull BlendMode

Multiply the inverse of the components of the source and destination images, and inverse the result.

static final @NonNull BlendMode

Use ColorDodge for source values below 0.5 and ColorBurn for source values above 0.5.

static final @NonNull BlendMode

Drop the destination image, only paint the source image.

static final @NonNull BlendMode

Composite the source image over the destination image, but only where it overlaps the destination.

static final @NonNull BlendMode

Show the source image, but only where the two images overlap.

static final @NonNull BlendMode

Show the source image, but only where the two images do not overlap.

static final @NonNull BlendMode

Composite the source image over the destination image.

static final @NonNull BlendMode

Apply a bitwise xor operator to the source and destination images.

Public methods

getClear

public static final @NonNull BlendMode getClear()

Drop both the source and destination images, leaving nothing.

getColor

public static final @NonNull BlendMode getColor()

Take the hue and saturation of the source image, and the luminosity of the destination image.

The effect is to tint the destination image with the source image.

The opacity of the output image is computed in the same way as for SrcOver. Regions that are entirely transparent in the source image take their hue and saturation from the destination.

NOTE This BlendMode can only be used on Android API level 29 and above

See also:

getColorBurn

public static final @NonNull BlendMode getColorBurn()

Divide the inverse of the destination by the source, and inverse the result.

Inverting the components means that a fully saturated channel (opaque white) is treated as the value 0.0, and values normally treated as 0.0 (black, transparent) are treated as 1.0.

NOTE This BlendMode can only be used on Android API level 29 and above

getColorDodge

public static final @NonNull BlendMode getColorDodge()

Divide the destination by the inverse of the source.

Inverting the components means that a fully saturated channel (opaque white) is treated as the value 0.0, and values normally treated as 0.0 (black, transparent) are treated as 1.0.

NOTE This BlendMode can only be used on Android API level 29 and above

getDarken

public static final @NonNull BlendMode getDarken()

Composite the source and destination image by choosing the lowest value from each color channel.

The opacity of the output image is computed in the same way as for SrcOver.

getDifference

public static final @NonNull BlendMode getDifference()

Subtract the smaller value from the bigger value for each channel.

Compositing black has no effect; compositing white inverts the colors of the other image.

The opacity of the output image is computed in the same way as for SrcOver.

NOTE This BlendMode can only be used on Android API level 29 and above

The effect is similar to Exclusion but harsher.

getDst

public static final @NonNull BlendMode getDst()

Drop the source image, only paint the destination image.

Conceptually, the source image is discarded, leaving the destination untouched.

getDstAtop

public static final @NonNull BlendMode getDstAtop()

Composite the destination image over the source image, but only where it overlaps the source.

This is essentially the DstOver operator, but with the output's opacity channel being set to that of the source image instead of being a combination of both image's opacity channels.

For a variant with the source on top instead of the destination, see SrcAtop.

getDstIn

public static final @NonNull BlendMode getDstIn()

Show the destination image, but only where the two images overlap. The source image is not rendered, it is treated merely as a mask. The color channels of the source are ignored, only the opacity has an effect.

To show the source image instead, consider SrcIn.

To reverse the semantic of the mask (only showing the source where the destination is present, rather than where it is absent), consider DstOut.

getDstOut

public static final @NonNull BlendMode getDstOut()

Show the destination image, but only where the two images do not overlap. The source image is not rendered, it is treated merely as a mask. The color channels of the source are ignored, only the opacity has an effect.

To show the source image instead, consider SrcOut.

To reverse the semantic of the mask (only showing the destination where the source is present, rather than where it is absent), consider DstIn.

This corresponds to the "Destination out Source" Porter-Duff operator.

getDstOver

public static final @NonNull BlendMode getDstOver()

Composite the source image under the destination image.

This is the opposite of SrcOver.

This is useful when the source image should have been painted before the destination image, but could not be.

getExclusion

public static final @NonNull BlendMode getExclusion()

Subtract double the product of the two images from the sum of the two images.

Compositing black has no effect; compositing white inverts the colors of the other image.

The opacity of the output image is computed in the same way as for SrcOver.

NOTE This BlendMode can only be used on Android API level 29 and above

The effect is similar to Difference but softer.

getHardlight

public static final @NonNull BlendMode getHardlight()

Multiply the components of the source and destination images after adjusting them to favor the source.

Specifically, if the source value is smaller, this multiplies it with the destination value, whereas is the destination value is smaller, it multiplies the inverse of the destination value with the inverse of the source value, then inverts the result.

Inverting the components means that a fully saturated channel (opaque white) is treated as the value 0.0, and values normally treated as 0.0 (black, transparent) are treated as 1.0.

NOTE This BlendMode can only be used on Android API level 29 and above

See also:

getHue

public static final @NonNull BlendMode getHue()

Take the hue of the source image, and the saturation and luminosity of the destination image.

The effect is to tint the destination image with the source image.

The opacity of the output image is computed in the same way as for SrcOver. Regions that are entirely transparent in the source image take their hue from the destination.

NOTE This BlendMode can only be used on Android API level 29 and above

getLighten

public static final @NonNull BlendMode getLighten()

Composite the source and destination image by choosing the highest value from each color channel.

The opacity of the output image is computed in the same way as for SrcOver.

getLuminosity

public static final @NonNull BlendMode getLuminosity()

Take the luminosity of the source image, and the hue and saturation of the destination image.

The opacity of the output image is computed in the same way as for SrcOver. Regions that are entirely transparent in the source image take their luminosity from the destination.

NOTE This BlendMode can only be used on Android API level 29 and above

See also:

getModulate

public static final @NonNull BlendMode getModulate()

Multiply the color components of the source and destination images.

This can only result in the same or darker colors (multiplying by white, 1.0, results in no change; multiplying by black, 0.0, results in black).

When compositing two opaque images, this has similar effect to overlapping two transparencies on a projector.

For a variant that also multiplies the alpha channel, consider Multiply.

See also:

getMultiply

public static final @NonNull BlendMode getMultiply()

Multiply the components of the source and destination images, including the alpha channel.

This can only result in the same or darker colors (multiplying by white, 1.0, results in no change; multiplying by black, 0.0, results in black).

Since the alpha channel is also multiplied, a fully-transparent pixel (opacity 0.0) in one image results in a fully transparent pixel in the output. This is similar to DstIn, but with the colors combined.

For a variant that multiplies the colors but does not multiply the alpha channel, consider Modulate.

NOTE This BlendMode can only be used on Android API level 29 and above

getOverlay

public static final @NonNull BlendMode getOverlay()

Multiply the components of the source and destination images after adjusting them to favor the destination.

Specifically, if the destination value is smaller, this multiplies it with the source value, whereas is the source value is smaller, it multiplies the inverse of the source value with the inverse of the destination value, then inverts the result.

Inverting the components means that a fully saturated channel (opaque white) is treated as the value 0.0, and values normally treated as 0.0 (black, transparent) are treated as 1.0.

See also:

getPlus

public static final @NonNull BlendMode getPlus()

Sum the components of the source and destination images.

Transparency in a pixel of one of the images reduces the contribution of that image to the corresponding output pixel, as if the color of that pixel in that image was darker.

getSaturation

public static final @NonNull BlendMode getSaturation()

Take the saturation of the source image, and the hue and luminosity of the destination image.

The opacity of the output image is computed in the same way as for SrcOver. Regions that are entirely transparent in the source image take their saturation from the destination.

NOTE This BlendMode can only be used on Android API level 29 and above

See also:

getScreen

public static final @NonNull BlendMode getScreen()

Multiply the inverse of the components of the source and destination images, and inverse the result.

Inverting the components means that a fully saturated channel (opaque white) is treated as the value 0.0, and values normally treated as 0.0 (black, transparent) are treated as 1.0.

This is essentially the same as Modulate blend mode, but with the values of the colors inverted before the multiplication and the result being inverted back before rendering.

This can only result in the same or lighter colors (multiplying by black, 1.0, results in no change; multiplying by white, 0.0, results in white). Similarly, in the alpha channel, it can only result in more opaque colors.

This has similar effect to two projectors displaying their images on the same screen simultaneously.

See also:

getSoftlight

public static final @NonNull BlendMode getSoftlight()

Use ColorDodge for source values below 0.5 and ColorBurn for source values above 0.5.

This results in a similar but softer effect than Overlay.

NOTE This BlendMode can only be used on Android API level 29 and above

See also:

getSrc

public static final @NonNull BlendMode getSrc()

Drop the destination image, only paint the source image.

Conceptually, the destination is first cleared, then the source image is painted.

getSrcAtop

public static final @NonNull BlendMode getSrcAtop()

Composite the source image over the destination image, but only where it overlaps the destination.

This is essentially the SrcOver operator, but with the output's opacity channel being set to that of the destination image instead of being a combination of both image's opacity channels.

For a variant with the destination on top instead of the source, see DstAtop.

getSrcIn

public static final @NonNull BlendMode getSrcIn()

Show the source image, but only where the two images overlap. The destination image is not rendered, it is treated merely as a mask. The color channels of the destination are ignored, only the opacity has an effect.

To show the destination image instead, consider DstIn.

To reverse the semantic of the mask (only showing the source where the destination is absent, rather than where it is present), consider SrcOut.

getSrcOut

public static final @NonNull BlendMode getSrcOut()

Show the source image, but only where the two images do not overlap. The destination image is not rendered, it is treated merely as a mask. The color channels of the destination are ignored, only the opacity has an effect.

To show the destination image instead, consider DstOut.

To reverse the semantic of the mask (only showing the source where the destination is present, rather than where it is absent), consider SrcIn.

This corresponds to the "Source out Destination" Porter-Duff operator.

getSrcOver

public static final @NonNull BlendMode getSrcOver()

Composite the source image over the destination image.

This is the default value. It represents the most intuitive case, where shapes are painted on top of what is below, with transparent areas showing the destination layer.

getXor

public static final @NonNull BlendMode getXor()

Apply a bitwise xor operator to the source and destination images. This leaves transparency where they would overlap.