Xojo Developer Conference
25/27th April 2018 in Denver.
MBS Xojo Conference
6/7th September 2018 in Munich, Germany.

DynaPDF Manual - Page 546

Previous Page 545   Index   Next Page 547

Function Reference
Page 546 of 750
fill color directly to a device color space when the color is set in the TSetFillColor calback function. In
this case the resulting device color can be stored in the graphics state as an unsigned integer (UI32).
The graphics state should contain these variables:
Parameter
Type
Initial Value
FillColor
double[32]
Black (optional)
FillColorSpace
TExtColorSpace, IColorSpace*
esDeviceGray, NULL (optional)
Matrix
TCTM
{1, 0, 0, 1, 0, 0}
The visible size of an image, measured in user space, can be calculated from the current
transformation matrix as follows:
double x1 = 0.0;
double y1 = 0.0;
double x2 = 1.0;
double y2 = 0.0;
double x3 = 0.0;
double y3 = 1.0;
// m_GState represents the current graphics state
Transform(m_GState.Matrix, x1, y1); // lower left corner
Transform(m_GState.Matrix, x2, y2); // lower right corner
Transform(m_GState.Matrix, x3, y3); // upper left corner
// CalcDistance() is described at Helper Functions.
double w = CalcDistance(x1, y1, x2, y2); // Width in user space
double h = CalcDistance(x1, y1, x3, y3); // Height in user space
An image can be used several times in a document, e.g. if it represents a logo or other repeating
contents. To avoid the extraction of unnecessay duplicates a duplicate check should be performed
before extracting an image. If the image is not an inline image, the member ObjectPtr of the structure
TPDFImage represents a unique pointer to the image object.
Inline images are fully defined in the content stream and cannot be used repeatly. A duplicate check
is normally not required. The only way to compare two inline images is to compare the image data.
A duplicate check should also be performed for templates. Templates are normally used for
repeating contents such as fixed page backgrounds, logos and so on. To skip a template the
TBeginTemplate calback function must return 1.
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.
 

Previous topic: Image Extraction

Next topic: Helper functions