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 = 25The sum of the colors, clamped:
B = min(1, Cs + Cd)(Photoshop's Linear Dodge).Clear = 1Both are removed: the result is transparent.
Color = 29The source's hue and saturation with the destination's luminosity: tints a gray image.
ColorBurn = 20Darkens the destination to reflect the source:
B = 1 − min(1, (1 − Cd) / Cs).ColorDodge = 19Brightens the destination to reflect the source:
B = min(1, Cd / (1 − Cs)).Darken = 17The darker of the two colors, per channel.
DarkerColor = 37The whole color, source or destination, whose luminosity is lower.
Destination = 3The destination is kept:
d. Drawing with it changes nothing.DestinationAtop = 10The destination on top of the source, only where the source is:
s(1 − αd) + d·αs.DestinationIn = 6The destination where the source is:
d·αs. Use it to cut an image to a shape.DestinationOut = 8The destination where the source is not:
d(1 − αs). Use it to punch a shape out of an image.DestinationOver = 4The destination covers the source:
s(1 − αd) + d, drawing behind what is there.Difference = 23The absolute difference of the colors:
B = |Cd − Cs|.Dissolve = 39Each 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 = 31Divides the destination by the source, clamped:
B = min(1, Cd / Cs); black in the source gives white.Exclusion = 24Like Difference with lower contrast:
B = Cs + Cd − 2·Cs·Cd.HardLight = 21Multiplies where the source is dark and screens where it is light, as a harsh spotlight would.
HardMix = 36Each channel to 0 or 1:
B = 1whereCd + Cs ≥ 1, else 0.Hue = 27The source's hue with the destination's saturation and luminosity.
Lighten = 18The lighter of the two colors, per channel.
LighterColor = 38The whole color, source or destination, whose luminosity is higher.
LinearBurn = 32The sum of the colors less 1, clamped:
B = max(0, Cd + Cs − 1). Darkens more than Multiply.LinearLight = 33LinearBurn where the source is dark, Add where it is light:
B = clamp(Cd + 2·Cs − 1).Luminosity = 30The source's luminosity with the destination's hue and saturation.
Modulate = 13The product of color and of alpha:
s·d.Multiply = 14Multiplies the colors, which always darkens:
B = Cs·Cd. White changes nothing; black gives black.Overlay = 16Multiplies or screens depending on the destination, raising contrast: HardLight with the layers swapped.
PinLight = 35Darken with 2·Cs where the source is dark, Lighten with 2·Cs − 1 where it is light.
Plus = 12The sum, clamped to 1, of color and of alpha:
min(1, s + d)(the W3C "lighter").Saturation = 28The source's saturation with the destination's hue and luminosity.
Screen = 15Multiplies the inverted colors, which always lightens:
B = Cs + Cd − Cs·Cd. Black changes nothing.SoftLight = 22Darkens or lightens depending on the source, as a diffused spotlight would (the W3C formula).
Source = 2The source replaces the destination:
s.SourceAtop = 9The source on top of the destination, only where the destination is:
s·αd + d(1 − αs).SourceIn = 5The source where the destination is:
s·αd.SourceOut = 7The source where the destination is not:
s(1 − αd).SourceOver = 0The source covers the destination:
s + d(1 − αs). The default, and what every 1.x DrawImage does.Subtract = 26The source taken from the destination, clamped:
B = max(0, Cd − Cs).VividLight = 34ColorBurn by 2·Cs where the source is dark, ColorDodge by 2·Cs − 1 where it is light.
Xor = 11Each 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.