SECTION 4.8
337
Images
ple by sample; for example, in a three-component
RGB
image, the red, green, and
blue components for one sample are followed by the red, green, and blue compo-
nents for the next.
Normally, the color samples in an image are interpreted according to the color
space specified in the image dictionary (see Section 4.5, “Color Spaces”), without
reference to the color parameters in the graphics state. However, if the image dic-
tionary’s
ImageMask
entry is
true
, the sample data is interpreted as a
stencil mask
for applying the graphics state’s nonstroking color parameters (see “Stencil Mask-
4.8.3 Image Coordinate System
Each image has its own internal coordinate system, or
image space.
The image oc-
cupies a rectangle in image space
w
units wide and
h
units high, where
w
and
h
are the width and height of the image in samples. Each sample occupies one
square unit. The coordinate origin (0, 0) is at the upper-left corner of the image,
with coordinates ranging from 0 to
w
horizontally and 0 to
h
vertically.
The image’s sample data is ordered by row, with the horizontal coordinate varying
most rapidly. This is shown in Figure 4.26, where the numbers inside the squares
indicate the order of the samples, counting from 0. The upper-left corner of the
first sample is at coordinates (0, 0), the second at (1, 0), and so on through the last
sample of the first row, whose upper-left corner is at (w
−
1, 0) and whose upper-
right corner is at (w, 0). The next samples after that are at coordinates (0, 1),
(1, 1), and so on to the final sample of the image, whose upper-left corner is at
(w
−
1,
h
−
1) and whose lower-right corner is at (w,
h).
Note:
The image coordinate system and scanning order imposed by PDF do not pre-
clude using different conventions in the actual image. Coordinate transformations
can be used to map from other conventions to the PDF convention.
The correspondence between image space and user space is constant: the unit
square of user space, bounded by user coordinates (0, 0) and (1, 1), corresponds
to the boundary of the image in image space (see Figure 4.27). Following the
normal convention for user space, the coordinate (0, 0) is at the
lower-left
corner
of this square, corresponding to coordinates (0,
h)
in image space. The transfor-
mation from image space to user space could be described by the matrix
[ 1
⁄
w
0 0
−
1
⁄
h
0 1 ]
.