DynaPDF Manual - Page 258

Previous Page 257   Index   Next Page 259

Function Reference
Page 258 of 839
components on the stack are adjusted to the valid input range of the alternate color space and then
passed to it.
Note also that the remaining components on the stack must match the number of input colorants of
the alternate color space. It is an error to leave more or less components on the stack than supported
by the alternate color space.
Example 1:
In this example we create a DeviceN color space that contains the process colorants Cyan, Magenta,
and Yellow. The alternate color space is of course DeviceCMYK. The definition of the PostScript
calculator function is very simple in this example because we need to add the missing Black
component only. The array cls includes also the Black component here because we need the colorant
names later to add the definition of the process components to the DeviceN color space:
const char* cls[] = {"Cyan", "Magenta", "Yellow", "Black"};
const char ps[] = "{0}"; // Just add the missing Black component
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.
 

Previous topic: How to create the PostScript Calculator Function?

Next topic: CreateDPartRoot