Beispiel #1
0
static int
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;
    int i;

    for (i = 0; i < n_separation_names; i++) {
        const char *sep_name = dev->std_colorant_names[i];
        if (compare_color_names(pname, name_size, sep_name, strlen(sep_name)))
            return i;
    }
    return -1;
}
static void
update_Separation_spot_equivalent_cmyk_colors(gx_device * pdev,
		    const gs_state * pgs, const gs_color_space * pcs,
		    gs_devn_params * pdevn_params,
		    equivalent_cmyk_color_params * pparams)
{
    int i;

    /* 
     * Check if the color space's separation name matches any of the
     * separations for which we need an equivalent CMYK color.
     */
    for (i = 0; i < pdevn_params->separations.num_separations; i++) {
	if (pparams->color[i].color_info_valid == false) {
	    const devn_separation_name * dev_sep_name =
			    &(pdevn_params->separations.names[i]);
	    unsigned int cs_sep_name_size;
	    unsigned char * pcs_sep_name;

	    pcs->params.separation.get_colorname_string
		(pdev->memory, pcs->params.separation.sep_name, &pcs_sep_name,
		 &cs_sep_name_size);
	    if (compare_color_names(dev_sep_name->data, dev_sep_name->size,
			    pcs_sep_name, cs_sep_name_size)) {
		gs_color_space temp_cs = *pcs;
		gs_client_color client_color;

		/*
	         * Create a copy of the color space and then modify it
		 * to force the use of the alternate color space.
	         */
		temp_cs.params.separation.use_alt_cspace = true;
		client_color.paint.values[0] = 1.0;
		capture_spot_equivalent_cmyk_colors(pdev, pgs, &client_color,
					    &temp_cs, i, pparams);
		break;
	    }
	}
    }
}
static void
update_DeviceN_spot_equivalent_cmyk_colors(gx_device * pdev,
		    const gs_state * pgs, const gs_color_space * pcs,
		    gs_devn_params * pdevn_params,
		    equivalent_cmyk_color_params * pparams)
{
    int i;
    unsigned int j;
    unsigned int cs_sep_name_size;
    unsigned char * pcs_sep_name;

    /*
     * Check if the color space contains components named 'None'.  If so then
     * our capture logic does not work properly.  When present, the 'None'
     * components contain alternate color information.  However this info is
     * specified as part of the 'color' and not part of the color space.  Thus
     * we do not have this data when this routine is called.  See the 
     * description of DeviceN color spaces in section 4.5 of the PDF spec.
     * In this situation we exit rather than produce invalid values.
     */
     for (j = 0; j < pcs->params.device_n.num_components; j++) {
	pcs->params.device_n.get_colorname_string
	    (pdev->memory, pcs->params.device_n.names[j],  
	     &pcs_sep_name, &cs_sep_name_size);
	if (compare_color_names("None", 4, pcs_sep_name, cs_sep_name_size))
	    return;
    }

    /* 
     * Check if the color space's separation names matches any of the
     * separations for which we need an equivalent CMYK color.
     */
    for (i = 0; i < pdevn_params->separations.num_separations; i++) {
	if (pparams->color[i].color_info_valid == false) {
	    const devn_separation_name * dev_sep_name =
			    &(pdevn_params->separations.names[i]);

	    for (j = 0; j < pcs->params.device_n.num_components; j++) {
	        pcs->params.device_n.get_colorname_string
		    (pdev->memory, pcs->params.device_n.names[j], &pcs_sep_name,
		     &cs_sep_name_size);
	        if (compare_color_names(dev_sep_name->data, dev_sep_name->size,
			    pcs_sep_name, cs_sep_name_size)) {
		    gs_color_space temp_cs = *pcs;
		    gs_client_color client_color;

		    /*
	             * Create a copy of the color space and then modify it
		     * to force the use of the alternate color space.
	             */
		    memset(&client_color, 0, sizeof(client_color));
		    temp_cs.params.device_n.use_alt_cspace = true;
		    client_color.paint.values[j] = 1.0;
		    capture_spot_equivalent_cmyk_colors(pdev, pgs, &client_color,
					    &temp_cs, i, pparams);
		    break;
	        }
	    }
	}
    }
}