DynaPDF Manual - Page 577

Previous Page 576   Index   Next Page 578

Function Reference
Page 577 of 787
Physical organization of images
The visible appearance and the physical structure how an image is stored in a PDF file is sometimes
somewhat confusing. Images can be split into bands or tiles. There are various reasons why this can
be done but if an image was split into smaller pieces then it is very difficult to restore the original
image. DynaPDF does not provide algorithms which try to identify pieces of a larger image.
It is usually best to ignore images which are less than two units high. For example, applications like
Microsoft Word split images often into separate scan lines or smaller pieces if the image contained
transparent areas. The result is a PDF file that contains hundreds or thousands of very small images.
Because such small pieces are not really meaningful when viewed alone, the application can either
try to reconstruct the original image, or if this is not possible, such images should be skipped.
When the content parser returns lots of very small images then it is usually best to provide a
fallback that renders the entire page with RenderPage() or RenderPageToImage().
Image coordinate space
An image occupies 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 or pixels. 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.
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 (0, 0) and whose upper-right
corner is at (w - 1, 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 (0, 0) and whose lower-right corner is at (w-1, h-
1).
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. 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 implicit
transformation from image space to user space, if specified explicitly, would be described by the
matrix [1/w, 0, 0, -1/h, 0, 1].
An image can be placed on the output page in any position, orientation, and size by modifying the
current transformation matrix to map the unit square of user space to the rectangle or parallelogram
in which the image shall be painted. Typically, this is done within a pair of save/restore graphics
state operators to isolate the effect of the transformation, which can include translation, rotation,
reflection, and skew.
Please note that the content parser returns images as is. It is maybe required to mirror an image on
the x- or y-axis or to rotate it according to the current transformation matrix. DynaPDF does not
provide functions to manipulate images.
 

Previous topic: TShowTextArrayW, Image Extraction

Next topic: Helper functions, Vector Graphics

Start Chat