client_install_CIEtoA(client_custom_color_params_t * pparams, gs_color_space * pcs, gs_state * pgs) { /* get ready for converting to XYZ */ demo_color_space_data_t * pdata; /* Exit if we have already installed this color space. */ if (pcs->pclient_color_space_data != NULL) return true; pdata = allocate_client_data_block(1, pcs->rc.memory->stable_memory); pcs->pclient_color_space_data = (client_color_space_data_t *) pdata; if (pdata) { int code; gs_cie_a *pcie = pcs->params.a; gs_sample_loop_params_t lp; int i; pdata->client_is_going_to_handle_color_space = 1; /* Fill the caches we need in the CIE color space */ gs_cie_cache_init(&pcie->caches.DecodeA.floats.params, &lp, &pcie->RangeA, "DecodeA"); for (i = 0; i <= lp.N; ++i) { float in = SAMPLE_LOOP_VALUE(i, lp); pcie->caches.DecodeA.floats.values[i] = (*pcie->DecodeA)(in, pcie); } gx_cie_load_common_cache(&pcie->common, pgs); gs_cie_a_complete(pcie); if ((code=gs_cie_cs_complete(pgs, true)) >= 0) { /* Now allocate the conversion imager state in stable_memory */ /* so that the garbage collector won't free it */ code = gx_cie_to_xyz_alloc(&pdata->CIEtoXYZ_pis, pcs, pcs->rc.memory->stable_memory); } if (code < 0) { client_adjust_cspace_count(pcs, -1); /* free it up */ return false; } } return true; }
static bool client_install_ICCtoXYZ(client_custom_color_params_t * pparams, gs_color_space * pcs, gs_state * pgs) { int code; const gs_icc_params * picc_params = (const gs_icc_params *)&pcs->params.icc; gs_cie_icc * picc_info = picc_params->picc_info; demo_color_space_data_t * pdata; if (pcs->pclient_color_space_data != NULL) return true; pdata = allocate_client_data_block(1, pcs->rc.memory->stable_memory); pcs->pclient_color_space_data = (client_color_space_data_t *) pdata; /* Need to initialize the client data. The imager_state is what is needed in pdata->CIEtoXZY_ps */ /* update the stub information used by the joint caches */ gx_cie_load_common_cache(&picc_info->common, pgs); gx_cie_common_complete(&picc_info->common); if ((code=gs_cie_cs_complete(pgs, true)) < 0) { client_adjust_cspace_count(pcs, -1); /* free it up */ return false; } /* Now allocate the conversion imager state in stable_memory */ /* so that the garbage collector won't free it */ code = gx_cie_to_xyz_alloc(&pdata->CIEtoXYZ_pis, pcs, pcs->rc.memory->stable_memory); if (code < 0) { client_adjust_cspace_count(pcs, -1); /* free it up */ return false; } return true; }