DynaPDF Manual - Page 601

Previous Page 600   Index   Next Page 602

Function Reference
Page 601 of 821
TSetFillColor
// Optional
It is possible to extract images without a graphics state. The destination width and height, the
output resolution, and the parallelogram into which the image would be drawn are already pre-
computed and can be taken from the sructure TPDFImage.
1 bit images require a special processing if the image is drawn as an image mask. This is the case if
no color table is present and if the member Transparent of the TPDFImage structure is set to true.
Non-zero pixels are are rendered in the current fill color while zero pixel values produce no output.
To simply processing the current fill can be taken from the structure TPDFImage.
The provided fill color is already converted to the specified device color space if one of the color
conversion flags is set (pfConvImagesToGray, pfConvImagesToRGB, or pfConvImagesToCMYK),
or it was converted to the nearest device color space.
If a graphics state is used then it should contain at least these variables:
Parameter
Type
Initial Value
FillColor
double[32] or UI32
Black (0)
FillColorSpace
TExtColorSpace, IColorSpace*
esDeviceGray, NULL (optional)
Matrix
TCTM
{1, 0, 0, 1, 0, 0}
The fill color can be stored as array of double if the original values are of interest or as unsigned
integer if colors are converted to a device space with ConvColor().
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
The above values are already pre-computed and can be taken from the structure TPDFImage.
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.
 

Previous topic: TShowTextArrayW, Image Extraction

Next topic: Physical organization of images, Image coordinate space


Start Chat