DynaPDF Manual - Page 237

Previous Page 236   Index   Next Page 238

Function Reference
Page 237 of 787
pdfAppend(pdf);
// Note that the Black component is not part of the DeviceN color space
SI32 cs = pdfCreateDeviceNColorSpace(pdf, cls, 3, ps, esDeviceCMYK, -1);
// Optional but strongly recommended: Add the defintion of the process
// colorants to the DeviceN color space.
pdfAddDeviceNProcessColorants(pdf, cls, 4, esDeviceCMYK, -1);
// Draw a rectangle in the alternate DeviceCMYK color space
pdfSetFillColorSpace(pdf, csDeviceCMYK);
pdfSetFillColor(pdf, PDF_CMYK(135, 65, 160, 0));
pdfRectangle(pdf, 50.0, 50.0, 200.0, 100.0, fmFill);
// Now we use the DeviceN color space. The colors of both rectangles must
// be identically. If you see a difference, then disable the output
// preview in Adobe's Acrobat, since the color is converted into the
// simulation profile otherwise...
pdfSetExtColorSpace(pdf, cs);
BYTE color[] = {135, 65, 160};
pdfSetFillColorEx(pdf, color, 3);
pdfRectangle(pdf, 50.0, 150.0, 200.0, 100.0, fmFill);
pdfEndPage(pdf);
Example 2:
In this example we want to define a DeviceN color space that contains 2 spot colors and the process
color yellow. The alternate color space for the spot colors is DeviceCMYK in this example and the
process colorant is defined in this color space too.
The tint transformation function for such a color space must be able to compute one color from
arbitrary combinations of these three colors. So, we need essentially a blend function expressed in
PostScript syntax.
The definition of a blend function is not difficult but long because the entire code is stack based.
However, let us first keep in mind what we need to do. We have already three values on the stack
when the function is executed. These are the tint values which were passed to the DeviceN color
space. We need to multiply the tint values with the four components of the alternate color
representations of all three channels and finally we need to combine these three colors so that we get
the resulting output color. This sounds difficult, because a lot of multiplications and additions are
required to produce the wished result, but you'll see it's easier as it looks like.
The used colors in the DeviceN color space are defined as follows:
Colorant name
CMYK representation
PANTONE 345 CVC (coated)
{0.38, 0.00, 0.34, 0.0} or { 97,
0,
87, 0}
PANTONE 293 CVC (coated)
{1.00, 0.56, 0.00, 0.0} or {255, 143,
0, 0}
Yellow
{0.00, 0.00, 1.00, 0.0} or {
0,
0, 255, 0}
 

Previous topic: Example 1:

Next topic: CreateExtGState

Start Chat