Table of Contents

Enum BlendMode

Namespace
Egami.Operations
Assembly
Egami.dll

How a source color is combined with the destination under it: the twelve Porter–Duff operators, Plus and Modulate, and the separable and non-separable blend modes of the W3C Compositing and Blending specification, plus Add and Subtract. Blend modes (Multiply to Luminosity) blend the colors where both are present, then composite source-over. The values are fixed: they never change between releases.

public enum BlendMode

Fields

Add = 25

The sum of the colors, clamped: B = min(1, Cs + Cd) (Photoshop's Linear Dodge).

Clear = 1

Both are removed: the result is transparent.

Color = 29

The source's hue and saturation with the destination's luminosity: tints a gray image.

ColorBurn = 20

Darkens the destination to reflect the source: B = 1 − min(1, (1 − Cd) / Cs).

ColorDodge = 19

Brightens the destination to reflect the source: B = min(1, Cd / (1 − Cs)).

Darken = 17

The darker of the two colors, per channel.

DarkerColor = 37

The whole color, source or destination, whose luminosity is lower.

Destination = 3

The destination is kept: d. Drawing with it changes nothing.

DestinationAtop = 10

The destination on top of the source, only where the source is: s(1 − αd) + d·αs.

DestinationIn = 6

The destination where the source is: d·αs. Use it to cut an image to a shape.

DestinationOut = 8

The destination where the source is not: d(1 − αs). Use it to punch a shape out of an image.

DestinationOver = 4

The destination covers the source: s(1 − αd) + d, drawing behind what is there.

Difference = 23

The absolute difference of the colors: B = |Cd − Cs|.

Dissolve = 39

Each source pixel is drawn fully or not at all, with a chance equal to its alpha (opacity included), then source-over. The pattern is a fixed hash of the pixel's place, not Photoshop's: DrawImage and Fill place it by canvas position, and Compositor by the index in the row, so it repeats from row to row there.

Divide = 31

Divides the destination by the source, clamped: B = min(1, Cd / Cs); black in the source gives white.

Exclusion = 24

Like Difference with lower contrast: B = Cs + Cd − 2·Cs·Cd.

HardLight = 21

Multiplies where the source is dark and screens where it is light, as a harsh spotlight would.

HardMix = 36

Each channel to 0 or 1: B = 1 where Cd + Cs ≥ 1, else 0.

Hue = 27

The source's hue with the destination's saturation and luminosity.

Lighten = 18

The lighter of the two colors, per channel.

LighterColor = 38

The whole color, source or destination, whose luminosity is higher.

LinearBurn = 32

The sum of the colors less 1, clamped: B = max(0, Cd + Cs − 1). Darkens more than Multiply.

LinearLight = 33

LinearBurn where the source is dark, Add where it is light: B = clamp(Cd + 2·Cs − 1).

Luminosity = 30

The source's luminosity with the destination's hue and saturation.

Modulate = 13

The product of color and of alpha: s·d.

Multiply = 14

Multiplies the colors, which always darkens: B = Cs·Cd. White changes nothing; black gives black.

Overlay = 16

Multiplies or screens depending on the destination, raising contrast: HardLight with the layers swapped.

PinLight = 35

Darken with 2·Cs where the source is dark, Lighten with 2·Cs − 1 where it is light.

Plus = 12

The sum, clamped to 1, of color and of alpha: min(1, s + d) (the W3C "lighter").

Saturation = 28

The source's saturation with the destination's hue and luminosity.

Screen = 15

Multiplies the inverted colors, which always lightens: B = Cs + Cd − Cs·Cd. Black changes nothing.

SoftLight = 22

Darkens or lightens depending on the source, as a diffused spotlight would (the W3C formula).

Source = 2

The source replaces the destination: s.

SourceAtop = 9

The source on top of the destination, only where the destination is: s·αd + d(1 − αs).

SourceIn = 5

The source where the destination is: s·αd.

SourceOut = 7

The source where the destination is not: s(1 − αd).

SourceOver = 0

The source covers the destination: s + d(1 − αs). The default, and what every 1.x DrawImage does.

Subtract = 26

The source taken from the destination, clamped: B = max(0, Cd − Cs).

VividLight = 34

ColorBurn by 2·Cs where the source is dark, ColorDodge by 2·Cs − 1 where it is light.

Xor = 11

Each where the other is not: s(1 − αd) + d(1 − αs).

Examples

// One enum names every mode. Blend modes (Multiply to Luminosity) blend the colors, then cover what is under them.
BlendMode[] darkening = [BlendMode.Multiply, BlendMode.Darken, BlendMode.ColorBurn];
BlendMode[] cutting = [BlendMode.DestinationIn, BlendMode.DestinationOut];   // shape the destination by the image's alpha

Remarks

Every mode works on premultiplied values; with s the source and d the destination, each with alpha αs and αd. The source's alpha is multiplied by the opacity first, so opacity 0 leaves the destination as it was for every mode except Clear, Source, DestinationAtop, Modulate and the In and Out modes, whose results depend on where the source is.