Exemplo n.º 1
0
/* Remap=0 is used by the interpreter. */
int
gs_setcolortransfer_remap(gs_gstate * pgs, gs_mapping_proc red_proc,
                          gs_mapping_proc green_proc,
                          gs_mapping_proc blue_proc,
                          gs_mapping_proc gray_proc, bool remap)
{
    gx_transfer *ptran = &pgs->set_transfer;
    gx_transfer old;
    gs_id new_ids = gs_next_ids(pgs->memory, 4);
    gx_device * dev = pgs->device;

    old = *ptran;
    rc_unshare_struct(ptran->gray, gx_transfer_map, &st_transfer_map,
                      pgs->memory, goto fgray, "gs_setcolortransfer");
    rc_unshare_struct(ptran->red, gx_transfer_map, &st_transfer_map,
                      pgs->memory, goto fred, "gs_setcolortransfer");
    rc_unshare_struct(ptran->green, gx_transfer_map, &st_transfer_map,
                      pgs->memory, goto fgreen, "gs_setcolortransfer");
    rc_unshare_struct(ptran->blue, gx_transfer_map, &st_transfer_map,
                      pgs->memory, goto fblue, "gs_setcolortransfer");
    ptran->gray->proc = gray_proc;
    ptran->gray->id = new_ids;
    ptran->red->proc = red_proc;
    ptran->red->id = new_ids + 1;
    ptran->green->proc = green_proc;
    ptran->green->id = new_ids + 2;
    ptran->blue->proc = blue_proc;
    ptran->blue->id = new_ids + 3;
    ptran->red_component_num =
        gs_color_name_component_number(dev, "Red", 3, ht_type_colorscreen);
    ptran->green_component_num =
        gs_color_name_component_number(dev, "Green", 5, ht_type_colorscreen);
    ptran->blue_component_num =
        gs_color_name_component_number(dev, "Blue", 4, ht_type_colorscreen);
    ptran->gray_component_num =
        gs_color_name_component_number(dev, "Gray", 4, ht_type_colorscreen);
    if (remap) {
        load_transfer_map(pgs, ptran->red, 0.0);
        load_transfer_map(pgs, ptran->green, 0.0);
        load_transfer_map(pgs, ptran->blue, 0.0);
        load_transfer_map(pgs, ptran->gray, 0.0);
        gx_set_effective_transfer(pgs);
        gx_unset_dev_color(pgs);
    } else
        gx_set_effective_transfer(pgs);
    return 0;
  fblue:
    rc_assign(ptran->green, old.green, "setcolortransfer");
  fgreen:
    rc_assign(ptran->red, old.red, "setcolortransfer");
  fred:
    rc_assign(ptran->gray, old.gray, "setcolortransfer");
  fgray:
    return_error(gs_error_VMerror);
}
Exemplo n.º 2
0
/* Remap=0 is used by the interpreter. */
int
gs_setcolortransfer_remap(gs_state *pgs, gs_mapping_proc red_proc,
  gs_mapping_proc green_proc, gs_mapping_proc blue_proc,
  gs_mapping_proc gray_proc, bool remap)
{	gx_transfer_colored *ptran = &pgs->set_transfer.colored;
	gx_transfer_colored old;
	gs_id new_ids = gs_next_ids(4);

	old = *ptran;
	rc_unshare_struct(ptran->gray, gx_transfer_map, &st_transfer_map,
			  pgs->memory, goto fgray, "gs_setcolortransfer");
	rc_unshare_struct(ptran->red, gx_transfer_map, &st_transfer_map,
			  pgs->memory, goto fred, "gs_setcolortransfer");
	rc_unshare_struct(ptran->green, gx_transfer_map, &st_transfer_map,
			  pgs->memory, goto fgreen, "gs_setcolortransfer");
	rc_unshare_struct(ptran->blue, gx_transfer_map, &st_transfer_map,
			  pgs->memory, goto fblue, "gs_setcolortransfer");
	ptran->gray->proc = gray_proc;
	ptran->gray->id = new_ids;
	ptran->red->proc = red_proc;
	ptran->red->id = new_ids + 1;
	ptran->green->proc = green_proc;
	ptran->green->id = new_ids + 2;
	ptran->blue->proc = blue_proc;
	ptran->blue->id = new_ids + 3;
	if ( remap )
	{	load_transfer_map(pgs, ptran->red, 0.0);
		load_transfer_map(pgs, ptran->green, 0.0);
		load_transfer_map(pgs, ptran->blue, 0.0);
		load_transfer_map(pgs, ptran->gray, 0.0);
		gx_set_effective_transfer(pgs);
		gx_unset_dev_color(pgs);
	}
	return 0;
fblue:	rc_assign(ptran->green, old.green, "setcolortransfer");
fgreen:	rc_assign(ptran->red, old.red, "setcolortransfer");
fred:	rc_assign(ptran->gray, old.gray, "setcolortransfer");
fgray:	return_error(gs_error_VMerror);
}