Esempio n. 1
0
/* Note that this takes a px_state_t, not a px_gstate_t. */
int
px_initgraphics(px_state_t *pxs)
{	gs_state *pgs = pxs->pgs;

	px_gstate_reset(pxs->pxgs);
	gs_initgraphics(pgs);

	gs_setfilladjust(pgs, 0.5, 0.5);

	{ gs_point inch;
	  float dpi;

	  gs_dtransform(pgs, 72.0, 0.0, &inch);
	  dpi = fabs(inch.x) + fabs(inch.y);

	  /* Stroke adjustment leads to anomalies at high resolutions. */
	  if ( dpi >= 150 )
	    gs_setstrokeadjust(pgs, false);

	  /* We need the H-P interpretation of zero-length lines */
	  /* and of using bevel joins for the segments of flattened curves. */
	  gs_setdotlength(pgs, 72.0 / 300, true);
	}
	/* we always clamp coordinates hp does not seem to report
           limit checks in paths */
	gs_setlimitclamp(pgs, true);
	return 0;
}
Esempio n. 2
0
/* Initialize the graphics stack. */
gs_state *
int_gstate_alloc(const gs_dual_memory_t * dmem)
{
    int_gstate *iigs;
    ref proc0;
    int_remap_color_info_t *prci;
    gs_ref_memory_t *lmem = dmem->space_local;
    gs_ref_memory_t *gmem = dmem->space_global;
    gs_state *pgs = gs_state_alloc((gs_memory_t *)lmem);

    iigs = gs_alloc_struct((gs_memory_t *)lmem, int_gstate, &st_int_gstate,
			   "int_gstate_alloc(int_gstate)");
    int_gstate_map_refs(iigs, make_null);
    make_empty_array(&iigs->dash_pattern_array, a_all);
    gs_alloc_ref_array(lmem, &proc0, a_readonly + a_executable, 2,
		       "int_gstate_alloc(proc0)");
    make_oper(proc0.value.refs, 0, zpop);
    make_real(proc0.value.refs + 1, 0.0);
    iigs->black_generation = proc0;
    iigs->undercolor_removal = proc0;
    make_false(&iigs->use_cie_color);
    /*
     * Even though the gstate itself is allocated in local VM, the
     * container for the color remapping procedure must be allocated in
     * global VM so that the gstate can be copied into global VM.
     */
    prci = gs_alloc_struct((gs_memory_t *)gmem, int_remap_color_info_t,
			   &st_int_remap_color_info,
			   "int_gstate_alloc(remap color info)");
    make_struct(&iigs->remap_color_info, imemory_space(gmem), prci);
    clear_pagedevice(iigs);
    gs_state_set_client(pgs, iigs, &istate_procs, true);
    /* PostScript code wants limit clamping enabled. */
    gs_setlimitclamp(pgs, true);
    /*
     * gsave and grestore only work properly
     * if there are always at least 2 entries on the stack.
     * We count on the PostScript initialization code to do a gsave.
     */
    return pgs;
}
Esempio n. 3
0
void
hpgl_do_reset(pcl_state_t * pcs, pcl_reset_type_t type)
{
    /* pgframe.c (Chapter 18) */
    hpgl_args_t hpgl_args;

    if ((type & (pcl_reset_initial | pcl_reset_printer | pcl_reset_cold)) !=
        0) {
        if ((type & (pcl_reset_initial | pcl_reset_cold)) != 0) {
            gx_path_alloc_contained(&pcs->g.polygon.buffer.path,
                                    pcs->memory,
                                    "hpgl_do_reset polygon buffer");
            gs_setlimitclamp(pcs->pgs, true);
        } else
            gx_path_new(&pcs->g.polygon.buffer.path);

        /* provide default anchor point, plot size and picture frame size */
        hpgl_default_coordinate_system(pcs);

        /* we should not have a path at this point but we make sure */
        hpgl_clear_current_path(pcs);

        /* Initialize stick/arc font instances */
        hpgl_initialize_stick_fonts(pcs);

        /* intialize subpolygon started hack flag */
        pcs->g.subpolygon_started = false;

        /* indicates a line down operation has been done in polygon
           mode */
        pcs->g.have_drawn_in_path = false;
        /* execute only the implicit portion of IN */
        hpgl_IN_implicit(pcs);

        /* we select the default pen 1 here, oddly, IN does not select
           the default pen even though it sets pen widths and units of
           measure */
        pcs->g.pen.selected = 1;
    }
    /* NB check all of these */
    if ((type & pcl_reset_page_params) != 0) {
        /* provide default anchor point, plot size and picture frame
           size.  Oddly HP does not reset the scaling parameters
           when the page size is changed. */
        int scale_type = pcs->g.scaling_type;
        hpgl_scaling_params_t params = pcs->g.scaling_params;

        hpgl_default_coordinate_system(pcs);

        /* restore the scaling parameter. */
        pcs->g.scaling_type = scale_type;
        pcs->g.scaling_params = params;

        hpgl_args_setup(&hpgl_args);
        hpgl_IW(&hpgl_args, pcs);
        hpgl_args_set_int(&hpgl_args, 0);
        hpgl_PM(&hpgl_args, pcs);
        hpgl_args_set_int(&hpgl_args, 2);
        hpgl_PM(&hpgl_args, pcs);
        hpgl_args_setup(&hpgl_args);
        hpgl_IP(&hpgl_args, pcs);
    }

    if ((type & pcl_reset_picture_frame) != 0) {
        /* this shouldn't happen.  Picture frame side effects are
           handled directly by the command picture frame command. */
        dmprintf(pcs->memory, "PCL reset picture frame received\n");
    }

    if ((type & pcl_reset_overlay) != 0)
        /* ignore return */
        (void)hpgl_reset_overlay(pcs);

    if ((type & (pcl_reset_plot_size)) != 0) {
        /* this shouldn't happen.  Plot size side effects are handled
           directly by the command picture frame command. */
        dmprintf(pcs->memory, "PCL reset plot received\n");
    }

    if ((type & (pcl_reset_permanent)) != 0) {
        gx_path_free(&pcs->g.polygon.buffer.path,
                     "hpgl_do_reset polygon buffer");
        /* if we have allocated memory for a stick font free the memory */
        hpgl_free_stick_fonts(pcs);
    }
    return;
}