DynaPDF Manual - Page 224

Previous Page 223   Index   Next Page 225

Function Reference
Page 224 of 839
DeviceN and Separation color spaces are subtractive color spaces. Thus, a tint value of 0.0 denotes
the lightest color that can be achieved with a given colorant, and 1.0 denotes the darkest.
If you want to calculate the color of a spot colorant then initialize the color channel that corresponds
to the spot colorant to 1.0 and the remaining channels to 0.0, if any.
Now it is important to know what is a spot colorant? A Separation color space supports two special
colorant names: All and None. The value All refers to all channels of the output device and None
produces no visible output.
DeviceN supports 5 reserved values: the colorant names Cyan, Magenty, Yellow, and Black are
always treated as device colorants, and the special colorant name None produces no visible output.
All other colorant names are considered as spot colorants. Colorant names must be compared case-
sensitive.
So, if you want to calculate the color value of a spot colorant, then you must first compare the
colorant names against the reserved or special colorant names of the color space. If a spot color was
found, initialize that color channel to 1.0 and all others to 0.0. Continue until all colorants of the
color space were visited, see example below.
Return values:
If the function succeeds the return value is the color value defined in the destination color space. If
the function fails the return value is zero without further error indication. However, the function
cannot fail if valid values were passed to the function.
Example (C++):
// Returns true if the colorant is a spot colorant
bool IsSpotColor(const char* Colorant, bool Separation)
{
if (Separation)
return (strcmp(Colorant, "None") && strcmp(Colorant, "All"));
else
return (strcmp(Colorant, "Cyan") && strcmp(Colorant, "Magenta")
&& strcmp(Colorant, "Yellow") && strcmp(Colorant, "Black")
&& strcmp(Colorant, "None"));
}
// Helper function to process the spot colors in DeviceN, NChannel, and
// Separation color spaces
void ProcessColorSpace(TPDFColorSpaceObj &CS)
{
UI32 i, color;
double inClr[32] = {0}; // More than 32 channels cannot occur!
for (i = 0; i < CS.ColorantsCount; i++)
{
if (IsSpotColor((char*)CS.Colorants[i], CS.Type == esSeparation))
{
inClr[i] = 1.0;
// Do something with the color...
color = pdfConvColor(inClr,
CS.NumInComponents,
CS.Type,
 

Previous topic: ConvColor

Next topic: ConvertColors