DynaPDF Manual - Page 261

Previous Page 260   Index   Next Page 262

Function Reference
Page 261 of 839
// Second spot color
separations[1] = pdfCreateSeparationCS(
PDF,
cls[1],
esDeviceCMYK,
-1,
PDF_CMYK(255, 143, 0, 0)); // 1.0 * 255, 0.56 * 255, 0 * 0, 0 * 0
// Add the separation color spaces to the DeviceN color space.
pdfAddDeviceNSeparations(
PDF,
// Instance pointer
cs,
// DeviceN color space handle
cls,
// Colorants array
separations, // Separation color space handles for these colorants
2);
// Number of Separation color spaces
// Because the DeviceN color space uses a process color we add also
// the attributes of the process color space to it. Note that all
// colorant names must be defined, also if the DeviceN color space
// uses only one component of the process color space.
pdfAddDeviceNProcessColorants(
PDF,
// Instance pointer
cs,
// DeviceN color space handle
pcs,
// Array of process colorants
4,
// Number of process colorants
esDeviceCMYK, // The used process color space
-1);
// No handle is required for a device color space
// The DeviceN color space is now fully created so that we can use it
BYTE color[] = {150, 100, 100};
pdfSetExtColorSpace(PDF, cs);
// Set the DeviceN color space
pdfSetFillColorEx(PDF, color, 3); // Set a fill color
// Draw a rectangle with this color
pdfRectangle(PDF, 50.0, 690.0, 200.0, 100.0, fmFill);
pdfEndPage(PDF);
return pdfCloseFile(PDF);
}
int main(int argc, char* argv[]
{
SI32 retval;
PPDF* pdf = pdfNewPDF();
if (!pdf) return -1; // Out of memory?
retval = TestDeviceNColorSpace(pdf);
pdfFreePDF(pdf);
return retval;
}
As you can see the creation of a DeviceN color space with multiple spot and process colorants is not
difficult. With the helper function that creates the required PostScript calculator function, you can
easily create DeviceN color spaces with up to 32 color channels.
Return values:
If the function succeeds the return value is the color space handle, a value greater or equal zero. If
the function fails the return value is a negative error code.
 

Previous topic: Example 1:, Example 2:

Next topic: CreateDPartRoot