PDF Reference sixth edition, Adobe Portable Document Format Version 1.7 (book 1) — page 14
536
CHAPTER 7
Transparency
fs
=
fj
×
fm
×
fk
i
i
i
i
αs
=
αj
×
( fm
×
qm
)
×
(fk
×
qk
)
i
i
i
i
i
i
fg
=
Union(fg
,
fs
)
i
i-1
i
αg
=
Union(αg
,
αs
)
i
i-1
i
αi
=
Union(α0,αg
)
i
αs
αs
⎛
⎞
i
Ci
=
⎜1
- ------ ⎟
×
Ci-1
+
×((
1
-
αi-1
)× Cs
+
αi-1
×
Bi (Ci-1
,
C
))
si
α
αi
i
⎝
i
⎠
• Result:
⎛
α0
⎞
C = Cn + (Cn– C0)
×
⎜
-------- –α0⎟
α
⎝
gn
⎠
f
=
fg
n
α = αg
n
where the variables have the meanings shown in Table 7.8 (in addition to those in
Table 7.7 above).
For an element Ei that is an elementary object, the color, shape, and alpha
values
Cs
,
fj
, and
αj
are intrinsic attributes of the object. For an element that is
i
i
i
a group, the group compositing function is applied recursively to the subgroup
and the resulting C, f, and α values are used for itsCs
,
fj
, and
αj
in the calcula-
i
i
i
tions for the parent group.
TABLE 7.8 Variables used in the group compositing formulas
VARIABLE
MEANING
Ei
Element i of the group: a compound variable representing the ele-
ment’s color, shape, opacity, and blend mode
fs
Source shape for element Ei
i
fj
Object shape for element Ei
i
fm
Mask shape for element Ei
i
537
SECTION 7.3
Transparency Groups
VARIABLE
MEANING
f
Constant shape for element Ei
k
i
f
Group shape: the accumulated source shapes of group elements E1
gi
to Ei , excluding the initial backdrop
qm
Mask opacity for element Ei
i
qk
Constant opacity for element Ei
i
αs
Source alpha for element Ei
i
αj
Object alpha for element Ei : the product of its object shape and ob-
i
ject opacity
αg
Group alpha: the accumulated source alphas of group elements E1
i
to Ei, excluding the initial backdrop
αi
Accumulated alpha after compositing element Ei , including the ini-
tial backdrop
Cs
Source color for element Ei
i
Ci
Accumulated color after compositing element Ei , including the ini-
tial backdrop
Bi(Ci-1,
Cs
)
Blend function for element Ei
i
Note that the elements of a group are composited onto a backdrop that includes
the group’s initial backdrop. This is done to achieve the correct effects of the
blend modes, most of which are dependent on both the backdrop and source col-
ors being blended. (This feature is what distinguishes non-isolated groups from
isolated groups, discussed in the next section.)
Special attention should be directed to the formulas at the end that compute the
final results, C, f, and α, of the group compositing function. Essentially, these for-
mulas remove the contribution of the group backdrop from the computed results.
This ensures that when the group is subsequently composited with that backdrop
538
CHAPTER 7
Transparency
(possibly with additional shape or opacity inputs or a different blend mode), the
backdrop’s contribution is included only once.
For color, the backdrop removal is accomplished by an explicit calculation, whose
effect is essentially the reverse of compositing with the Normal blend mode. The
formula is a simplification of the following formulas, which present this opera-
tion more intuitively:
(1
-
αg
)× α0
φb
= --------------------------------------
Union(α
,
α
)
0
g
n
Cn – φb × C0
C
= -------------------------------
1
-
φ
b
where φb is the backdrop fraction, the relative contribution of the backdrop color
to the overall color.
For shape and alpha, backdrop removal is accomplished by maintaining two sets
of variables to hold the accumulated values. The group shape and alpha,
fg
and
αg
, accumulate only the shape and alpha of the group elements, exclud-
i
i
ing the group backdrop. Their final values become the group results returned by
the group compositing function. The complete alpha, αi , includes the backdrop
contribution as well; its value is used in the color compositing computations.
(There is never any need to compute the corresponding complete shape, fi , that
includes the backdrop contribution.)
As a result of these corrections, the effect of compositing objects as a group is the
same as that of compositing them separately (without grouping) if the following
conditions hold:
• The group is non-isolated and has the same knockout attribute as its parent
group (see Sections 7.3.4, “Isolated Groups,” and 7.3.5, “Knockout Groups”).
• When compositing the group’s results with the group backdrop, the Normal
blend mode is used, and the shape and opacity inputs are always 1.0.
7.3.4
Isolated Groups
An isolated group is one whose elements are composited onto a fully transparent
initial backdrop rather than onto the group’s backdrop. The resulting source
539
SECTION 7.3
Transparency Groups
color, object shape, and object alpha for the group are therefore independent of
the group backdrop. The only interaction with the group backdrop occurs when
the group’s computed color, shape, and alpha are then composited with it.
In particular, the special effects produced by the blend modes of objects within
the group take into account only the intrinsic colors and opacities of those ob-
jects; they are not influenced by the group’s backdrop. For example, applying the
Multiply blend mode to an object in the group produces a darkening effect on
other objects lower in the group’s stack but not on the group’s backdrop.
Plate 17 illustrates this effect for a group consisting of four overlapping circles in a
light gray color (C = M = Y = 0.0; K = 0.15). The circles are painted within the
group with opacity 1.0 in the Multiply blend mode; the group itself is painted
against its backdrop in Normal blend mode. In the top row, the group is isolated
and thus does not interact with the rainbow backdrop. In the bottom row, the
group is non-isolated and composites with the backdrop. The plate also illustrates
the difference between knockout and non-knockout groups (see Section 7.3.5,
“Knockout Groups”).
The effect of an isolated group can be represented by a simple object that directly
specifies a color, shape, and opacity at each point. This flattening of an isolated
group is sometimes useful for importing and exporting fully composited artwork
in applications. Furthermore, a group that specifies an explicit blending color
space must be an isolated group.
For an isolated group, the group compositing formulas are altered by simply add-
ing one statement to the initialization:
α0 = 0.0
if the group is isolated
That is, the initial backdrop on which the elements of the group are composited is
transparent rather than inherited from the group’s backdrop. This substitution
also makes C0 undefined, but the normal compositing formulas take care of that.
Also, the result computation for C automatically simplifies to C = Cn , since there
is no backdrop contribution to be factored out.
7.3.5
Knockout Groups
In a knockout group, each individual element is composited with the group’s
initial backdrop rather than with the stack of preceding elements in the group.
540
CHAPTER 7
Transparency
When objects have binary shapes (1.0 for inside, 0.0 for outside), each object
overwrites (knocks out) the effects of any earlier elements it overlaps within the
same group. At any given point, only the topmost object enclosing the point con-
tributes to the result color and opacity of the group as a whole.
Plate 17, already discussed above in Section 7.3.4, “Isolated Groups,” illustrates
the difference between knockout and non-knockout groups. In the left column,
the four overlapping circles are defined as a knockout group and therefore do not
composite with each other within the group. In the right column, the circles form
a non-knockout group and thus do composite with each other. In each column,
the upper and lower figures depict an isolated and a non-isolated group, respec-
tively.
This model is similar to the opaque imaging model, except that the “topmost
object wins” rule applies to both the color and the opacity. Knockout groups are
useful in composing a piece of artwork from a collection of overlapping objects,
where the topmost object in any overlap completely obscures those beneath. At
the same time, the topmost object interacts with the group’s initial backdrop in
the usual way, with its opacity and blend mode applied as appropriate.
The concept of knockout is generalized to accommodate fractional shape values.
In that case, the immediate backdrop is only partially knocked out and replaced
by only a fraction of the result of compositing the object with the initial backdrop.
The restated group compositing formulas deal with knockout groups by intro-
ducing a new variable, b, which is a subscript that specifies which previous result
to use as the backdrop in the compositing computations: 0 in a knockout group
or i − 1 in a non-knockout group. When b = i − 1, the formulas simplify to the
ones given in Section 7.3.3, “Group Compositing Computations.”
In the general case, the computation proceeds in two stages:
1. Composite the object with the group’s initial backdrop, disregarding the ob-
ject’s shape and using a source shape value of 1.0 everywhere. This produces
unnormalized temporary alpha and color results, αt and Ct . (For color, this
541
SECTION 7.3
Transparency Groups
computation is essentially the same as the unsimplified color compositing for-
mula given in Section 7.2.5, “Interpretation of Alpha,” but using a source shape
of 1.0.)
αt = Union(αg
,
qs
)
b
i
Ct
=
(1
-
qs
)× αb× Cb
+
qs
×((
1
-
αb
)× Cs
+
αb × Bi (Cb, Cs
))
i
i
i
i
2. Compute a weighted average of this result with the object’s immediate back-
drop, using the source shape as the weighting factor. Then normalize the result
color by the result alpha:
αg
=
(1
-
fs
)× αg
+
fs
×
αt
i
i
i-1
i
αi
=
Union(α0,αg
)
i
(1
-
fs
)× αi-1
×
Ci-1
+
fs
×
Ct
i
Ci
= ---------------
α
i
This averaging computation is performed for both color and alpha. The formulas
above show this averaging directly. The formulas in Section 7.3.7, “Summary of
Group Compositing Computations,” are slightly altered to use source shape and
alpha rather than source shape and opacity, avoiding the need to compute a
source opacity value explicitly. (Note that Ct there is slightly different from Ct
above: it is premultiplied by
.)
fs
i
The extreme values of the source shape produce the straightforward knockout
effect. That is, a shape value of 1.0 (inside) yields the color and opacity that result
from compositing the object with the initial backdrop. A shape value of 0.0 (out-
side) leaves the previous group results unchanged. The existence of the knockout
feature is the main reason for maintaining a separate shape value rather than only
a single alpha that combines shape and opacity. The separate shape value must be
computed in any group that is subsequently used as an element of a knockout
group.
A knockout group can be isolated or non-isolated; that is, isolated and knockout
are independent attributes. A non-isolated knockout group composites its top-
most enclosing element with the group’s backdrop. An isolated knockout group
composites the element with a transparent backdrop.
542
CHAPTER 7
Transparency
Note: When a non-isolated group is nested within a knockout group, the initial
backdrop of the inner group is the same as that of the outer group; it is not the im-
mediate backdrop of the inner group. This behavior, although perhaps unexpected,
is a consequence of the group compositing formulas when b = 0.
7.3.6
Page Group
All of the elements painted directly onto a page—both top-level groups and top-
level objects that are not part of any group—are treated as if they were contained
in a transparency group P, which in turn is composited with a context-dependent
backdrop. This group is called the page group.
The page group can be treated in two distinctly different ways:
• Ordinarily, the page is imposed directly on an output medium, such as paper or
a display screen. The page group is treated as an isolated group, whose results
are then composited with a backdrop color appropriate for the medium. The
backdrop is nominally white, although varying according to the actual proper-
ties of the medium. However, some applications may choose to provide a dif-
ferent backdrop, such as a checkerboard or grid to aid in visualizing the effects
of transparency in the artwork.
• A “page” of a PDF file can be treated as a graphics object to be used as an ele-
ment of a page of some other document. This case arises, for example, when
placing a PDF file containing a piece of artwork produced by Illustrator into a
page layout produced by InDesign®. In this situation, the PDF “page” is not
composited with the media color; instead, it is treated as an ordinary transpar-
ency group, which can be either isolated or non-isolated and is composited
with its backdrop in the normal way.
The remainder of this section pertains only to the first use of the page group,
where it is to be imposed directly on the medium.
The color C of the page at a given point is defined by a simplification of the gen-
eral group compositing formula:
·
〈
Cg, fg, αg
〉
=
Composite(U, 0, P)
C
=
(
1
-
αg
)×W + αg×Cg
543
SECTION 7.3
Transparency Groups
where the variables have the meanings shown in Table 7.9. The first formula com-
putes the color and alpha for the group given a transparent backdrop—in effect,
treating P as an isolated group. The second formula composites the results with
the context-dependent backdrop (using the equivalent of the Normal blend
mode).
TABLE 7.9 Variables used in the page group compositing formulas
VARIABLE
MEANING
P
The page group, consisting of all elements E1, … , En in the page’s
top-level stack
Cg
Computed color of the page group
fg
Computed shape of the page group
αg
Computed alpha of the page group
C
Computed color of the page
W
Initial color of the page (nominally white but may vary depending
on the properties of the medium or the needs of the application)
U
An undefined color (which is not used, since the α0 argument of
Composite is 0)
If not otherwise specified, the page group’s color space is inherited from the
native color space of the output device—that is, a device color space, such as
DeviceRGB or DeviceCMYK. It is often preferable to specify an explicit color space,
particularly a CIE-based space, to ensure more predictable results of the compos-
iting computations within the page group. In this case, all page-level compositing
is done in the specified color space, with the entire result then converted to the
native color space of the output device before being composited with the context-
dependent backdrop. This case also arises when the page is not actually being
rendered but is converted to a flattened representation in an opaque imaging
model, such as PostScript.
544
CHAPTER 7
Transparency
7.3.7
Summary of Group Compositing Computations
The following restatement of the group compositing formulas also takes isolated
groups and knockout groups into account. See Tables 7.7 and 7.8 on pages 534
and 536 for the meanings of the variables.
〈C, f, α 〉
=
Composite(C0, α0,
G
)
• Initialization:
fg
=
α
=
0
g0
0
α0 = 0
if the group is isolated
• For each group element Ei ∈ G (i = 1, … , n):
⎧
0
if the group is knockout
b
=
⎨
⎩i-1
otherwise
⎧
Composite(Cb,
αb,
Ei)
if Ei is a group
〈
〉
=
⎨
Csi, fji, αji
⎩
intrinsic color, shape, and (shape × opacity) of Ei
otherwise
fs
=
fj
×
fm
×
f
ki
i
i
i
αs
=
αj
×
( fm
×
qm
)
×
(fk
×
q
)
ki
i
i
i
i
i
fg
=
Union(fg
,
f
)
si
i
i-1
αg
=
(1
-
fs
)× αg
+
( fs
-
αs
)× αg
+
α
si
i
i
i-1
i
i
b
αi
=
Union(α0,α
)
gi
Ct
=
( fs
-
αs
)× αb× Cb
+
αs
×((
1
-
αb
)× Cs
+
αb ×Bi (Cb,C
))
si
i
i
i
i
(1
-
fs
)× αi-1
×
Ci-1
+
Ct
Ci = ---------------
--------------------------------------------------------
αi
545
SECTION 7.4
Soft Masks
• Result:
⎛
α0
⎞
C = Cn + (Cn– C0)
×
⎜
-------- –α0⎟
α
⎝
gn
⎠
f
=
fg
n
α = αg
n
Note: Once again, keep in mind that these formulas are in their most general form.
They can be significantly simplified when some sources of shape and opacity are not
present or when shape and opacity need not be maintained separately. Furthermore,
in each specific type of group (isolated or not, knockout or not), some terms of these
formulas cancel or drop out. An efficient implementation should use the simplified
derived formulas.
7.4
Soft Masks
As stated in earlier sections, the shape and opacity values used in compositing an
object can include components called the mask shape (fm) and mask opacity
(qm), which originate from a source independent of the object. Such an indepen-
dent source, called a soft mask, defines values that can vary across different points
on the page. The word soft emphasizes that the mask value at a given point is not
limited to just 0.0 or 1.0 but can take on intermediate fractional values as well.
Such a mask is typically the only means of providing position-dependent opacity
values, since elementary objects do not have intrinsic opacity of their own.
A mask used as a source of shape values is also called a soft clip, by analogy with
the “hard” clipping path of the opaque imaging model (see Section 4.4.3, “Clip-
ping Path Operators”). The soft clip is a generalization of the hard clip: a hard clip
can be represented as a soft clip having shape values of 1.0 inside and 0.0 outside
the clipping path. Everywhere inside a hard clipping path, the source object’s col-
or replaces the backdrop; everywhere outside, the backdrop shows through un-
changed. With a soft clip, by contrast, a gradual transition can be created between
an object and its backdrop, as in a vignette.
A mask can be defined by creating a transparency group and painting objects into
it, thereby defining color, shape, and opacity in the usual way. The resulting group
can then be used to derive the mask in either of two ways, as described in the fol-
lowing sections.
546
CHAPTER 7
Transparency
7.4.1
Deriving a Soft Mask from Group Alpha
In the first method of defining a soft mask, the color, shape, and opacity of a
transparency group G are first computed by the usual formula
〈 C, f, α 〉
=
Composite(C0, α0
,
G
)
where C0 and α0 represent an arbitrary backdrop whose value does not contrib-
ute to the eventual result. The C, f, and α results are the group’s color, shape, and
alpha, respectively, with the backdrop factored out.
The mask value at each point is then derived from the alpha of the group. Since
the group’s color is not used in this case, there is no need to compute it. The alpha
value is passed through a separately specified transfer function, allowing the
masking effect to be customized.
7.4.2
Deriving a Soft Mask from Group Luminosity
The second method of deriving a soft mask from a transparency group begins by
compositing the group with a fully opaque backdrop of some selected color. The
mask value at any given point is then defined to be the luminosity of the resulting
color. This allows the mask to be derived from the shape and color of an arbitrary
piece of artwork drawn with ordinary painting operators.
The color C used to create the mask from a group G is defined by
·
〈
Cg, fg, αg
〉
=
Composite(C0, 1, G )
C
=
(
1
-
αg
)× C0
+
αg ×Cg
where C0 is the selected backdrop color.
547
SECTION 7.5
Specifying Transparency in PDF
G can be any kind of group—isolated or not, knockout or not—producing vari-
ous effects on the C result in each case. The color C is then converted to luminos-
ity in one of the following ways, depending on the group’s color space:
• For CIE-based spaces, convert to the CIE 1931 XYZ space and use the Y com-
ponent as the luminosity. This produces a colorimetrically correct luminosity.
In the case of a PDF CalRGB space, the formula is
GR
GG
GB
Y = YA × A
+
YB × B
+
YC × C
using components of the Gamma and Matrix entries of the color space dictio-
nary (see Table 4.14 on page 248). An analogous computation applies to other
CIE-based color spaces.
• For device color spaces, convert the color to DeviceGray by device-dependent
means and use the resulting gray value as the luminosity, with no compensa-
tion for gamma or other color calibration. This method makes no pretense of
colorimetric correctness; it merely provides a numerically simple means to pro-
duce continuous-tone mask values. Here are some recommended formulas for
converting from DeviceRGB and DeviceCMYK, respectively:
Y = 0.30 × R + 0.59 × G + 0.11 × B
Y = 0.30 × (1 - C) × (1 - K)
+ 0.59 × (1 - M) × (1 - K)
+ 0.11 × (1 - Y) × (1 - K)
Following this conversion, the result is passed through a separately specified
transfer function, allowing the masking effect to be customized.
The backdrop color most likely to be useful is black, which causes any areas out-
side the group’s shape to have zero luminosity values in the resulting mask. If the
contents of the group are viewed as a positive mask, this produces the results that
would be expected with respect to points outside the shape.
7.5
Specifying Transparency in PDF
The preceding sections have presented the transparent imaging model at an
abstract level, with little mention of its representation in PDF. This section
describes the facilities available for specifying transparency in PDF 1.4.
548
CHAPTER 7
Transparency
7.5.1
Specifying Source and Backdrop Colors
Single graphics objects, as defined in Section 4.1, “Graphics Objects,” are treated
as elementary objects for transparency compositing purposes (subject to special
treatment for text objects, as described in Section 5.2.7, “Text Knockout”). That
is, all of a given object is considered to be one element of a transparency stack.
Portions of an object are not composited with one another, even if they are de-
scribed in a way that would seem to cause overlaps (such as a self-intersecting
path, combined fill and stroke of a path, or a shading pattern containing an
overlap or fold-over). An object’s source color Cs , used in the color compositing
formula, is specified in the same way as in the opaque imaging model: by means
of the current color in the graphics state or the source samples in an image. The
backdrop color Cb is the result of previous painting operations.
7.5.2
Specifying Blending Color Space and Blend Mode
The blending color space is an attribute of the transparency group within which
an object is painted; its specification is described in Section 7.5.5, “Transparency
Group XObjects.” The page as a whole is also treated as a group, the page group
(see Section 7.3.6, “Page Group”), with a color space attribute of its own. If not
otherwise specified, the page group’s color space is inherited from the native color
space of the output device.
The blend mode B (Cb , Cs ) is determined by the current blend mode parameter in
the graphics state (see Section 4.3, “Graphics State”), which is specified by the BM
entry in a graphics state parameter dictionary (Section 4.3.4, “Graphics State Pa-
rameter Dictionaries”). Its value is either a name object, designating one of the
standard blend modes listed in Tables 7.2 and 7.3 on pages 520 and 524, or an ar-
ray of such names. In the latter case, the application should use the first blend
mode in the array that it recognizes (or Normal if it recognizes none of them).
Therefore, new blend modes can be introduced in the future, and applications
that do not recognize them have reasonable fallback behavior. (See implementa-
tion note 72 in Appendix H.)
Note: The current blend mode always applies to process color components but only
sometimes to spot colorants; see “Blend Modes and Overprinting” on page 566 for
details.
549
SECTION 7.5
Specifying Transparency in PDF
7.5.3
Specifying Shape and Opacity
As discussed under “Source Shape and Opacity” on page 526, the shape (f) and
opacity (q) values used in the compositing computation can come from a variety
of sources:
• The intrinsic shape (fj ) and opacity (qj ) of the object being composited
• A separate shape (fm ) or opacity (qm ) mask independent of the object itself
• A scalar shape (fk ) or opacity (qk ) constant to be added at every point
The following sections describe how each of these shape and opacity sources are
specified in PDF.
Object Shape and Opacity
The shape value fj of an object painted with PDF painting operators is defined as
follows:
• For objects defined by a path or a glyph and painted in a uniform color with a
path-painting or text-showing operator (Sections 4.4.2, “Path-Painting Opera-
tors,” and 5.3.2, “Text-Showing Operators”), the shape is always 1.0 inside and
0.0 outside the path.
• For images (Section 4.8, “Images”), the shape is nominally 1.0 inside the image
rectangle and 0.0 outside it. This can be further modified by an explicit or color
key mask (“Explicit Masking” on page 351 and “Color Key Masking” on page
351).
• For image masks (“Stencil Masking” on page 350), the shape is 1.0 for painted
areas and 0.0 for masked areas.
• For objects painted with a tiling pattern (Section 4.6.2, “Tiling Patterns”) or a
shading pattern (Section 4.6.3, “Shading Patterns), the shape is further con-
strained by the objects that define the pattern (see Section 7.5.6, “Patterns and
Transparency”).
• For objects painted with the sh operator (“Shading Operator” on page 303), the
shape is 1.0 inside and 0.0 outside the bounds of the shading’s painting
geometry, disregarding the Background entry in the shading dictionary (see
“Shading Dictionaries” on page 304).
550
CHAPTER 7
Transparency
All elementary objects have an intrinsic opacity qj of 1.0 everywhere. Any desired
opacity less than 1.0 must be applied by means of an opacity mask or constant, as
described in the following sections.
Mask Shape and Opacity
At most one mask input—called a soft mask, or alpha mask—can be provided to
any PDF compositing operation. The mask can serve as a source of either shape
(fm ) or opacity (qm ) values, depending on the setting of the alpha source parame-
ter in the graphics state (see Section 4.3, “Graphics State”). This is a boolean flag,
set with the AIS (“alpha is shape”) entry in a graphics state parameter dictionary
(Section 4.3.4, “Graphics State Parameter Dictionaries”): true if the soft mask
contains shape values, false for opacity.
The soft mask can be specified in one of the following ways:
• The current soft mask parameter in the graphics state, set with the SMask entry
in a graphics state parameter dictionary, contains a soft-mask dictionary (see
“Soft-Mask Dictionaries” on page 552) defining the contents of the mask. The
name None may be specified in place of a soft-mask dictionary, denoting the
absence of a soft mask. In this case, the mask shape or opacity is implicitly 1.0
everywhere. (See implementation note 72 in Appendix H.)
• An image XObject can contain its own soft-mask image in the form of a subsid-
iary image XObject in the SMask entry of the image dictionary (see Section
4.8.4, “Image Dictionaries”). This mask, if present, overrides any explicit or col-
or key mask specified by the image dictionary’s Mask entry. Either form of
mask in the image dictionary overrides the current soft mask in the graphics
state. (See implementation note 73 in Appendix H.)
• An image XObject that has a JPXDecode filter as its data source can specify an
SMaskInData entry, indicating that the soft mask is embedded in the data
stream (see Section 3.3.8, “JPXDecode Filter”).
Note: The current soft mask in the graphics state is intended to be used to clip only a
single object at a time (either an elementary object or a transparency group). If a
soft mask is applied when painting two or more overlapping objects, the effect of the
mask multiplies with itself in the area of overlap (except in a knockout group), pro-
ducing a result shape or opacity that is probably not what is intended. To apply a
soft mask to multiple objects, it is usually best to define the objects as a transparency
551
SECTION 7.5
Specifying Transparency in PDF
group and apply the mask to the group as a whole. These considerations also apply
to the current alpha constant (see the next section).
Constant Shape and Opacity
The current alpha constant parameter in the graphics state (see Section 4.3,
“Graphics State”) specifies two scalar values—one for strokes and one for all
other painting operations—to be used for the constant shape (fk) or constant
opacity (qk) component in the color compositing formulas. This parameter can
be thought of as analogous to the current color used when painting elementary
objects. (Note, however, that the nonstroking alpha constant is also applied when
painting a transparency group’s results onto its backdrop; see also implementa-
tion note 72 in Appendix H.)
The stroking and nonstroking alpha constants are set, respectively, by the CA and
ca entries in a graphics state parameter dictionary (see Section 4.3.4, “Graphics
State Parameter Dictionaries”). As described above for the soft mask, the alpha
source flag in the graphics state determines whether the alpha constants are inter-
preted as shape values (true) or opacity values (false).
Note: The note at the end of “Mask Shape and Opacity,” above, applies to the cur-
rent alpha constant parameter as well as the current soft mask.
7.5.4
Specifying Soft Masks
As noted under “Mask Shape and Opacity” on page 550, soft masks for use in
compositing computations can be specified in one of the following ways:
• As a soft-mask dictionary in the current soft mask parameter of the graphics
state; see “Soft-Mask Dictionaries,” below, for more details.
• As a soft-mask image associated with a sampled image; see “Soft-Mask Images”
on page 553 for more details.
• (In PDF 1.5) as a mask channel embedded in JPEG2000 encoded data; see Sec-
tion 3.3.8, “JPXDecode Filter,” and the SMaskInData entry of Table 4.39 for
more details.
552
CHAPTER 7
Transparency
Soft-Mask Dictionaries
The most common way of defining a soft mask is with a soft-mask dictionary
specified as the current soft mask in the graphics state (see Section 4.3, “Graphics
State”). Table 7.10 shows the contents of this type of dictionary. (See implementa-
tion note 72 in Appendix H.)
The mask values are derived from those of a transparency group, using one of the
two methods described in Sections 7.4.1, “Deriving a Soft Mask from Group
Alpha,” and 7.4.2, “Deriving a Soft Mask from Group Luminosity.” The group is
defined by a transparency group XObject (see Section 7.5.5, “Transparency
Group XObjects”) designated by the G entry in the soft-mask dictionary. The S
(subtype) entry specifies which of the two derivation methods to use:
• If the subtype is Alpha, the transparency group XObject G is evaluated to com-
pute a group alpha only. The colors of the constituent objects are ignored and
the color compositing computations are not performed. The transfer function
TR is then applied to the computed group alpha to produce the mask values.
Outside the bounding box of the transparency group, the mask value is the re-
sult of applying the transfer function to the input value 0.0.
• If the subtype is Luminosity, the transparency group XObject G is composited
with a fully opaque backdrop whose color is everywhere defined by the soft-
mask dictionary’s BC entry. The computed result color is then converted to a
single-component luminosity value, and the transfer function TR is applied to
this luminosity to produce the mask values. Outside the transparency group’s
bounding box, the mask value is derived by transforming the BC color to lumi-
nosity and applying the transfer function to the result.
The mask’s coordinate system is defined by concatenating the transformation
matrix specified by the Matrix entry in the transparency group’s form dictio-
nary (see Section 4.9.1, “Form Dictionaries”) with the current transformation
matrix at the moment the soft mask is established in the graphics state with the
gs operator.
Note: In a transparency group XObject that defines a soft mask, spot color compo-
nents are never available, even if they are available in the group or page on which
the soft mask is used. If the group XObject’s content stream specifies a Separation or
DeviceN color space that uses spot color components, the alternate color space is
substituted (see “Separation Color Spaces” on page 264 and “DeviceN Color Spaces”
on page 268).
553
SECTION 7.5
Specifying Transparency in PDF
TABLE 7.10 Entries in a soft-mask dictionary
KEY
TYPE
VALUE
Type
name
(Optional) The type of PDF object that this dictionary describes; if present,
must be Mask for a soft-mask dictionary.
S
name
(Required) A subtype specifying the method to be used in deriving the mask
values from the transparency group specified by the G entry:
Alpha
Use the group’s computed alpha, disregarding its color (see
Section 7.4.1, “Deriving a Soft Mask from Group Alpha”).
Luminosity Convert the group’s computed color to a single-component
luminosity value (see Section 7.4.2, “Deriving a Soft Mask
from Group Luminosity”).
G
stream
(Required) A transparency group XObject (see Section 7.5.5, “Transparency
Group XObjects”) to be used as the source of alpha or color values for deriv-
ing the mask. If the subtype S is Luminosity, the group attributes dictionary
must contain a CS entry defining the color space in which the compositing
computation is to be performed.
BC
array
(Optional) An array of component values specifying the color to be used as
the backdrop against which to composite the transparency group XObject G.
This entry is consulted only if the subtype S is Luminosity. The array consists
of n numbers, where n is the number of components in the color space speci-
fied by the CS entry in the group attributes dictionary (see Section 7.5.5,
“Transparency Group XObjects”). Default value: the color space’s initial
value, representing black.
TR
function or name
(Optional) A function object (see Section 3.9, “Functions”) specifying the
transfer function to be used in deriving the mask values. The function ac-
cepts one input, the computed group alpha or luminosity (depending on the
value of the subtype S), and returns one output, the resulting mask value.
Both the input and output must be in the range 0.0 to 1.0; if the computed
output falls outside this range, it is forced to the nearest valid value. The
name Identity may be specified in place of a function object to designate the
identity function. Default value: Identity.
Soft-Mask Images
The second way to define a soft mask is by associating a soft-mask image with an
image XObject. This is a subsidiary image XObject specified in the SMask entry
554
CHAPTER 7
Transparency
of the parent XObject’s image dictionary (see Section 4.8.4, “Image Dictionaries”;
see also implementation note 73 in Appendix H). Entries in the subsidiary image
dictionary for such a soft-mask image have the same format and meaning as in
that of an ordinary image XObject (as described in Table 4.39 on page 340), sub-
ject to the restrictions listed in Table 7.11. This type of image dictionary can also
optionally contain an additional entry, Matte, discussed below.
When an image is accompanied by a soft-mask image, it is sometimes advanta-
geous for the image data to be preblended with some background color, called the
matte color. Each image sample represents a weighted average of the original
source color and the matte color, using the corresponding mask sample as the
weighting factor. (This is a generalization of a technique commonly called pre-
multiplied alpha.)
If the image data is preblended, the matte color must be specified by a Matte
entry in the soft-mask image dictionary (see Table 7.12). The preblending com-
putation, performed independently for each component, is
c'
= m + α×(c-m)
where
c′ is the value to be provided in the image source data
c is the original image component value
m is the matte color component value
α is the corresponding mask sample
Note: This computation uses actual color component values, with the effects of the
Filter and Decode transformations already performed. The computation is the same
whether the color space is additive or subtractive.
TABLE 7.11 Restrictions on the entries in a soft-mask image dictionary
KEY
RESTRICTION
Type
If present, must be XObject.
Subtype
Must be Image.
555
SECTION 7.5
Specifying Transparency in PDF
KEY
RESTRICTION
Width
If a Matte entry (see Table 7.12, below) is present, must be the
same as the Width value of the parent image; otherwise inde-
pendent of it. Both images are mapped to the unit square in
user space (as are all images), regardless of whether the sam-
ples coincide individually.
Height
Same considerations as for Width.
ColorSpace
Required; must be DeviceGray.
BitsPerComponent
Required.
Intent
Ignored.
ImageMask
Must be false or absent.
Mask
Must be absent.
SMask
Must be absent.
Decode
Default value: [ 0 1 ].
Interpolate
Optional.
Alternates
Ignored.
Name
Ignored.
StructParent
Ignored.
ID
Ignored.
OPI
Ignored.
TABLE 7.12
Additional entry in a soft-mask image dictionary
KEY
TYPE
VALUE
Matte
array
(Optional; PDF 1.4) An array of component values specifying the matte color with
which the image data in the parent image has been preblended. The array consists of n
numbers, where n is the number of components in the color space specified by the
ColorSpace entry in the parent image’s image dictionary; the numbers must be valid
color components in that color space. If this entry is absent, the image data is not
preblended.
556
CHAPTER 7
Transparency
When preblended image data is used in transparency blending and compositing
computations, the results are the same as if the original, unblended image data
were used and no matte color were specified. In particular, the inputs to the blend
function are the original color values. To derive c from c′, the application may
sometimes need to invert the formula shown above. If the resulting c value lies
outside the range of color component values for the image color space, the results
are unpredictable.
The preblending computation is done in the color space specified by the parent
image’s ColorSpace entry. This is independent of the group color space into which
the image may be painted. If a color conversion is required, inversion of the preb-
lending must precede the color conversion. If the image color space is an Indexed
space (see “Indexed Color Spaces” on page 262), the color values in the color table
(not the index values themselves) are preblended.
7.5.5
Transparency Group XObjects
A transparency group is represented in PDF as a special type of group XObject
(see Section 4.9.2, “Group XObjects”) called a transparency group XObject. A
group XObject is in turn a type of form XObject, distinguished by the presence of
a Group entry in its form dictionary (see Section 4.9.1, “Form Dictionaries”). The
value of this entry is a subsidiary group attributes dictionary defining the proper-
ties of the group. The format and meaning of the dictionary’s contents are deter-
mined by its group subtype, which is specified by the dictionary’s S entry. The
entries for a transparency group (subtype Transparency) are shown in Table 7.13.
Note: A page object (see “Page Objects” on page 144) may also have a Group entry,
whose value is a group attributes dictionary specifying the attributes of the page
group (see Section 7.3.6, “Page Group”). Some of the dictionary entries are inter-
preted slightly differently for a page group than for a transparency group XObject;
see their descriptions in the table for details.
TABLE 7.13 Additional entries specific to a transparency group attributes dictionary
KEY
TYPE
VALUE
S
name
(Required) The group subtype, which identifies the type of group whose at-
tributes this dictionary describes; must be Transparency for a transparency
group.
557
SECTION 7.5
Specifying Transparency in PDF
KEY
TYPE
VALUE
CS
name or array
(Sometimes required, as discussed below) The group color space, which is used
for the following purposes:
• As the color space into which colors are converted when painted into the
group
• As the blending color space in which objects are composited within the group
(see Section 7.2.3, “Blending Color Space”)
• As the color space of the group as a whole when it in turn is painted as an ob-
ject onto its backdrop
The group color space may be any device or CIE-based color space that treats its
components as independent additive or subtractive values in the range 0.0 to 1.0,
subject to the restrictions described in Section 7.2.3, “Blending Color Space.”
These restrictions exclude Lab and lightness-chromaticity ICCBased color spac-
es, as well as the special color spaces Pattern, Indexed, Separation, and DeviceN.
Device color spaces are subject to remapping according to the DefaultGray,
DefaultRGB, and DefaultCMYK entries in the ColorSpace subdictionary of the
current resource dictionary (see “Default Color Spaces” on page 257).
Ordinarily, the CS entry is allowed only for isolated transparency groups (those
for which I, below, is true), and even then it is optional. However, this entry is re-
quired in the group attributes dictionary for any transparency group XObject
that has no parent group or page from which to inherit—in particular, one that
is the value of the G entry in a soft-mask dictionary of subtype Luminosity (see
“Soft-Mask Dictionaries” on page 552).
In addition, it is always permissible to specify CS in the group attributes dictio-
nary associated with a page object, even if I is false or absent. In the normal case
in which the page is imposed directly on the output medium, the page group is
effectively isolated regardless of the I value, and the specified CS value is there-
fore honored. But if the page is in turn used as an element of some other page
and if the group is non-isolated, CS is ignored and the color space is inherited
from the actual backdrop with which the page is composited (see Section 7.3.6,
“Page Group”).
Default value: the color space of the parent group or page into which this trans-
parency group is painted. (The parent’s color space in turn can be either explicit-
ly specified or inherited.)
Note: For a transparency group XObject used as an annotation appearance (see
Section 8.4.4, “Appearance Streams”), the default color space is inherited from the
page on which the annotation appears.
558
CHAPTER 7
Transparency
KEY
TYPE
VALUE
I
boolean
(Optional) A flag specifying whether the transparency group is isolated (see Sec-
tion 7.3.4, “Isolated Groups”). If this flag is true, objects within the group are
composited against a fully transparent initial backdrop; if false, they are com-
posited against the group’s backdrop. Default value: false.
In the group attributes dictionary for a page, the interpretation of this entry is
slightly altered. In the normal case in which the page is imposed directly on the
output medium, the page group is effectively isolated and the specified I value is
ignored. But if the page is in turn used as an element of some other page, it is
treated as if it were a transparency group XObject; the I value is interpreted in
the normal way to determine whether the page group is isolated.
K
boolean
(Optional) A flag specifying whether the transparency group is a knockout
group (see Section 7.3.5, “Knockout Groups”). If this flag is false, later objects
within the group are composited with earlier ones with which they overlap; if
true, they are composited with the group’s initial backdrop and
overwrite
(“knock out”) any earlier overlapping objects. Default value: false.
The transparency group XObject’s content stream defines the graphics objects be-
longing to the group. Invoking the Do operator on the XObject executes its con-
tent stream and composites the resulting group color, shape, and opacity into the
group’s parent group or page as if they had come from an elementary graphics ob-
ject. When applied to a transparency group XObject, Do performs the following
actions in addition to the normal ones for a form XObject (as described in Sec-
tion 4.9, “Form XObjects”):
• If the transparency group is non-isolated (the value of the I entry in its group
attributes dictionary is false), its initial backdrop, within the bounding box
specified by the XObject’s BBox entry, is defined to be the accumulated color
and alpha of the parent group or page—that is, the result of everything that has
been painted in the parent up to that point. (However, if the parent is a knock-
out group, the initial backdrop is the same as that of the parent.) If the group is
isolated (I is true), its initial backdrop is defined to be transparent.
• Before execution of the transparency group XObject’s content stream, the cur-
rent blend mode in the graphics state is initialized to Normal, the current strok-
ing and nonstroking alpha constants to 1.0, and the current soft mask to None.
Note: The purpose of initializing these graphics state parameters at the beginning
of execution is to ensure that they are not applied twice: once when member ob-
jects are painted into the group and again when the group is painted into the par-
ent group or page.
559
SECTION 7.5
Specifying Transparency in PDF
• Objects painted by operators in the transparency group XObject’s content
stream are composited into the group according to the rules described in Sec-
tion 7.2.2, “Basic Compositing Formula.” The knockout flag (K) in the group at-
tributes dictionary and the transparency-related parameters of the graphics
state contribute to this computation.
• If a group color space (CS) is specified in the group attributes dictionary, all
painting operators convert source colors to that color space before compositing
objects into the group, and the resulting color at each point is interpreted in
that color space. If no group color space is specified, the prevailing color space
is dynamically inherited from the parent group or page. (If not otherwise spec-
ified, the page group’s color space is inherited from the native color space of the
output device.)
• After execution of the transparency group XObject’s content stream, the graph-
ics state reverts to its former state before the invocation of the Do operator (as it
does for any form XObject). The group’s shape—the union of all objects paint-
ed into the group, clipped by the group XObject’s bounding box—is then paint-
ed into the parent group or page, using the group’s accumulated color and
opacity at each point.
Note: If the Do operator is invoked more than once for a given transparency group
XObject, each invocation is treated as a separate transparency group. That is, the
result is as if the group were independently composited with the backdrop on each
invocation. Applications that perform caching of rendered form XObjects must take
this requirement into account.
The actions described above occur only for a transparency group XObject—a
form XObject having a Group entry that designates a group attributes subdic-
tionary whose group subtype (S) is Transparency. An ordinary form XObject—
one having no Group entry—is not subject to any grouping behavior for transpar-
ency purposes. That is, the graphics objects it contains are composited individu-
ally, just as if they were painted directly into the parent group or page.
7.5.6
Patterns and Transparency
In the transparent imaging model, the graphics objects making up the pattern cell
of a tiling pattern (see Section 4.6.2, “Tiling Patterns”) can include transparent
objects and transparency groups. Transparent compositing can occur both within
the pattern cell and between it and the backdrop wherever the pattern is painted.
560
CHAPTER 7
Transparency
Similarly, a shading pattern (Section 4.6.3, “Shading Patterns”) composites with
its backdrop as if the shading dictionary were applied with the sh operator.
In both cases, the pattern definition is treated as if it were implicitly enclosed in a
non-isolated transparency group: a non-knockout group for tiling patterns, a
knockout group for shading patterns. The definition does not inherit the current
values of the graphics state parameters at the time it is evaluated; these take effect
only when the resulting pattern is later used to paint an object. Instead, the
graphics state parameters are initialized as follows:
• As always for transparency groups, those parameters related to transparency
(blend mode, soft mask, and alpha constant) are initialized to their standard
default values.
• All other parameters are initialized to their values at the beginning of the con-
tent stream (such as a page or a form XObject) in which the pattern is defined
as a resource. This is the normal behavior for all patterns, in both the opaque
and transparent imaging models.
• In the case of a shading pattern, the parameter values may be augmented by the
contents of the ExtGState entry in the pattern dictionary (see Section 4.6.3,
“Shading Patterns”). Only those parameters that affect the sh operator, such as
the current transformation matrix and rendering intent, are used. Parameters
that affect path-painting operators are not used, since the execution of sh does
not entail painting a path.
• If the shading dictionary has a Background entry, the pattern’s implicit trans-
parency group is filled with the specified background color before the sh oper-
ator is invoked.
When the pattern is later used to paint a graphics object, the color, shape, and
opacity values resulting from the evaluation of the pattern definition are used as
the object’s source color (Cs ), object shape (fj ), and object opacity (qj ) in the
transparency compositing formulas. This painting operation is subject to the val-
ues of the graphics state parameters in effect at the time, just as in painting an ob-
ject with a constant color.
Unlike the opaque imaging model, in which the pattern cell of a tiling pattern can
be evaluated once and then replicated indefinitely to fill the painted area, the
effect in the general transparent case is as if the pattern definition were reexecut-
ed independently for each tile, taking into account the color of the backdrop at
each point. However, in the common case in which the pattern consists entirely
561
SECTION 7.6
Color Space and Rendering Issues
of objects painted with the Normal blend mode, this behavior can be optimized
by treating the pattern cell as if it were an isolated group. Since in this case the
results depend only on the color, shape, and opacity of the pattern cell and not on
those of the backdrop, the pattern cell can be evaluated once and then replicated,
just as in opaque painting.
Note: In a raster-based implementation of tiling, it is important that all tiles togeth-
er be treated as a single transparency group. This avoids artifacts due to multiple
marking of pixels along the boundaries between adjacent tiles.
The foregoing discussion applies to both colored (PaintType 1) and uncolored
(PaintType 2) tiling patterns. In the latter case, the restriction that an uncolored
pattern’s definition may not specify colors extends as well to any transparency
group that the definition may include. There are no corresponding restrictions,
however, on specifying transparency-related parameters in the graphics state.
7.6
Color Space and Rendering Issues
This section describes the interactions between transparency and other aspects of
color specification and rendering in the Adobe imaging model.
7.6.1
Color Spaces for Transparency Groups
As discussed in Section 7.5.5, “Transparency Group XObjects,” a transparency
group can either have an explicitly declared color space of its own or inherit that
of its parent group. In either case, the colors of source objects within the group
are converted to the group’s color space, if necessary, and all blending and com-
positing computations are done in that space (see Section 7.2.3, “Blending Color
Space”). The resulting colors are then interpreted in that color space when the
group is subsequently composited with its backdrop.
Under this arrangement, it is envisioned that all or most of a given piece of art-
work will be created in a single color space—most likely, the working color space
of the application generating it. The use of multiple color spaces typically will
arise only when assembling independently produced artwork onto a page. After
all the artwork has been placed on the page, the conversion from the group’s color
space to the page’s device color space will be done as the last step, without any
further transparency compositing. The transparent imaging model does not re-
quire that this convention be followed, however; the reason for adopting it is to
562
CHAPTER 7
Transparency
avoid the loss of color information and the introduction of errors resulting from
unnecessary color space conversions.
Only an isolated group may have an explicitly declared color space of its own.
Non-isolated groups must inherit their color space from the parent group (sub-
ject to special treatment for the page group, as described in Section 7.3.6, “Page
Group”). This is because the use of an explicit color space in a non-isolated group
would require converting colors from the backdrop’s color space to that of the
group in order to perform the compositing computations. Such conversion may
not be possible (since some color conversions can be performed only in one
direction), and even if possible, it would entail an excessive number of color con-
versions.
The choice of a group color space has significant effects on the results that are
produced:
• As noted in Section 7.2.3, “Blending Color Space,” the results of compositing in
a device color space is device-dependent. For the compositing computations to
work in a device-independent way, the group’s color space must be CIE-based.
• A consequence of choosing a CIE-based group color space is that only CIE-
based spaces can be used to specify the colors of objects within the group. This
is because conversion from device to CIE-based colors is not possible in gener-
al; the defined conversions work only in the opposite direction. See below for
further discussion.
• The compositing computations and blend functions generally compute linear
combinations of color component values, on the assumption that the compo-
nent values themselves are linear. For this reason, it is usually best to choose a
group color space that has a linear gamma function. If a nonlinear color space
is chosen, the results are still well-defined, but the appearance may not match
the user’s expectations. Note, in particular, that the CIE-based sRGB color
space (see page 256) is nonlinear and hence may be unsuitable for use as a
group color space.
Note: Implementations of the transparent imaging model are advised to use as
much precision as possible in representing colors during compositing computations
and in the accumulated group results. To minimize the accumulation of roundoff er-
rors and avoid additional errors arising from the use of linear group color spaces,
more precision is needed for intermediate results than is typically used to represent
either the original source data or the final rasterized results.
563
SECTION 7.6
Color Space and Rendering Issues
If a group’s color space—whether specified explicitly or inherited from the parent
group—is CIE-based, any use of device color spaces for painting objects is subject
to special treatment. Device colors cannot be painted directly into such a group,
since there is no generally defined method for converting them to the CIE-based
color space. This problem arises in the following cases:
• DeviceGray, DeviceRGB, and DeviceCMYK color spaces, unless remapped to de-
fault CIE-based color spaces (see “Default Color Spaces” on page 257)
• Operators (such as rg) that specify a device color space implicitly, unless that
space is remapped
• Special color spaces whose base or underlying space is a device color space, un-
less that space is remapped
It is recommended that the default color space remapping mechanism always be
employed when defining a transparency group whose color space is CIE-based. If a
device color is specified and is not remapped, it is converted to the CIE-based color
space in an implementation-dependent fashion, producing unpredictable results.
Note: The foregoing restrictions do not apply if the group’s color space is implicitly
converted to DeviceCMYK, as discussed in “Implicit Conversion of CIE-Based Color
Spaces” on page 259.
7.6.2
Spot Colors and Transparency
The foregoing discussion of color spaces has been concerned with process colors—
those produced by combinations of an output device’s process colorants. Process
colors may be specified directly in the device’s native color space (such as Device-
CMYK), or they may be produced by conversion from some other color space,
such as a CIE-based (CalRGB or ICCBased) space. Whatever means is used to
specify them, process colors are subject to conversion to and from the group’s col-
or space.
A spot color is an additional color component, independent of those used to pro-
duce process colors. It may represent either an additional separation to be
produced or an additional colorant to be applied to the composite page (see “Sep-
aration Color Spaces” on page 264 and “DeviceN Color Spaces” on page 268).
The color component value, or tint, for a spot color specifies the concentration of
the corresponding spot colorant. Tints are conventionally represented as subtrac-
tive, rather than additive, values.
564
CHAPTER 7
Transparency
Spot colors are inherently device-dependent and are not always available. In the
opaque imaging model, each use of a spot color component in a Separation or
DeviceN color space is accompanied by an alternate color space and a tint transfor-
mation function for mapping tint values into that space. This enables the color to
be approximated with process colorants when the corresponding spot colorant is
not available on the device.
Spot colors can be accommodated straightforwardly in the transparent imaging
model (except for issues relating to overprinting, discussed in Section 7.6.3,
“Overprinting and Transparency”). When an object is painted transparently with
a spot color component that is available in the output device, that color is com-
posited with the corresponding spot color component of the backdrop, indepen-
dently of the compositing that is performed for process colors. A spot color
retains its own identity; it is not subject to conversion to or from the color space
of the enclosing transparency group or page. If the object is an element of a trans-
parency group, one of two things can happen:
• The group maintains a separate color value for each spot color component,
independently of the group’s color space. In effect, the spot color passes directly
through the group hierarchy to the device, with no color conversions per-
formed. However, it is still subject to blending and compositing with other ob-
jects that use the same spot color.
• The spot color is converted to its alternate color space. The resulting color is
then subject to the usual compositing rules for process colors. In particular,
spot colors are never available in a transparency group XObject that is used to
define a soft mask; the alternate color space is always substituted in that case.
Only a single shape value and opacity value are maintained at each point in the
computed group results; they apply to both process and spot color components.
In effect, every object is considered to paint every existing color component, both
process and spot. Where no value has been explicitly specified for a given com-
ponent in a given object, an additive value of 1.0 (or a subtractive tint value of
0.0) is assumed. For instance, when painting an object with a color specified in a
DeviceCMYK or ICCBased color space, the process color components are painted
as specified and the spot color components are painted with an additive value of
1.0. Likewise, when painting an object with a color specified in a Separation color
space, the named spot color is painted as specified and all other components
(both process colors and other spot colors) are painted with an additive value of
1.0. The consequences of this are discussed in Section 7.6.3, “Overprinting and
Transparency.”
565
SECTION 7.6
Color Space and Rendering Issues
The opaque imaging model also allows process color components to be addressed
individually, as if they were spot colors. For instance, it is possible to specify a
Separation color space named Cyan, which paints just the cyan component on a
CMYK output device. However, this capability is very difficult to extend to trans-
parency groups. In general, the color components in a group are not the process
colorants themselves, but are converted to process colorants only after the com-
pletion of all color compositing computations for the group (and perhaps some of
its parent groups as well). For instance, if the group’s color space is ICCBased, the
group has no Cyan component to be painted. Consequently, treating a process
color component as if it were a spot color is permitted only within a group that
inherits the native color space of the output device (or is implicitly converted to
DeviceCMYK, as discussed in “Implicit Conversion of CIE-Based Color Spaces”
on page 259). Attempting to do so in a group that specifies its own color space re-
sults in conversion of the requested spot color to its alternate color space.
7.6.3
Overprinting and Transparency
In the opaque imaging model, overprinting is controlled by two parameters of the
graphics state: the overprint parameter and the overprint mode (see Section 4.5.6,
“Overprint Control”). Painting an object causes some specific set of device colo-
rants to be marked, as determined by the current color space and current color in
the graphics state. The remaining colorants are either erased or left unchanged,
depending on whether the overprint parameter is false or true. When the current
color space is DeviceCMYK, the overprint mode parameter additionally enables
this selective marking of colorants to be applied to individual color components
according to whether the component value is zero or nonzero.
Because this model of overprinting deals directly with the painting of device
colorants, independently of the color space in which source colors have been
specified, it is highly device-dependent and primarily addresses production
needs rather than design intent. Overprinting is usually reserved for opaque colo-
rants or for very dark colors, such as black. It is also invoked during late-stage
production operations such as trapping (see Section 10.10.5, “Trapping Sup-
port”), when the actual set of device colorants has already been determined.
Consequently, it is best to think of transparency as taking place in appearance
space, but overprinting of device colorants in device space. This means that colo-
rant overprint decisions should be made at output time, based on the actual re-
sultant colorants of any transparency compositing operation. On the other hand,
effects similar to overprinting can be achieved in a device-independent manner
by taking advantage of blend modes, as described in the next section.
566
CHAPTER 7
Transparency
Blend Modes and Overprinting
As stated in Section 7.6.2, “Spot Colors and Transparency,” each graphics object
that is painted affects all existing color components: all process colorants in the
transparency group’s color space as well as any available spot colorants. For color
components whose value has not been specified, a source color value of 1.0 is
assumed; when objects are fully opaque and the Normal blend mode is used, this
has the effect of erasing those components. This treatment is consistent with the
behavior of the opaque imaging model with the overprint parameter set to false.
The transparent imaging model defines some blend modes, such as Darken, that
can be used to achieve effects similar to overprinting. The blend function for
Darken is
B(cb,cs)
=
min(cb, cs
)
In this blend mode, the result of compositing is always the same as the backdrop
color when the source color is 1.0, as it is for all unspecified color components.
When the backdrop is fully opaque, this leaves the result color unchanged from
that of the backdrop. This is consistent with the behavior of the opaque imaging
model with the overprint parameter set to true.
If the object or backdrop is not fully opaque, the actions described above are al-
tered accordingly. That is, the erasing effect is reduced, and overprinting an ob-
ject with a color value of 1.0 may affect the result color. While these results may
or may not be useful, they lie outside the realm of the overprinting and erasing
behavior defined in the opaque imaging model.
When process colors are overprinted or erased (because a spot color is being paint-
ed), the blending computations described above are done independently for each
component in the group’s color space. If that space is different from the native col-
or space of the output device, its components are not the device’s actual process
colorants; the blending computations affect the process colorants only after the
group’s results are converted to the device color space. Thus the effect is different
from that of overprinting or erasing the device’s process colorants directly. On the
other hand, this is a fully general operation that works uniformly, regardless of the
type of object or of the computations that produced the source color.
The discussion so far has focused on those color components whose values are
not specified and that are to be either erased or left unchanged. However, the
567
SECTION 7.6
Color Space and Rendering Issues
Normal or Darken blend modes used for these purposes may not be suitable for
use on those components whose color values are specified. In particular, using
the Darken blend mode for such components would preclude overprinting a dark
color with a lighter one. Moreover, some other blend mode may be specifically
desired for those components.
The PDF graphics state specifies only one current blend mode parameter, which
always applies to process colorants and sometimes to spot colorants as well.
Specifically, only separable, white-preserving blend modes can be used for spot
colors. A blend mode is white-preserving if its blend function B has the property
that B (1.0, 1.0) = 1.0. (Of the standard separable blend modes listed in Table 7.2
on page 520, all except Difference and Exclusion are white-preserving.) If the
specified blend mode is not separable and white-preserving, it applies only to
process color components; the Normal blend mode is substituted for spot colors.
This ensures that when objects accumulate in an isolated transparency group, the
accumulated values for unspecified components remain 1.0 as long as only white-
preserving blend modes are used. The group’s results can then be overprinted us-
ing Darken (or other useful modes) while avoiding unwanted interactions with
components whose values were never specified within the group.
Compatibility with Opaque Overprinting
Because the use of blend modes to achieve effects similar to overprinting does
not make direct use of the overprint control parameters in the graphics state,
such methods are usable only by transparency-aware applications. For compati-
bility with the methods of overprint control used in the opaque imaging model, a
special blend mode, CompatibleOverprint, is provided that consults the over-
print-related graphics state parameters to compute its result. This mode applies
only when painting elementary graphics objects (fills, strokes, text, images, and
shadings). It is never invoked explicitly and is not identified by any PDF name
object; rather, it is implicitly invoked whenever an elementary graphics object is
painted while overprinting is enabled (that is, when the overprint parameter in
the graphics state is true).
Note: Earlier designs of the transparent imaging model included an additional
blend mode named Compatible, which explicitly invoked the CompatibleOverprint
blend mode described here. Because CompatibleOverprint is now invoked implicitly
whenever appropriate, it is never necessary to specify the Compatible blend mode
for use in compositing. It is still recognized as a valid blend mode for the sake of
compatibility but is simply treated as equivalent to Normal.
568
CHAPTER 7
Transparency
The value of the blend function B (cb , cs ) in the CompatibleOverprint mode is
either cb or cs , depending on the setting of the overprint mode parameter, the
current and group color spaces, and the source color value cs :
• If the overprint mode is 1 (nonzero overprint mode) and the current color
space and group color space are both DeviceCMYK, then only process color
components with nonzero values replace the corresponding component values
of the backdrop. All other component values leave the existing backdrop value
unchanged. That is, the value of the blend function B (cb , cs ) is the source com-
ponent cs for any process (DeviceCMYK) color component whose (subtractive)
color value is nonzero; otherwise it is the backdrop component cb . For spot col-
or components, the value is always cb .
• In all other cases, the value of B (cb , cs ) is cs for all color components specified
in the current color space, otherwise cb . For instance, if the current color space
is DeviceCMYK or CalRGB, the value of the blend function is cs for process color
components and cb for spot components. On the other hand, if the current col-
or space is a Separation space representing a spot color component, the value is
cs for that spot component and cb for all process components and all other spot
components.
Note: In the descriptions above, the term current color space refers to the color
space used for a painting operation. This may be specified by the current color space
parameter in the graphics state (see Section 4.5.1, “Color Values”), implicitly by col-
or operators such as rg (Section 4.5.7, “Color Operators”), or by the ColorSpace en-
try of an image XObject (Section 4.8.4, “Image Dictionaries”). In the case of an
Indexed space, it refers to the base color space (see “Indexed Color Spaces” on page
262); likewise for Separation and DeviceN spaces that revert to their alternate color
space, as described under “Separation Color Spaces” on page 264 and “DeviceN
Color Spaces” on page 268.
If the current blend mode when CompatibleOverprint is invoked is any mode
other than Normal, the object being painted is implicitly treated as if it were
defined in a non-isolated, non-knockout transparency group and painted using
the CompatibleOverprint blend mode. The group’s results are then painted using
the current blend mode in the graphics state.
Note: It is not necessary to create such an implicit transparency group if the current
blend mode is Normal; simply substituting the CompatibleOverprint blend mode
while painting the object produces equivalent results. There are some additional
cases in which the implicit transparency group can be optimized out.
569
SECTION 7.6
Color Space and Rendering Issues
Plate 20 shows the effects of all four possible combinations of blending and over-
printing, using the Screen blend mode in the DeviceCMYK color space. The label
“overprint enabled” means that the overprint parameter in the graphics state is
true and the overprint mode is 1. In the upper half of the figure, a light green oval
is painted opaquely (opacity = 1.0) over a backdrop shading from pure yellow to
pure magenta. In the lower half, the same object is painted with transparency
(opacity = 0.5).
Special Path-Painting Considerations
The overprinting considerations discussed above also affect those path-painting
operations that combine filling and stroking a path in a single operation. These
include the B, B*, b, and b* operators (see Section 4.4.2, “Path-Painting Opera-
tors”) and the painting of glyphs with text rendering mode 2 or 6 (Section 5.2.5,
“Text Rendering Mode”). For transparency compositing purposes, the combined
fill and stroke are treated as a single graphics object, as if they were enclosed in a
transparency group. This implicit group is established and used as follows:
• If overprinting is enabled (the overprint parameter in the graphics state is true)
and the current stroking and nonstroking alpha constants are equal, a non-
isolated, non-knockout transparency group is established. Within the group,
the fill and stroke are performed with an alpha value of 1.0 but with the Com-
patibleOverprint blend mode. The group results are then composited with the
backdrop, using the originally specified alpha and blend mode.
• In all other cases, a non-isolated knockout group is established. Within the
group, the fill and stroke are performed with their respective prevailing alpha
constants and the prevailing blend mode. The group results are then composit-
ed with the backdrop, using an alpha value of 1.0 and the Normal blend mode.
Note that in the case of showing text with the combined filling and stroking text
rendering modes, this behavior is independent of the text knockout parameter in
the graphics state (see Section 5.2.7, “Text Knockout”).
The purpose of these rules is to avoid having a non-opaque stroke composite with
the result of the fill in the region of overlap, which would produce a double bor-
der effect that is usually undesirable. The special case that applies when the over-
print parameter is true is for backward compatibility with the overprinting
behavior of the opaque imaging model. If a desired effect cannot be achieved with
a combined filling and stroking operator or text rendering mode, it can be
570
CHAPTER 7
Transparency
achieved by specifying the fill and stroke with separate path objects and an ex-
plicit transparency group.
Note: Overprinting of the stroke over the fill does not work in the second case de-
scribed above (although either the fill or the stroke can still overprint the backdrop).
Furthermore, if the overprint graphics state parameter is true, the results are discon-
tinuous at the transition between equal and unequal values of the stroking and non-
stroking alpha constants. For this reason, it is best not to use overprinting for
combined filling and stroking operations if the stroking and nonstroking alpha con-
stants are being varied independently.
Summary of Overprinting Behavior
Tables 7.14 and 7.15 summarize the overprinting and erasing behavior in the
opaque and transparent imaging models, respectively. Table 7.14 shows the over-
printing rules used in the opaque model, as described in Section 4.5.6, “Overprint
Control.” Table 7.15 shows the equivalent rules as implemented by the Compatib-
leOverprint blend mode in the transparent model. The names OP and OPM in the
tables refer to the overprint and overprint mode parameters of the graphics state.
TABLE 7.14 Overprinting behavior in the opaque imaging model
EFFECT ON COLOR COMPONENT
SOURCE COLOR SPACE
AFFECTED COLOR
COMPONENT
OP FALSE
OP TRUE, OPM 0
OP TRUE, OPM 1
DeviceCMYK,
C, M, Y, or K
Paint source
Paint source
Paint source if ≠ 0.0
specified directly,
Do not paint if = 0.0
not in a sampled image
Process colorant
Paint source
Paint source
Paint source
other than CMYK
Spot colorant
Paint 0.0
Do not paint
Do not paint
Any process color
Process colorant
Paint source
Paint source
Paint source
space (including other
Spot colorant
Paint 0.0
Do not paint
Do not paint
cases of DeviceCMYK)
571
SECTION 7.6
Color Space and Rendering Issues
EFFECT ON COLOR COMPONENT
SOURCE COLOR SPACE
AFFECTED COLOR
COMPONENT
OP FALSE
OP TRUE, OPM 0
OP TRUE, OPM 1
Separation or
Process colorant
Paint 0.0
Do not paint
Do not paint
DeviceN
Spot colorant
Paint source
Paint source
Paint source
named in source
space
Spot colorant not
Paint 0.0
Do not paint
Do not paint
named in source
space
TABLE 7.15 Overprinting behavior in the transparent imaging model
AFFECTED COLOR
VALUE OF BLEND FUNCTION B (cb , c
s ) EXPRESSED AS TINT
SOURCE COLOR SPACE
COMPONENT OF
GROUP COLOR SPACE
OP FALSE
OP TRUE, OPM 0
OP TRUE, OPM 1
DeviceCMYK,
C, M, Y, or K
c
c
c
s
s
s if cs ≠ 0.0
specified directly,
c
b if cs = 0.0
not in a sampled image
Process color
c
c
c
s
s
s
component other
than CMYK
Spot colorant
c
c
c
s (= 0.0)
b
b
Any process color
Process color
c
c
c
s
s
s
space (including other
component
cases of DeviceCMYK)
Spot colorant
c
c
c
s (= 0.0)
b
b
Separation or
Process color
c
c
c
s (= 0.0)
b
b
DeviceN
component
Spot colorant
c
c
c
s
s
s
named in source
space
Spot colorant not
c
c
c
s (= 0.0)
b
b
named in source
space
572
CHAPTER 7
Transparency
AFFECTED COLOR
VALUE OF BLEND FUNCTION B (cb , cs ) EXPRESSED AS TINT
SOURCE COLOR SPACE
COMPONENT OF
GROUP COLOR SPACE
OP FALSE
OP TRUE, OPM 0
OP TRUE, OPM 1
A group (not an
All color
cs
cs
cs
elementary object)
components
Color component values are represented in these tables as subtractive tint values
because overprinting is typically applied to subtractive colorants such as inks
rather than to additive ones such as phosphors on a display screen. The Compati-
bleOverprint blend mode is therefore described as if it took subtractive argu-
ments and returned subtractive results. In reality, however, CompatibleOverprint
(like all blend modes) treats color components as additive values; subtractive
components must be complemented before and after application of the blend
function.
Note an important difference between the two tables. In Table 7.14, the process
color components being discussed are the actual device colorants—the color
components of the output device’s native color space (DeviceGray, DeviceRGB, or
DeviceCMYK). In Table 7.15, the process color components are those of the
group’s color space, which is not necessarily the same as that of the output device
(and can even be something like CalRGB or ICCBased). For this reason, the pro-
cess color components of the group color space cannot be treated as if they were
spot colors in a Separation or DeviceN color space (see Section 7.6.2, “Spot
Colors and Transparency”). This difference between opaque and transparent
overprinting and erasing rules arises only within a transparency group (including
the page group, if its color space is different from the native color space of the
output device). There is no difference in the treatment of spot color components.
Table 7.15 has one additional row at the bottom. It applies when painting an ob-
ject that is a transparency group rather than an elementary object (fill, stroke,
text, image, or shading). As stated in Section 7.6.2, “Spot Colors and Transparen-
cy,” a group is considered to paint all color components, both process and spot.
Color components that were not explicitly painted by any object in the group
have an additive color value of 1.0 (subtractive tint 0.0). Since no information is
retained about which components were actually painted within the group, com-
patible overprinting is not possible in this case; the CompatibleOverprint blend
mode reverts to Normal, with no consideration of the overprint and overprint
mode parameters. (A transparency-aware application can choose a more suitable
blend mode, such as Darken, to produce an effect similar to overprinting.)
573
SECTION 7.6
Color Space and Rendering Issues
7.6.4
Rendering Parameters and Transparency
The opaque imaging model has several graphics state parameters dealing with the
rendering of color: the current halftone (see Section 6.4.4, “Halftone Diction-
aries”), transfer functions (Section 6.3, “Transfer Functions”), rendering intent
(“Rendering Intents” on page 260), and black-generation and undercolor-removal
functions (Section 6.2.3, “Conversion from DeviceRGB to DeviceCMYK”). All of
these rendering parameters can be specified on a per-object basis; they control
how a particular object is rendered. When all objects are opaque, it is easy to define
what this means. But when they are transparent, more than one object can con-
tribute to the color at a given point; it is unclear which rendering parameters to ap-
ply in an area where transparent objects overlap. At the same time, the transparent
imaging model should be consistent with the opaque model when only opaque ob-
jects are painted.
Furthermore, some of the rendering parameters—the halftone and transfer func-
tions, in particular—can be applied only when the final color at a given point is
known. In the presence of transparency, these parameters must be treated some-
what differently from those (rendering intent, black generation, and undercolor
removal) that apply whenever colors must be converted from one color space to
another. When objects are transparent, the rendering of an object does not occur
when the object is specified but at some later time. Hence, for rendering param-
eters in the former category, the implementation must keep track of the rendering
parameters at each point from the time they are specified until the time the ren-
dering actually occurs. This means that these rendering parameters must be asso-
ciated with regions of the page rather than with individual objects.
Halftone and Transfer Function
The halftone and transfer function to be used at any given point on the page are
those in effect at the time of painting the last (topmost) elementary graphics object
enclosing that point, but only if the object is fully opaque. (Only elementary objects
are relevant; the rendering parameters associated with a group object are ignored.)
The topmost object at any point is defined to be the topmost elementary object in
the entire page stack that has a nonzero object shape value (fj ) at that point (that is,
for which the point is inside the object). An object is considered to be fully opaque
if all of the following conditions hold at the time the object is painted:
• The current alpha constant in the graphics state (stroking or nonstroking, de-
pending on the painting operation) is 1.0.
574
CHAPTER 7
Transparency
• The current blend mode in the graphics state is Normal (or Compatible, which
is treated as equivalent to Normal).
• The current soft mask in the graphics state is None. If the object is an image
XObject, there is no SMask entry in its image dictionary.
• The foregoing three conditions were also true at the time the Do operator was
invoked for the group containing the object, as well as for any direct ancestor
groups.
• If the current color is a tiling pattern, all objects in the definition of its pattern
cell also satisfy the foregoing conditions.
Together, these conditions ensure that only the object itself contributes to the col-
or at the given point, completely obscuring the backdrop. For portions of the page
whose topmost object is not fully opaque or that are never painted at all, the de-
fault halftone and transfer function for the page are used.
Note: If a graphics object is painted with overprinting enabled—that is, if the applic-
able (stroking or nonstroking) overprint parameter in the graphics state is true—the
halftone and transfer function to use at a given point must be determined indepen-
dently for each color component. Overprinting implicitly invokes the Compatible-
Overprint blend mode (see “Compatibility with Opaque Overprinting” on page
567). An object is considered opaque for a given component only if Compatible-
Overprint yields the source color (not the backdrop color) for that component.
Rendering Intent and Color Conversions
The rendering intent, black-generation, and undercolor-removal parameters
need to be handled somewhat differently. The rendering intent influences the
conversion from a CIE-based color space to a target color space, taking into ac-
count the target space’s color gamut (the range of colors it can reproduce).
Whereas in the opaque imaging model the target space is always the native color
space of the output device, in the transparent model it may instead be the group
color space of a transparency group into which an object is being painted.
The rendering intent is needed at the moment such a conversion must be per-
formed—that is, when painting an elementary or group object specified in a CIE-
based color space into a parent group having a different color space. This differs
from the current halftone and transfer function, whose values are used only when
all color compositing has been completed and rasterization is being performed.
575
SECTION 7.6
Color Space and Rendering Issues
In all cases, the rendering intent to use for converting an object’s color (whether
that of an elementary object or of a transparency group) is determined by the ren-
dering intent parameter associated with the object. In particular:
• When painting an elementary object with a CIE-based color into a transpar-
ency group having a different color space, the rendering intent used is the cur-
rent rendering intent in effect in the graphics state at the time of the painting
operation.
• When painting a transparency group whose color space is CIE-based into a
parent group having a different color space, the rendering intent used is the
current rendering intent in effect at the time the Do operator is applied to the
group.
• When the color space of the page group is CIE-based, the rendering intent used
to convert colors to the native color space of the output device is the default
rendering intent for the page.
Note: Since there may be one or more nested transparency groups having different
CIE-based color spaces, the color of an elementary source object may be converted to
the device color space in multiple stages, controlled by the rendering intent in effect
at each stage. The proper choice of rendering intent at each stage depends on the rel-
ative gamuts of the source and target color spaces. It is specified explicitly by the doc-
ument producer, not prescribed by the PDF specification, since no single policy for
managing rendering intents is appropriate for all situations.
A similar approach works for the black-generation and undercolor-removal func-
tions, which are applied only during conversion from DeviceRGB to DeviceCMYK
color spaces:
• When painting an elementary object with a DeviceRGB color directly into a
transparency group whose color space is DeviceCMYK, the functions used are
the current black-generation and undercolor-removal functions in effect in the
graphics state at the time of the painting operation.
• When painting a transparency group whose color space is DeviceRGB into a
parent group whose color space is DeviceCMYK, the functions used are the ones
in effect at the time the Do operator is applied to the group.
• When the color space of the page group is DeviceRGB and the native color
space of the output device is DeviceCMYK, the functions used to convert colors
to the device’s color space are the default functions for the page.
576
CHAPTER 7
Transparency
7.6.5
PostScript Compatibility
Because the PostScript language does not support the transparent imaging
model, PDF 1.4 consumer applications must have some means for converting the
appearance of a document that uses transparency to a purely opaque description
for printing on PostScript output devices. Similar techniques can also be used to
convert such documents to a form that can be correctly viewed by PDF 1.3 and
earlier consumers.
Converting the contents of a page from transparent to opaque form entails some
combination of shape decomposition and prerendering to flatten the stack of
transparent objects on the page, perform all the needed transparency computa-
tions, and describe the final appearance using opaque objects only. Whether the
page contains transparent content needing to be flattened can be determined by
straightforward analysis of the page’s resources; it is not necessary to analyze the
content stream itself. The conversion to opaque form is irreversible, since all in-
formation about how the transparency effects were produced is lost.
To perform the transparency computations properly, the application needs to
know the native color space of the output device. This is no problem when the ap-
plication controls the output device directly. However, when generating Post-
Script output, the application has no way of knowing the native color space of the
PostScript output device. An incorrect assumption will ruin the calibration of any
CIE-based colors appearing on the page. This problem can be addressed in either
of two ways:
• If the entire page consists of CIE-based colors, flatten the colors to a single CIE-
based color space rather than to a device color space. The preferred color space
for this purpose can easily be determined if the page has a group attributes dic-
tionary (Group entry in the page object) specifying a CIE-based color space
(see Section 7.5.5, “Transparency Group XObjects”).
• Otherwise, flatten the colors to some assumed device color space with pre-
determined calibration. In the generated PostScript output, paint the flattened
colors in a CIE-based color space having that calibration.
Because the choice between using spot colorants and converting them to an alter-
nate color space affects the flattened results of process colors, a decision must also
be made during PostScript conversion about the set of available spot colorants to
assume. (This differs from strictly opaque painting, where the decision can be
deferred until the generated PostScript code is executed.)
Большое спасибо!
Ваше мнение очень важно для нас.

Нет комментариевНе стесняйтесь поделиться с нами вашим ценным мнением.
Текст