Exemple #1
0
/* <dict> <crd> .setcolorrendering1 - */
static int
zsetcolorrendering1(i_ctx_t *i_ctx_p)
{
    os_ptr op = osp;
    es_ptr ep = esp;
    ref_cie_render_procs procs;
    int code;

    check_type(op[-1], t_dictionary);
    check_stype(*op, st_cie_render1);
    code = zcrd1_proc_params(imemory, op - 1, &procs);
    if (code < 0)
	return code;
    code = gs_setcolorrendering(igs, r_ptr(op, gs_cie_render));
    if (code < 0)
	return code;
    if (gs_cie_cs_common(igs) != 0 &&
	(code = cie_cache_joint(i_ctx_p, &procs, gs_cie_cs_common(igs), igs)) < 0
	)
	return code;
    istate->colorrendering.dict = op[-1];
    istate->colorrendering.procs = procs;
    pop(2);
    return (esp == ep ? 0 : o_push_estack);
}
Exemple #2
0
static int
pl_build_crd(gs_state *pgs)
{
    int code;
    /* nothing to do */
    if ( pl_pcrd_built == true )
        return gs_setcolorrendering(pgs, pl_pcrd);

    code = gs_cie_render1_build(&pl_pcrd, gs_state_memory(pgs), "build_crd");
    if ( code < 0 )
	return code;
    pl_pcrd_built = true;

    if ( pl_read_device_CRD(pl_pcrd, pgs) ) {
        dprintf("CRD initialized from device\n");
        return 0;
    }

    code = gs_cie_render1_initialize(pgs->memory, 
				     pl_pcrd,
                                     NULL,
                                     &pl_WhitePoint,
                                     &pl_BlackPoint,
                                     &pl_MatrixPQR,
                                     &pl_RangePQR,
                                     &pl_TransformPQR,
                                     &pl_MatrixCRDLMN,
                                     NULL, /* EncodeLMN */
                                     NULL, /* RangeLMN */
                                     NULL, /* MatrixABC */
                                     &pl_EncodeABC_procs,
                                     NULL,
                                     NULL);
    if ( code < 0 )
	return code; /* should not fail */
    code = gs_setcolorrendering(pgs, pl_pcrd);
    return code;
}
Exemple #3
0
static int
test6(gs_state * pgs, gs_memory_t * mem)
{
    gs_color_space *pcs;
    gs_cie_abc *pabc;
    gs_cie_render *pcrd;
    static const gs_vector3 white_point =
    {1, 1, 1};
    static const gs_cie_render_proc3 encode_abc =
    {
        {render_abc, render_abc, render_abc}
    };
    int code;
    gs_color_space *rgb_cs;

    rgb_cs = gs_cspace_new_DeviceRGB(mem);

    gs_scale(pgs, 150.0, 150.0);
    gs_translate(pgs, 0.5, 0.5);
    gs_setcolorspace(pgs, rgb_cs);
    spectrum(pgs, 5);
    gs_translate(pgs, 1.2, 0.0);
    /* We must set the CRD before the color space. */
    code = gs_cie_render1_build(&pcrd, mem, "test6");
    if (code < 0)
        return code;
    gs_cie_render1_initialize(mem, pcrd, NULL, &white_point, NULL,
                              NULL, NULL, NULL,
                              NULL, NULL, NULL,
                              NULL, &encode_abc, NULL,
                              NULL);
    gs_setcolorrendering(pgs, pcrd);
    gs_cspace_build_CIEABC(&pcs, NULL, mem);
    /* There should be an API for initializing CIE color spaces too.... */
    pabc = pcs->params.abc;
    pabc->common.points.WhitePoint = white_point;
    gs_cie_abc_complete(pabc);
    /* End of initializing the color space. */
    gs_setcolorspace(pgs, pcs);
    spectrum(pgs, 5);
    gs_free_object(mem, rgb_cs, "test6 rgb_cs");
    return 0;
}
Exemple #4
0
/* <dict> <crd> .setdevicecolorrendering1 - */
static int
zsetdevicecolorrendering1(i_ctx_t *i_ctx_p)
{
    os_ptr op = osp;
    int code;
    ref_cie_render_procs procs;

    check_type(op[-1], t_dictionary);
    check_stype(*op, st_cie_render1);
    code = gs_setcolorrendering(igs, r_ptr(op, gs_cie_render));
    if (code < 0)
	return code;
    refset_null((ref *)&procs, sizeof(procs) / sizeof(ref));
    if (gs_cie_cs_common(igs) != 0 &&
	(code = cie_cache_joint(i_ctx_p, &procs, gs_cie_cs_common(igs), igs)) < 0
	)
	return code;
    istate->colorrendering.dict = op[-1];
    refset_null((ref *)&istate->colorrendering.procs,
		sizeof(istate->colorrendering.procs) / sizeof(ref));
    pop(2);
    return 0;
}