[gs-code-review] 687594 Enhancement: Imaging spot colors without using the SeparationColorNames parameter.

Dan Coby dan.coby at artifex.com
Mon Jun 7 13:53:42 PDT 2004


687594 Enhancement: Imaging spot colors without using the
SeparationColorNames parameter.

DETAILS:

The purpose of this enhancement is to provide an example of how
to implement imaging spot colors without requiring that they be
specified in advance via the SeparationColorNames setpagedevice
parameter.  Note:  Spot colors are only supported on a few devices
which have output file formats which allow for spot colors.  These
are currently the psdcmyk, spotcmyk, and xcfcmyk devices.

This commit only implements this feature on the psdcmyk device.

In order to implement this feature, a device needs to be able to
allocate image buffer memory for each colorant and to detect when
a new colorant is being used inside of a color space.  The
implementation has the following pieces:

1.  The handling of the MaxSeparation setpagedevice parameter was
extended.  Previously this parameter was always set to one.  For
most devices it now indicates the number of colorants being used
by the device.  For most devices this is a fixed quantity, however
for the psdcmyk device, this parameter can be used to tell the
device to allocate image buffer memory for up to eight colorants.
(The eight colorant limit is due to the fact that the psdcmyk
device uses 8 bits per colorant and we currently have a 64 bit
maximum pixel size.)

2.  The devices already have a 'get_color_comp_index' routine which
is used to query if a colorant is supported by the device.  However
this routine is used for both real components in color spaces and also
for some special cases.  For instance, the same halftone may be used
either for a cyan or a red colorant.  To handle this case, the halftoning
setup logic will query the get_color_comp_index routine to check if
cyan is supported by the device.  If not then a query is made to see
if the device supports red.  By monitoring the names of the components
passed to get_color_comp_index routine, a device can detect when a new spot
color is being used.  However it is necessary to be able to detect
the special cases so that the device does not believe that it has a
'red' spot color.  To do this the third parameter of the
get_color_comp_index device proc was logically modified to indicate
if a name represents a name actually in a color space or one of the
special case situations.  Previously this parameter was not being used.

3.  The get_color_comp_index routine for the psdcmyk device was
modified to look for new spot colors and to add then to its list of
colorants if there was space available.  Note:  This also required
that the psdcmyk device have its own structure descriptor, pointer
enumeration and relocation procedures.  The macro which was used to
define the psdcmyk and psdrgb devices needed to be changed since the
previous macro used the st_device_printer structure descriptor instead
of the new structure descriptor for the psd devices.


Dan
-------------- next part --------------
Index: src/gdevdevn.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevdevn.c,v
retrieving revision 1.19
diff -u -r1.19 gdevdevn.c
--- src/gdevdevn.c	31 May 2004 06:02:00 -0000	1.19
+++ src/gdevdevn.c	7 Jun 2004 18:16:19 -0000
@@ -146,6 +146,7 @@
     { 1,			/* Bits per color - must match ncomp, depth, etc. above */
       DeviceCMYKComponents,	/* Names of color model colorants */
       4,			/* Number colorants for CMYK */
+      0,			/* MaxSeparations has not been specified */
       {0},			/* SeparationNames */
       {0},			/* SeparationOrder names */
       {0, 1, 2, 3, 4, 5, 6, 7 }	/* Initial component SeparationOrder */
@@ -175,7 +176,8 @@
     /* DeviceN device specific parameters */
     { 8,			/* Bits per color - must match ncomp, depth, etc. above */
       NULL,			/* No names for standard DeviceN color model */
-      0,			/* No standarad colorants for DeviceN */
+      0,			/* No standard colorants for DeviceN */
+      0,			/* MaxSeparations has not been specified */
       {0},			/* SeparationNames */
       {0},			/* SeparationOrder names */
       {0, 1, 2, 3 }		/* Initial component order */
@@ -661,11 +663,14 @@
         }
 	/*
 	 * If we have SeparationOrder specified then the number of components
-	 * is given by the number of names in the list.  Otherwise the number
-	 * of ProcessColorModel components and SeparationColorNames is used.
+	 * is given by the number of names in the list.  Otherwise check if
+	 * the MaxSeparations parameter has specified a value.  If so then use
+	 * that value, otherwise use the number of ProcessColorModel components
+	 * plus the number of SeparationColorNames is used.
 	 */
         pdev->color_info.num_components = (num_order) ? num_order 
-						      : npcmcolors + num_spot;
+		: (pparams->max_separations) ?  pparams->max_separations
+					    : npcmcolors + num_spot;
         /* 
          * The DeviceN device can have zero components if nothing has been
 	 * specified.  This causes some problems so force at least one component
@@ -760,11 +765,14 @@
         }
 	/*
 	 * If we have SeparationOrder specified then the number of components
-	 * is given by the number of names in the list.  Otherwise the number
-	 * of ProcessColorModel components and SeparationColorNames is used.
+	 * is given by the number of names in the list.  Otherwise check if
+	 * the MaxSeparations parameter has specified a value.  If so then use
+	 * that value, otherwise use the number of ProcessColorModel components
+	 * plus the number of SeparationColorNames is used.
 	 */
         pdev->color_info.num_components = (num_order) ? num_order 
-						      : npcmcolors + num_spot;
+		: (pparams->max_separations) ?  pparams->max_separations
+					    : npcmcolors + num_spot;
         /* 
          * The DeviceN device can have zero components if nothing has been
 	 * specified.  This causes some problems so force at least one component
Index: src/gdevdevn.h
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevdevn.h,v
retrieving revision 1.7
diff -u -r1.7 gdevdevn.h
--- src/gdevdevn.h	31 May 2004 06:02:00 -0000	1.7
+++ src/gdevdevn.h	7 Jun 2004 18:16:20 -0000
@@ -72,6 +72,7 @@
      */
     fixed_colorant_names_list std_colorant_names;
     int num_std_colorant_names;	/* Number of names in list */
+    int max_separations;	/* From MaxSeparation parameter */
 
     /*
     * Separation info (if any).
Index: src/gdevnfwd.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevnfwd.c,v
retrieving revision 1.22
diff -u -r1.22 gdevnfwd.c
--- src/gdevnfwd.c	6 May 2004 05:19:15 -0000	1.22
+++ src/gdevnfwd.c	7 Jun 2004 18:16:20 -0000
@@ -685,14 +685,16 @@
 
 int
 gx_forward_get_color_comp_index(const gx_device * dev, const char * pname,
-						int name_size, int src_index)
+					int name_size, int component_type)
 {
     const gx_device_forward * fdev = (const gx_device_forward *)dev;
     gx_device *tdev = fdev->target;
 
     return (tdev == 0 
-	? gx_error_get_color_comp_index(dev, pname, name_size, src_index)
-	: dev_proc(tdev, get_color_comp_index)(tdev, pname, name_size, src_index));
+	? gx_error_get_color_comp_index(dev, pname,
+				name_size, component_type)
+	: dev_proc(tdev, get_color_comp_index)(tdev, pname,
+				name_size, component_type));
 }
 
 gx_color_index
Index: src/gdevperm.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevperm.c,v
retrieving revision 1.3
diff -u -r1.3 gdevperm.c
--- src/gdevperm.c	25 Oct 2002 23:04:16 -0000	1.3
+++ src/gdevperm.c	7 Jun 2004 18:16:21 -0000
@@ -289,7 +289,8 @@
 	(strncmp((const char *)name, (const char *)str, name_size) == 0))
 
 private int
-perm_get_color_comp_index(const gx_device *pdev, const char *pname, int name_size, int src_index)
+perm_get_color_comp_index(const gx_device *pdev, const char *pname,
+					int name_size, int component_type)
 {
     const gx_device_perm_t * const dev = (const gx_device_perm_t *)pdev;
     int n_separation_names = dev->num_std_colorant_names;
Index: src/gdevpsd.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevpsd.c,v
retrieving revision 1.13
diff -u -r1.13 gdevpsd.c
--- src/gdevpsd.c	31 May 2004 06:02:00 -0000	1.13
+++ src/gdevpsd.c	7 Jun 2004 18:16:23 -0000
@@ -91,8 +91,46 @@
     icmLuBase *lu_out;
 } psd_device;
 
+private_st_psd_device();
+/* GC procedures */
+private 
+ENUM_PTRS_WITH(psd_device_enum_ptrs, psd_device *pdev)
+{
+    if (index < pdev->devn_params.separations.num_separations)
+	ENUM_RETURN(pdev->devn_params.separations.names[index]);
+    ENUM_PREFIX(st_device_printer,
+		    pdev->devn_params.separations.num_separations);
+}
+
+ENUM_PTRS_END
+private RELOC_PTRS_WITH(psd_device_reloc_ptrs, psd_device *pdev)
+{
+    RELOC_PREFIX(st_device_printer);
+    {
+	int i;
+
+	for (i = 0; i < pdev->devn_params.separations.num_separations; ++i) {
+	    RELOC_PTR(psd_device, devn_params.separations.names[i]);
+	}
+    }
+}
+RELOC_PTRS_END
+
+/* Even though psd_device_finalize is the same as gx_device_finalize, */
+/* we need to implement it separately because st_composite_final */
+/* declares all 3 procedures as private. */
+private void
+psd_device_finalize(void *vpdev)
+{
+    gx_device_finalize(vpdev);
+}
+
+gs_private_st_composite_final(st_psd_device, psd_device,
+    "psd_device", psd_device_enum_ptrs, psd_device_reloc_ptrs,
+    psd_device_finalize);
+
 /*
- * Macro definition for DeviceN procedures
+ * Macro definition for psd device procedures
  */
 #define device_procs(get_color_mapping_procs)\
 {	gdev_prn_open,\
@@ -165,28 +203,38 @@
 	0		/* List terminator */
 };
 
+#define psd_device_body(procs, dname, ncomp, pol, depth, mg, mc, cn)\
+    std_device_full_body_type_extended(psd_device, &procs, dname,\
+	  &st_psd_device,\
+	  (int)((long)(DEFAULT_WIDTH_10THS) * (X_DPI) / 10),\
+	  (int)((long)(DEFAULT_HEIGHT_10THS) * (Y_DPI) / 10),\
+	  X_DPI, Y_DPI,\
+    	  GX_DEVICE_COLOR_MAX_COMPONENTS,	/* MaxComponents */\
+	  ncomp,		/* NumComp */\
+	  pol,			/* Polarity */\
+	  depth, 0,		/* Depth, GrayIndex */\
+	  mg, mc,		/* MaxGray, MaxColor */\
+	  mg + 1, mc + 1,	/* DitherGray, DitherColor */\
+	  GX_CINFO_SEP_LIN,	/* Linear & Separable */\
+	  cn,			/* Process color model name */\
+	  0, 0,			/* offsets */\
+	  0, 0, 0, 0		/* margins */\
+	),\
+	prn_device_body_rest_(psd_print_page)
+
 /*
- * Example device with RGB and spot color support
+ * PSD device with RGB process color model.
  */
 private const gx_device_procs spot_rgb_procs = device_procs(get_psdrgb_color_mapping_procs);
 
 const psd_device gs_psdrgb_device =
 {   
-    prn_device_body_extended(psd_device, spot_rgb_procs, "psdrgb",
-	 DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
-	 X_DPI, Y_DPI,		/* X and Y hardware resolution */
-	 0, 0, 0, 0,		/* margins */
-    	 GX_DEVICE_COLOR_MAX_COMPONENTS, 3,	/* MaxComponents, NumComp */
-	 GX_CINFO_POLARITY_ADDITIVE,		/* Polarity */
-	 24, 0,			/* Depth, Gray_index, */
-	 255, 255, 256, 256,	/* MaxGray, MaxColor, DitherGray, DitherColor */
-	 GX_CINFO_SEP_LIN,      /* Linear & Seperable */
-	 "DeviceRGB",		/* Process color model name */
-	 psd_print_page),	/* Printer page print routine */
+    psd_device_body(spot_rgb_procs, "psdrgb", 3, GX_CINFO_POLARITY_ADDITIVE, 24, 255, 255, "DeviceRGB"),
     /* devn_params specific parameters */
-    { 8,			/* Bits per color - must match ncomp, depth, etc. above */
+    { 8,	/* Bits per color - must match ncomp, depth, etc. above */
       DeviceRGBComponents,	/* Names of color model colorants */
       3,			/* Number colorants for RGB */
+      0,			/* MaxSeparations has not been specified */
       {0},			/* SeparationNames */
       {0},			/* SeparationOrder names */
       {0, 1, 2, 3, 4, 5, 6, 7 }	/* Initial component SeparationOrder */
@@ -196,25 +244,20 @@
     psd_DEVICE_RGB,		/* Color model */
 };
 
-private const gx_device_procs spot_cmyk_procs = device_procs(get_psd_color_mapping_procs);
+/*
+ * PSD device with CMYK process color model and spot color support.
+ */
+private const gx_device_procs spot_cmyk_procs
+		= device_procs(get_psd_color_mapping_procs);
 
 const psd_device gs_psdcmyk_device =
 {   
-    prn_device_body_extended(psd_device, spot_cmyk_procs, "psdcmyk",
-	 DEFAULT_WIDTH_10THS, DEFAULT_HEIGHT_10THS,
-	 X_DPI, Y_DPI,		/* X and Y hardware resolution */
-	 0, 0, 0, 0,		/* margins */
-    	 GX_DEVICE_COLOR_MAX_COMPONENTS, 4,	/* MaxComponents, NumComp */
-	 GX_CINFO_POLARITY_SUBTRACTIVE,		/* Polarity */
-	 32, 0,			/* Depth, Gray_index, */
-	 255, 255, 256, 256,	/* MaxGray, MaxColor, DitherGray, DitherColor */
-	 GX_CINFO_SEP_LIN,      /* Linear & Separable */
-	 "DeviceCMYK",		/* Process color model name */
-	 psd_print_page),	/* Printer page print routine */
+    psd_device_body(spot_cmyk_procs, "psdcmyk", 4, GX_CINFO_POLARITY_SUBTRACTIVE, 32, 255, 255, "DeviceCMYK"),
     /* devn_params specific parameters */
-    { 8,			/* Bits per color - must match ncomp, depth, etc. above */
+    { 8,	/* Bits per color - must match ncomp, depth, etc. above */
       DeviceCMYKComponents,	/* Names of color model colorants */
       4,			/* Number colorants for CMYK */
+      0,			/* MaxSeparations has not been specified */
       {0},			/* SeparationNames */
       {0},			/* SeparationOrder names */
       {0, 1, 2, 3, 4, 5, 6, 7 }	/* Initial component SeparationOrder */
@@ -719,16 +762,19 @@
 psd_put_params(gx_device * pdev, gs_param_list * plist)
 {
     psd_device * const pdevn = (psd_device *) pdev;
-    gx_device_color_info save_info;
+    int num_spot = pdevn->devn_params.separations.num_separations;
     int ecode = 0;
     int code;
     gs_param_string po;
     gs_param_string prgb;
     gs_param_string pcmyk;
     gs_param_string pcm;
+    gs_param_name param_name;
     psd_color_model color_model = pdevn->color_model;
+    gx_device_color_info save_info = pdevn->color_info;
     gs_separations saved_separations = pdevn->devn_params.separations;
     gs_devn_params * pparams = &pdevn->devn_params;
+    int max_sep = pdevn->color_info.num_components;
 
     code = psd_param_read_fn(plist, "ProfileOut", &po,
 				 sizeof(pdevn->profile_out_fn));
@@ -759,9 +805,36 @@
 	ecode = code;
 
     /*
+     * Adobe says that MaxSeparations is supposed to be 'read only' however
+     * we use this to allow the specification of the maximum number of
+     * separations.  Memory is allocated for the specified number of
+     * separations.  This allows us to then accept separation colors in
+     * color spaces even if they we not specified at the start of the
+     * image file.
+     */
+    code = param_read_int(plist, param_name = "MaxSeparations", &max_sep);
+    switch (code) {
+        default:
+	    param_signal_error(plist, param_name, code);
+        case 0:
+        case 1:
+	    if (max_sep < 0 || max_sep > GX_DEVICE_COLOR_MAX_COMPONENTS)
+		return_error(gs_error_rangecheck);
+	    {
+		int depth = bpc_to_depth(max_sep, pparams->bitspercomponent);
+
+                if (depth > 8 * size_of(gx_color_index))
+		    return_error(gs_error_rangecheck);
+    	        pdevn->devn_params.max_separations =
+		    pdevn->color_info.max_components =
+    	            pdevn->color_info.num_components = max_sep;
+                pdev->color_info.depth = depth;
+	    }
+
+    }
+    /*
      * Save the color_info in case devicen_put_params fails.
      */
-    save_info = pdevn->color_info;
     ecode = psd_set_color_model(pdevn, color_model);
     if (ecode == 0)
 	ecode = devicen_put_params(pdev, pparams, plist);
@@ -782,9 +855,8 @@
 	    int i;
 
 	    pdevn->equiv_cmyk_colors.all_color_info_valid = false;
-	    for (i = 0;
-		i < pdevn->devn_params.separations.num_separations; i++)
-		    pdevn->equiv_cmyk_colors.color[i].color_info_valid = false;
+	    for (i = 0; i < num_spot; i++)
+		pdevn->equiv_cmyk_colors.color[i].color_info_valid = false;
 	}
     }
 
@@ -801,7 +873,9 @@
 	memcpy(pdevn->profile_cmyk_fn, pcmyk.data, pcmyk.size);
 	pdevn->profile_cmyk_fn[pcmyk.size] = 0;
     }
-    code = psd_open_profiles(pdevn);
+    if (memcmp(&pdevn->color_info, &save_info,
+			    size_of(gx_device_color_info)) != 0)
+        code = psd_open_profiles(pdevn);
 
     return code;
 }
@@ -823,23 +897,54 @@
 psd_get_color_comp_index(const gx_device * dev, const char * pname,
 					int name_size, int component_type)
 {
-    const gs_devn_params * pparams = &(((const psd_device *)dev)->devn_params);
-    int num_order = pparams->separation_order.num_names;
+    psd_device * pdev = (psd_device *) dev;
+    const gs_devn_params * pdevn_params =
+	    &(((const psd_device *)dev)->devn_params);
+    int num_order = pdevn_params->separation_order.num_names;
     int color_component_number = 0;
 
     /*
      * Check if the component is in either the process color model list
      * or in the SeparationNames list.
      */
-    color_component_number = check_pcm_and_separation_names(dev, pparams,
+    color_component_number = check_pcm_and_separation_names(dev, pdevn_params,
 					pname, name_size, component_type);
     /* Check if the component is in the separation order list. */
 
     if (color_component_number >= 0 && num_order) {
 	color_component_number = 
-		pparams->separation_order_map[color_component_number];
+		pdevn_params->separation_order_map[color_component_number];
         return color_component_number;
     }
+    /*
+     * The given name does not match any of our current components or
+     * separations.  If this is a separation name and we have room
+     * for it then add it to our list of separations.
+     */
+    if (color_component_number < 0 && component_type == SEPARATION_NAME &&
+	pdev->color_info.num_components >
+	    pdev->devn_params.separations.num_separations +
+	    pdev->devn_params.num_std_colorant_names ) {
+	gs_param_string * pstr_param;
+	byte * pseparation;
+	gs_separations * separations = &pdev->devn_params.separations;
+	int sep_num = separations->num_separations++;
+
+	/* We have a new separation */
+	pstr_param = (gs_param_string *)gs_alloc_bytes(pdev->memory,
+			sizeof(gs_param_string), "psd_get_color_comp_index");
+	pseparation = (byte *)gs_alloc_bytes(pdev->memory,
+			name_size, "psd_get_color_comp_index");
+	memcpy(pseparation, pname, name_size);
+	pstr_param->data = pseparation;
+	pstr_param->size = name_size;
+	pstr_param->persistent = false;
+	separations->names[sep_num] = pstr_param;
+	color_component_number = sep_num + pdevn_params->num_std_colorant_names;
+	/* Indicate that we need to find equivalent CMYK color. */
+	pdev->equiv_cmyk_colors.color[sep_num].color_info_valid = false;
+	pdev->equiv_cmyk_colors.all_color_info_valid = false;
+    }
 
     return color_component_number;
 }
@@ -1092,6 +1197,7 @@
 private int
 psd_write_image_data(psd_write_ctx *xc, gx_device_printer *pdev)
 {
+    psd_device * const pdevn = (psd_device *) pdev;
     int code = 0;
     int raster = gdev_prn_raster(pdev);
     int i, j;
Index: src/gdevxcf.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gdevxcf.c,v
retrieving revision 1.7
diff -u -r1.7 gdevxcf.c
--- src/gdevxcf.c	26 May 2004 04:10:58 -0000	1.7
+++ src/gdevxcf.c	7 Jun 2004 18:16:24 -0000
@@ -933,7 +933,8 @@
  * number if the name is found.  It returns a negative value if not found.
  */
 private int
-xcf_get_color_comp_index(const gx_device * dev, const char * pname, int name_size, int src_index)
+xcf_get_color_comp_index(const gx_device * dev, const char * pname, int name_size,
+					int component_type)
 {
 /* TO_DO_DEVICEN  This routine needs to include the effects of the SeparationOrder array */
     const fixed_colorant_names_list * list = ((const xcf_device *)dev)->std_colorant_names;
Index: src/gscdevn.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gscdevn.c,v
retrieving revision 1.16
diff -u -r1.16 gscdevn.c
--- src/gscdevn.c	8 Apr 2004 07:59:19 -0000	1.16
+++ src/gscdevn.c	7 Jun 2004 18:16:24 -0000
@@ -479,7 +479,7 @@
 	     * SeparationOrder list.
 	     */
 	    colorant_number = (*dev_proc(dev, get_color_comp_index))
-				    (dev, (const char *)pname, name_size, i);
+		    (dev, (const char *)pname, name_size, SEPARATION_NAME);
 	    if (colorant_number >= 0) {		/* If valid colorant name */
 		pcolor_component_map->color_map[i] =
 		    (colorant_number == GX_DEVICE_COLOR_MAX_COMPONENTS) ? -1
Index: src/gscsepr.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gscsepr.c,v
retrieving revision 1.23
diff -u -r1.23 gscsepr.c
--- src/gscsepr.c	8 Apr 2004 07:59:19 -0000	1.23
+++ src/gscsepr.c	7 Jun 2004 18:16:25 -0000
@@ -446,7 +446,7 @@
      * SeparationOrder list.
      */
     colorant_number = (*dev_proc(dev, get_color_comp_index))
-				    (dev, (const char *)pname, name_size, 0);
+		(dev, (const char *)pname, name_size, SEPARATION_NAME);
     if (colorant_number >= 0) {		/* If valid colorant name */
 	pcolor_component_map->color_map[0] =
 		    (colorant_number == GX_DEVICE_COLOR_MAX_COMPONENTS) ? -1
Index: src/gscspace.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gscspace.c,v
retrieving revision 1.15
diff -u -r1.15 gscspace.c
--- src/gscspace.c	5 May 2004 09:45:08 -0000	1.15
+++ src/gscspace.c	7 Jun 2004 18:16:25 -0000
@@ -354,25 +354,25 @@
                        dev,
                        "Cyan",
                        sizeof("Cyan") - 1,
-                       -1 )) < 0                          ||
+                       NO_COMP_NAME_TYPE )) < 0           ||
          cyan_c == GX_DEVICE_COLOR_MAX_COMPONENTS         ||
          (magenta_c = dev_proc(dev, get_color_comp_index)(
                           dev,
                           "Magenta",
                           sizeof("Magenta") - 1,
-                          -1 )) < 0                       ||
+                          NO_COMP_NAME_TYPE )) < 0        ||
          magenta_c == GX_DEVICE_COLOR_MAX_COMPONENTS      ||
          (yellow_c = dev_proc(dev, get_color_comp_index)(
                         dev,
                         "Yellow",
                         sizeof("Yellow") - 1,
-                        -1 )) < 0                         ||
+                        NO_COMP_NAME_TYPE )) < 0               ||
          yellow_c == GX_DEVICE_COLOR_MAX_COMPONENTS       ||
          (black_c = dev_proc(dev, get_color_comp_index)(
                         dev,
                         "Black",
                         sizeof("Black") - 1,
-                        -1 )) < 0                         ||
+                        NO_COMP_NAME_TYPE )) < 0                         ||
          black_c == GX_DEVICE_COLOR_MAX_COMPONENTS          )
         return 0;
 
Index: src/gsdparam.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gsdparam.c,v
retrieving revision 1.13
diff -u -r1.13 gsdparam.c
--- src/gsdparam.c	28 Apr 2004 05:39:56 -0000	1.13
+++ src/gsdparam.c	7 Jun 2004 18:16:26 -0000
@@ -73,7 +73,6 @@
 
     /* Standard page device parameters: */
 
-    int mns = 1;
     bool seprs = false;
     gs_param_string dns, pcms;
     gs_param_float_array msa, ibba, hwra, ma;
@@ -85,6 +84,7 @@
     /* Non-standard parameters: */
 
     int colors = dev->color_info.num_components;
+    int mns = colors;
     int depth = dev->color_info.depth;
     int GrayValues = dev->color_info.max_gray + 1;
     int HWSize[2];
@@ -640,7 +640,7 @@
 	if ((code = param_check_string(plist, "ProcessColorModel", pcms, (pcms != NULL))) < 0)
 	    ecode = code;
     }
-    if ((code = param_check_int(plist, "MaxSeparations", 1, true)) < 0)
+    if ((code = param_check_int(plist, "MaxSeparations", colors, true)) < 0)
 	ecode = code;
     if ((code = param_check_bool(plist, "Separations", false, true)) < 0)
 	ecode = code;
Index: src/gsht.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gsht.c,v
retrieving revision 1.18
diff -u -r1.18 gsht.c
--- src/gsht.c	5 Jan 2004 23:34:47 -0000	1.18
+++ src/gsht.c	7 Jun 2004 18:16:27 -0000
@@ -645,10 +645,10 @@
     int num_colorant;
 
 #define check_colorant_name(dev, name) \
-    ((*dev_proc(dev, get_color_comp_index)) (dev, name, strlen(name), 0))
+    ((*dev_proc(dev, get_color_comp_index)) (dev, name, strlen(name), NO_COMP_NAME_TYPE))
 
 #define check_colorant_name_length(dev, name, length) \
-    ((*dev_proc(dev, get_color_comp_index)) (dev, name, length, 0))
+    ((*dev_proc(dev, get_color_comp_index)) (dev, name, length, NO_COMP_NAME_TYPE))
 
 #define check_name(str, pname, length) \
     ((strlen(str) == length) && (strncmp(pname, str, length) == 0))
@@ -1250,7 +1250,7 @@
  * A value of -1 indicates that the name is not valid.
  */
 #define check_colorant_name(name, dev) \
-   ((*dev_proc(dev, get_color_comp_index)) (dev, name, strlen(name), 0))
+   ((*dev_proc(dev, get_color_comp_index)) (dev, name, strlen(name), NO_NAME_TYPE))
 
 /* Reestablish the effective transfer functions, taking into account */
 /* any overrides from halftone dictionaries. */
Index: src/gxcmap.c
===================================================================
RCS file: /cvs/ghostscript/gs/src/gxcmap.c,v
retrieving revision 1.20
diff -u -r1.20 gxcmap.c
--- src/gxcmap.c	26 May 2004 04:10:58 -0000	1.20
+++ src/gxcmap.c	7 Jun 2004 18:16:29 -0000
@@ -337,7 +337,7 @@
 /* Default color component to index for a DeviceGray color model */
 int
 gx_default_DevGray_get_color_comp_index(const gx_device * dev, const char * pname,
-						int name_size, int src_index)
+						int name_size, int component_type)
 {
     if (compare_color_names(pname, name_size, "Gray") ||
 	compare_color_names(pname, name_size, "Grey")) 
@@ -349,7 +349,7 @@
 /* Default color component to index for a DeviceRGB color model */
 int
 gx_default_DevRGB_get_color_comp_index(const gx_device * dev, const char * pname,
-						int name_size, int src_index)
+						int name_size, int component_type)
 {
     if (compare_color_names(pname, name_size, "Red"))
         return 0;
@@ -364,7 +364,7 @@
 /* Default color component to index for a DeviceCMYK color model */
 int
 gx_default_DevCMYK_get_color_comp_index(const gx_device * dev, const char * pname,
-						int name_size, int src_index)
+						int name_size, int component_type)
 {
     if (compare_color_names(pname, name_size, "Cyan"))
         return 0;
@@ -381,7 +381,7 @@
 /* Default color component to index for an unknown color model */
 int
 gx_error_get_color_comp_index(const gx_device * dev, const char * pname,
-						int name_size, int src_index)
+						int name_size, int component_type)
 {
     /*
      * We should never get here.  If we do then we do not have a "get_color_comp_index"
Index: src/gxcmap.h
===================================================================
RCS file: /cvs/ghostscript/gs/src/gxcmap.h,v
retrieving revision 1.8
diff -u -r1.8 gxcmap.h
--- src/gxcmap.h	18 May 2004 11:07:29 -0000	1.8
+++ src/gxcmap.h	7 Jun 2004 18:16:29 -0000
@@ -195,10 +195,20 @@
     dev_t_proc_get_color_mapping_procs(proc, gx_device)
 
 /*
+  Define the options for the component_type parameter to get_color_comp_index
+  routines.  Note:  This information is currently being used by the routines
+  for identifying when they are being given a separation name.  Some devices
+  automaticaly add separations to the device's components if the separation
+  is not previously known and there is room in the device.
+*/
+#define NO_COMP_NAME_TYPE	0
+#define SEPARATION_NAME		1
+
+/*
   Convert a color component name into a colorant index.
 */
 #define dev_t_proc_get_color_comp_index(proc, dev_t) \
-    int (proc)(const dev_t * dev, const char * pname, int name_size, int src_index)
+    int (proc)(const dev_t * dev, const char * pname, int name_size, int component_type)
 
 #define dev_proc_get_color_comp_index(proc) \
     dev_t_proc_get_color_comp_index(proc, gx_device)


More information about the gs-code-review mailing list