Skip to Content

How do I extract the alternate color values of a separation color?

Estimated Reading Time: 1 Minutes

For Separation colors, the equivalents are retrieved by running the color value through the alternate color function using the PDApplyFunction() API.

float inVal[4], tintTrans[4];
...
/* If this element has a GState, retrieve the Color Information here: */
if (PDEElementHasGState (pdeElement, &graphicState, (sizeof (PDEGraphicState)) ))
   {
   if ( !strcmp ( ASAtomGetString(PDEColorSpaceGetName(graphicState.fillColorSpec.space)), N_SEPARATION) )
      {
       DURING
       /* Get the name of the custom color : */
       strcpy (separationColor, "");
       PDEColorSpaceGetCosObj (graphicState.fillColorSpec.space, &cosObj);
       /* Separation Color Space entry has four entries */
       arrayEntry = CosArrayGet(cosObj,0);
       /* First is the family name */
       printf("\nFamily Name = %s\n",ASAtomGetString( CosNameValue (arrayEntry)) );
       arrayEntry = CosArrayGet(cosObj,1);
       /* Second is the name parameter */
       printf("name parameter = %s\n",ASAtomGetString( CosNameValue (arrayEntry)) );
       arrayEntry = CosArrayGet(cosObj,2);
       /*Third is the alternateSpace (must be array or name object) */
       printf("alternateSpace = %s\n",ASAtomGetString( CosNameValue (arrayEntry)) );
       arrayEntry = CosArrayGet(cosObj,3);
       /*Fourth is the tintTransForm */
       InVal[0] = FixedToFloat(graphicState.fillColorSpec.value.color[0]);
       PDApplyFunction(arrayEntry, InVal, tintTrans);
       printf("TintTrans color0 = %f \n",tintTrans[0]);
       printf("TintTrans color1 = %f \n",tintTrans[1]);
       printf("TintTrans color2 = %f \n",tintTrans[2]);
       printf("TintTrans color3 = %f \n",tintTrans[3]);

       HANDLER
       printf ("Error. Can't retrieve colorObj.\n");
       handleError (ERRORCODE);
       END_HANDLER
       }

   foundGState = 1;
   } /* end hasGState */

 

For ICC-based colors, use the color values returned in an appropriate gray, RGB or CMYK space. ThePDEColorSpaceGetNumComps() API will return the number of color components in the ICC color space:

  • DeviceGray, 1
  • DeviceRGB, 3
  • DeviceCMYK, 4

The PDEColorSpaceGetNumComps() API will always return “1” for Separation color spaces because there is only one component for a Separation color space (by definition).

 

.NET and Java

You can use Function.Apply() to apply the function to the supplied input values.

How do I extract the alternate color values of a separation color?
  • COMMENT