The 16 standard blend modes, which decide how a color being painted combines with the color already there, and the formula for each.
Compatible and arrays of blend modes, and changed ColorDodge and ColorBurn at one edge case each.
When an object is painted (the source), the transparent imaging model combines it with what is already on the page (the backdrop). The blend mode is a function B of the two colors, and opacity then mixes its result with the plain source and backdrop. For each color component:
cr = (1 − αs / αr) × cb + (αs / αr) × ((1 − αb) × cs + αb × B(cb, cs))
Here cb, cs and cr are the backdrop, source and result components, and αb, αs and αr their alphas. When both alphas are 1, the result is just B(cb, cs). For opacity, soft masks and groups, see Transparency in Learning.
The formulas take components from 0.0 to 1.0 in an additive space, where 1.0 is the most light. In the subtractive spaces, DeviceCMYK, Separation and DeviceN, each component is complemented (1 − c) before blending and complemented back after, so a mode has the same effect in every space.
Setting the blend mode
No operator sets the blend mode. It is the /BM entry /ExtGState resources, applied with gs. It starts as Normal, stays in effect until changed or until Q restores an earlier state, and resets to Normal at the start of every transparency group XObject.
3 0 obj << /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] /Resources << /ExtGState << /GS0 << /BM /Multiply >> >> >> /Contents 4 0 R >> endobj
1 1 0 rg 72 600 200 100 re f % yellow, painted normally q /GS0 gs % blend mode Multiply until Q 0 1 1 rg 172 650 200 100 re f % cyan: green where it overlaps the yellow Q
Multiply works component by component: yellow (1, 1, 0) times cyan (0, 1, 1) is (0, 1, 0), green.
The value of /BM is one of two things:
- A name, one of the modes on this page.
- An array of names, such as
[/NewMode /Multiply]: a fallback list, so that new modes could be added later. The reader uses the first mode in the array that it recognizes, orNormalif it recognizes none.Deprecated in PDF 2.0 Writers should not use arrays, but readers still apply the same rule.
/BM too, a name only, for blending the annotation’s appearance onto the page. Without it the annotation uses Normal.
Separable blend modes
A separable mode works on each component on its own: the result’s red depends only on the backdrop’s and source’s red, and so on. So it works in any color space, with any number of components. Lower-case cb and cs stand for one component of the backdrop and source.
| Mode | Blend function | Effect |
|---|---|---|
Normalformula in PDF 1.4 | B(cb, cs) = cs | The source replaces the backdrop. The default. |
Compatible | B(cb, cs) = cs | A leftover from an early design of the transparency model, the same as Normal. PDF 1.4 mentions it only in a note. |
Multiplyformula in PDF 1.4 | B(cb, cs) = cb × cs | Darkens: the result is never lighter than either color. Black gives black, white leaves the backdrop unchanged, and each overlapping layer gets darker. |
Screenformula in PDF 1.4 | B(cb, cs) = 1 − (1 − cb) × (1 − cs) = cb + cs − cb × cs | Lightens, the opposite of Multiply: multiplies the complements and complements the result. White gives white, black leaves the backdrop unchanged. |
Overlayformula from the 2006 addendum | B(cb, cs) = HardLight(cs, cb) | HardLight with the colors swapped, so the backdrop decides: dark areas are multiplied, light ones screened. The backdrop’s highlights and shadows survive, tinted by the source. |
Darkenformula in PDF 1.4 | B(cb, cs) = min(cb, cs) | Keeps the darker of the two, component by component. |
Lightenformula in PDF 1.4 | B(cb, cs) = max(cb, cs) | Keeps the lighter of the two, component by component. |
ColorDodgeformula from the 2006 addendum | B(cb, cs) = min(1, cb / (1 − cs))if cs < 11if cs = 1 | Brightens the backdrop toward the source. A black source changes nothing. PDF 2.0 gives the same results except at cb = 0, cs = 1, which is now 0 instead of 1, so that the result changes smoothly with cs. |
ColorBurnformula from the 2006 addendum | B(cb, cs) = 1 − min(1, (1 − cb) / cs)if cs > 00if cs = 0 | Darkens the backdrop toward the source. A white source changes nothing. PDF 2.0 gives the same results except at cb = 1, cs = 0, which is now 1 instead of 0. |
HardLightformula from the 2006 addendum | B(cb, cs) = Multiply(cb, 2 × cs)if cs ≤ 0.5Screen(cb, 2 × cs − 1)if cs > 0.5 | The source decides: darker than 0.5 multiplies, lighter screens, and exactly 0.5 leaves the backdrop alone. Black or white source gives black or white. Like a harsh spotlight. |
SoftLightformula from the 2006 addendum | B(cb, cs) = cb − (1 − 2 × cs) × cb × (1 − cb)if cs ≤ 0.5cb + (2 × cs − 1) × (D(cb) − cb)if cs > 0.5where D(x) = ((16 × x − 12) × x + 4) × xif x ≤ 0.25√xif x > 0.25 | A gentler HardLight: darkens or lightens by the source, but a black or white source gives a darker or lighter area, not pure black or white. Like a diffused spotlight. |
Differenceformula in PDF 1.4 | B(cb, cs) = |cb − cs| | The lighter minus the darker. A white source inverts the backdrop, black changes nothing. Not white-preserving. |
Exclusionformula from the 2006 addendum | B(cb, cs) = cb + cs − 2 × cb × cs | Like Difference, with less contrast. A white source inverts the backdrop, black changes nothing. Not white-preserving. |
Non-separable blend modes
A non-separable mode looks at all components together. In effect it converts both colors to hue, saturation and luminosity, takes some of each from the source and the rest from the backdrop, and converts back. The formulas skip the conversions: they start from the color that supplies the hue, then adjust its saturation and luminosity with the helper functions below. Upper-case Cb and Cs are whole colors.
| Mode | Blend function | Effect |
|---|---|---|
Hueformula from the 2006 addendum | B(Cb, Cs) = SetLum(SetSat(Cs, Sat(Cb)), Lum(Cb)) | The hue of the source, with the saturation and luminosity of the backdrop. |
Saturationformula from the 2006 addendum | B(Cb, Cs) = SetLum(SetSat(Cb, Sat(Cs)), Lum(Cb)) | The saturation of the source, with the hue and luminosity of the backdrop. Over a gray backdrop it changes nothing. |
Colorformula from the 2006 addendum | B(Cb, Cs) = SetLum(Cs, Lum(Cb)) | The hue and saturation of the source, with the luminosity of the backdrop. Keeps the backdrop’s gray levels, so it can tint a grayscale image. |
Luminosityformula from the 2006 addendum | B(Cb, Cs) = SetLum(Cb, Lum(Cs)) | The luminosity of the source, with the hue and saturation of the backdrop: the reverse of Color. |
The formulas are for RGB. In a CMYK space, cyan, magenta and yellow are complemented to red, green and blue, blended, and complemented back. Black is taken from the backdrop for Hue, Saturation and Color, and from the source for Luminosity. PDF 2.0 adds that gray spaces blend by converting to RGB and back.
Helper functions
They work on a color C with red, green and blue components:
| Function | Definition |
|---|---|
| Lum(C) | 0.3 × Cred + 0.59 × Cgreen + 0.11 × CblueLuminosity: a weighted sum of the components, green counting most. |
| SetLum(C, l) | Add d = l − Lum(C) to each component, then return ClipColor(C).Shifts a color to luminosity l. |
| ClipColor(C) | With l = Lum(C), n the smallest component and x the largest: if n < 0, each component c becomes l + (c − l) × l / (l − n); if x > 1, it becomes l + (c − l) × (1 − l) / (x − l).Brings components back into 0 to 1 by pulling them toward the luminosity, which stays the same. |
| Sat(C) | max(Cred, Cgreen, Cblue) − min(Cred, Cgreen, Cblue)Saturation: the spread between the largest and smallest component. |
| SetSat(C, s) | If Cmax > Cmin: Cmid = (Cmid − Cmin) × s / (Cmax − Cmin) and Cmax = s. Otherwise Cmid = Cmax = 0. Then Cmin = 0. Min, mid and max name the components by their size on entry.Rescales a color to saturation s, keeping the order of its components and so its hue. |
ISO 32000-2 warns that SetSat jumps between neutral and almost neutral colors, so Hue and Saturation can look quite different from one reader to another.
Color spaces and spot colors
Blending happens in the blending color space: the /CS of the transparency group being painted into or, for the page itself, of the page’s /Group, and otherwise the output device’s own space. It can be DeviceGray, DeviceRGB, DeviceCMYK, CalGray, CalRGB, or an ICCBased space equivalent to one of them, whose profile must convert both to and from CIE. Lab, and ICC spaces that separate lightness from color, aren’t allowed: blending their components one by one gives meaningless results. See Color spaces.
Spot colors in a Separation or DeviceN space aren’t converted to the blending space, unless they fall back to their alternate space. Each colorant blends with the same colorant in the backdrop, and only modes that are separable and white-preserving, meaning B(1, 1) = 1, apply to them. Of the standard modes, that rules out the four non-separable ones, Difference and Exclusion. With any of those, process colors use the mode and spot colorants use Normal.
How the formulas changed
Each row of the tables above notes where its formula first appeared. Only ColorDodge and ColorBurn have ever changed.
| Specification | What it gives |
|---|---|
| PDF Reference, third edition (PDF 1.4)2001 · Tables 7.2–7.3 | Formulas for Normal, Multiply, Screen, Darken, Lighten and Difference only. The other six separable modes, and all four non-separable ones, are described in words. Compatible is a note under the tables. |
| PDF Blend Modes: Addendum, to the PDF Reference, fifth edition (PDF 1.6)2006 · §7.2.4, reissued in full | A formula for every mode, plus the helper functions. It says the modes behave as they always did: the formulas document that behavior rather than correct it. |
| ISO 32000-1 (PDF 1.7)2008 · Tables 136–137 | The addendum’s formulas, with Compatible as a row of the separable table. In the published PDF the second condition of ColorDodge and ColorBurn is cut off after the equals sign; the addendum shows it in full (cs = 1 and cs = 0). |
| ISO 32000-2 (PDF 2.0)2017, 2020 · Tables 134–135 | ColorDodge and ColorBurn rewritten to change smoothly with the source, which changes one edge case each. Compatible and arrays of blend modes deprecated. Non-separable modes in gray spaces spelled out: convert to RGB, blend, and convert back. |
Checked against §7.2 and Tables 4.8, 7.2 and 7.3 of the Adobe PDF Reference, third edition (PDF 1.4), with §7.5.2 and §7.6.3; Adobe’s PDF Blend Modes addendum to the PDF Reference, fifth edition (PDF 1.6), January 2006; §11.3 and Tables 58, 136 and 137 of ISO 32000-1:2008 (PDF 1.7), with §11.6.3 and §11.7.4; and §11.3.5, §11.6.3 and Tables 57, 134, 135 and 166 of ISO 32000-2:2020 (PDF 2.0).