static int gx_concretize_DeviceN(const gs_client_color * pc, const gs_color_space * pcs, frac * pconc, const gs_imager_state * pis, gx_device *dev) { int code, tcode = 0; gs_client_color cc; gs_color_space *pacs = (gs_color_space*) (pcs->base_space); gs_device_n_map *map = pcs->params.device_n.map; bool is_lab; int num_src_comps = pcs->params.device_n.num_components; #ifdef DEBUG /* * Verify that the color space and imager state info match. */ if (pcs->id != pis->color_component_map.cspace_id) dmprintf(dev->memory, "gx_concretize_DeviceN: color space id mismatch"); #endif /* * Check if we need to map into the alternate color space. * We must preserve tcode for implementing a semi-hack in the interpreter. */ if (pis->color_component_map.use_alt_cspace) { /* Check the 1-element cache first. */ if (map->cache_valid) { int i; for (i = pcs->params.device_n.num_components; --i >= 0;) { if (map->tint[i] != pc->paint.values[i]) break; } if (i < 0) { int num_out = gs_color_space_num_components(pacs); for (i = 0; i < num_out; ++i) pconc[i] = map->conc[i]; return 0; } } tcode = (*pcs->params.device_n.map->tint_transform) (pc->paint.values, &cc.paint.values[0], pis, pcs->params.device_n.map->tint_transform_data); (*pacs->type->restrict_color)(&cc, pacs); if (tcode < 0) return tcode; /* First check if this was PS based. */ if (gs_color_space_is_PSCIE(pacs)) { /* We may have to rescale data to 0 to 1 range */ rescale_cie_colors(pacs, &cc); /* If we have not yet created the profile do that now */ if (pacs->icc_equivalent == NULL) { gs_colorspace_set_icc_equivalent(pacs, &(is_lab), pis->memory); } /* Use the ICC equivalent color space */ pacs = pacs->icc_equivalent; } if (pacs->cmm_icc_profile_data->data_cs == gsCIELAB || pacs->cmm_icc_profile_data->islab) { /* Get the data in a form that is concrete for the CMM */ cc.paint.values[0] /= 100.0; cc.paint.values[1] = (cc.paint.values[1]+128)/255.0; cc.paint.values[2] = (cc.paint.values[2]+128)/255.0; } code = cs_concretize_color(&cc, pacs, pconc, pis, dev); } else { int i; for (i = num_src_comps; --i >= 0;) pconc[i] = gx_unit_frac(pc->paint.values[i]); return 0; } return (code < 0 || tcode == 0 ? code : tcode); }
static int gx_concretize_DeviceN(const gs_client_color * pc, const gs_color_space * pcs, frac * pconc, const gs_imager_state * pis, gx_device *dev) { int code, tcode = 0; gs_client_color cc; gs_color_space *pacs = (gs_color_space*) (pcs->base_space); gs_device_n_map *map = pcs->params.device_n.map; bool is_lab; int k; int num_des_comps = dev->color_info.num_components; gsicc_namedcolor_t *named_color; const gs_separation_name *names = pcs->params.device_n.names; int num_src_comps = pcs->params.device_n.num_components; #ifdef DEBUG /* * Verify that the color space and imager state info match. */ if (pcs->id != pis->color_component_map.cspace_id) dmprintf(dev->memory, "gx_concretize_DeviceN: color space id mismatch"); #endif /* * Check if we need to map into the alternate color space. * We must preserve tcode for implementing a semi-hack in the interpreter. */ if (pis->color_component_map.use_alt_cspace) { /* First see if we have a named color object that we can use to try to map from the spot color into device values. */ if (pis->icc_manager->device_named != NULL) { /* There is a table present. If we have the colorant name then get the device values */ gx_color_value device_values[GX_DEVICE_COLOR_MAX_COMPONENTS]; byte *pname; uint name_size; gsicc_rendering_param_t rendering_params; /* Define the rendering intents. */ rendering_params.black_point_comp = pis->blackptcomp; rendering_params.graphics_type_tag = dev->graphics_type_tag; rendering_params.override_icc = false; rendering_params.preserve_black = gsBKPRESNOTSPECIFIED; rendering_params.rendering_intent = pis->renderingintent; rendering_params.cmm = gsCMM_DEFAULT; /* Allocate and initialize name structure */ named_color = (gsicc_namedcolor_t*) gs_alloc_bytes(dev->memory, num_src_comps * sizeof(gsicc_namedcolor_t), "gx_remap_concrete_DeviceN"); for (k = 0; k < num_src_comps; k++) { pcs->params.device_n.get_colorname_string(dev->memory, names[k], &pname, &name_size); named_color[k].colorant_name = (char*) pname; named_color[k].name_size = name_size; } code = gsicc_transform_named_color(pc->paint.values, named_color, num_src_comps, device_values, pis, dev, NULL, &rendering_params); gs_free_object(dev->memory, named_color, "gx_remap_concrete_DeviceN"); if (code == 0) { for (k = 0; k < num_des_comps; k++){ pconc[k] = float2frac(((float) device_values[k])/65535.0); } return(0); } } /* Check the 1-element cache first. */ if (map->cache_valid) { int i; for (i = pcs->params.device_n.num_components; --i >= 0;) { if (map->tint[i] != pc->paint.values[i]) break; } if (i < 0) { int num_out = gs_color_space_num_components(pacs); for (i = 0; i < num_out; ++i) pconc[i] = map->conc[i]; return 0; } } tcode = (*pcs->params.device_n.map->tint_transform) (pc->paint.values, &cc.paint.values[0], pis, pcs->params.device_n.map->tint_transform_data); (*pacs->type->restrict_color)(&cc, pacs); if (tcode < 0) return tcode; /* First check if this was PS based. */ if (gs_color_space_is_PSCIE(pacs)) { /* We may have to rescale data to 0 to 1 range */ rescale_cie_colors(pacs, &cc); /* If we have not yet created the profile do that now */ if (pacs->icc_equivalent == NULL) { gs_colorspace_set_icc_equivalent(pacs, &(is_lab), pis->memory); } /* Use the ICC equivalent color space */ pacs = pacs->icc_equivalent; } if (pacs->cmm_icc_profile_data->data_cs == gsCIELAB || pacs->cmm_icc_profile_data->islab) { /* Get the data in a form that is concrete for the CMM */ cc.paint.values[0] /= 100.0; cc.paint.values[1] = (cc.paint.values[1]+128)/255.0; cc.paint.values[2] = (cc.paint.values[2]+128)/255.0; } code = cs_concretize_color(&cc, pacs, pconc, pis, dev); } else { int i; for (i = num_src_comps; --i >= 0;) pconc[i] = gx_unit_frac(pc->paint.values[i]); return 0; } return (code < 0 || tcode == 0 ? code : tcode); }