DynaPDF Manual - Page 238

Previous Page 237   Index   Next Page 239

Function Reference
Page 238 of 777
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 2:

Next topic: CreateExtGState