예제 #1
0
/*
 * ESC * v <nbytes> W
 *
 * This command creates only the basic element of the the palette: the cid_data
 * array. Other parts are created as needed.
 */
static int
pcl_configure_image_data(pcl_args_t * pargs, pcl_state_t * pcs)
{
    if (pcs->personality == pcl5e || pcs->raster_state.graphics_mode)
        return 0;
#ifdef DEBUG
    if (gs_debug_c('i')) {
        pcl_debug_dump_data(pcs->memory, arg_data(pargs), uint_arg(pargs));
    }
#endif
    return install_cid_data(uint_arg(pargs),
                            arg_data(pargs), pcs, false, false);
}
예제 #2
0
파일: pcpage.c 프로젝트: hackqiang/gs
/*
 * ESC & l <psize_enum> A
 *
 * Select paper size
 */
static int
set_page_size(pcl_args_t * pargs, pcl_state_t * pcs)
{
    /* Note: not all values are implemented on all printers.  If -g
       has been given on the command line we use the "Custom" page
       tag, the height and width are set to the device media values
       which were filled in when the -g option was processed. */

    uint tag = (pcs->page_set_on_command_line ? 101 : uint_arg(pargs));
    int i;
    int code = 0;
    const pcl_paper_size_t *psize = 0;

    /* oddly the command goes to the next page irrespective of
       arguments */
    code = pcl_end_page_if_marked(pcs);
    if (code < 0)
        return code;
    pcl_home_cursor(pcs);

    for (i = 0; i < pcl_paper_type_count; i++) {
        if (tag == PAPER_SIZES[i].tag) {
            psize = &(PAPER_SIZES[i].psize);
            break;
        }
    }
    if ((psize != 0) && ((code = pcl_end_page_if_marked(pcs)) >= 0)) {
        pcs->xfm_state.print_dir = 0;
        new_page_size(pcs, psize, false, false);
    }
    return code;
}
예제 #3
0
/*
 * ESC * i <nbytes> W
 *
 * Set viewing illuminant. This command is related to the configure image
 * data object only in the sense that both apply to palettes. The command
 * is implemented in this file as it is the only other command that involves
 * binary floating point number arrays.
 *
 * This routine will convert the whitepoint to the form anticipated by the
 * gs_cie_render structure (i.e., Y = 1.0).
 */
static int
set_view_illuminant(pcl_args_t * pargs, pcl_state_t * pcs)
{
    uint len = uint_arg(pargs);
    const byte *pbuff = arg_data(pargs);
    float x, y;
    gs_vector3 wht_pt;

    if (pcs->personality == pcl5e || pcs->raster_state.graphics_mode)
        return 0;

    if (len != 8)
        return e_Range;
    x = make_float(pbuff);
    y = make_float(pbuff + 4);

    /*
     * A white point must have a non-zero y value, as otherwise it carries
     * no chromaticity infomration. It should also have x >= 0, y > 0, and
     * x + y <= 1, for otherwise it represents an unrealizable color.
     */
    if ((x < 0.0) || (y <= 0.0) || (x + y > 1.0))
        return e_Range;

    wht_pt.u = x / y;
    wht_pt.v = 1.0;
    wht_pt.w = (1.0 - x - y) / y;

    return pcl_palette_set_view_illuminant(pcs, &wht_pt);
}
예제 #4
0
파일: pcpage.c 프로젝트: hackqiang/gs
/*
 * ESC & l <orient> O
 *
 * Set logical page orientation.
 */
static int
set_logical_page_orientation(pcl_args_t * pargs, pcl_state_t * pcs)
{
    uint i = uint_arg(pargs);
    int code;
    /* the command is ignored if it is value is out of range */
    if (i > 3)
        return 0;

    /* this command is ignored in pcl xl snippet mode.  NB we need a
       better flag for snippet mode. */
    if (pcs->end_page != pcl_end_page_top) {
        return 0;
    }

    /* If orientation is same as before ignore the command */
    if (i == pcs->xfm_state.lp_orient) {
        return 0;
    }

    /* ok to execute - clear the page, set up the transformations and
       set the flag disabling the orientation command for this page. */
    code = pcl_end_page_if_marked(pcs);
    if (code >= 0) {
        new_logical_page(pcs, i, pcs->xfm_state.paper_size, false, false);
        pcs->hmi_cp = HMI_DEFAULT;
        pcs->vmi_cp = VMI_DEFAULT;
    }
    return code;
}
예제 #5
0
파일: pcpage.c 프로젝트: hackqiang/gs
/*
 * ESC & l <feed_enum> H
 *
 * Set paper source
 */
static int
set_paper_source(pcl_args_t * pargs, pcl_state_t * pcs)
{
    uint i = uint_arg(pargs);
    /* oddly the command goes to the next page irrespective of
       arguments */
    int code = pcl_end_page_if_marked(pcs);

    if (code < 0)
        return code;
    pcl_home_cursor(pcs);
    /* Do not change the page side if the wanted paper source is the same as the actual one */
    if (pcs->paper_source != i) {
        pcs->back_side = false;
        put_param1_bool(pcs, "FirstSide", !pcs->back_side);
    }
    pcs->paper_source = i;
    /* Note: not all printers support all possible values. */
    if (i <= 6) {
        code = 0;
        if (i > 0)
            code = put_param1_int(pcs, "%MediaSource", i);
        return (code < 0 ? code : 0);
    } else
        return e_Range;
}
예제 #6
0
파일: pcpage.c 프로젝트: ststeiger/ghostsvg
/*
 * ESC & l <line> E
 *
 * Set top margin. This will also reset the page length.
 */
  static int
set_top_margin(
    pcl_args_t *    pargs,
    pcl_state_t *   pcs
)
{
    coord           hgt = pcs->xfm_state.pd_size.y;
    coord           tmarg = uint_arg(pargs) * pcs->vmi_cp;

    if ((pcs->vmi_cp != 0) && (tmarg <= hgt)) {
        bool was_default = (pcs->margins.top == TOP_MARGIN(hgt, DFLT_TOP_MARGIN) &&
                            pcs->margins.left == DFLT_LEFT_MARGIN);

        pcs->margins.top = tmarg;
        pcs->margins.length = PAGE_LENGTH(hgt - tmarg, DFLT_BOTTOM_MARGIN);

        /* If the cursor has been moved then we have a fixed cap and the
           top margin only affects the next page. If the cap is floating,
           unmarked and unmoved, then the cap moves to the first line of text.
           More restrictive than implementor's guide:
           iff a default margin is changed on an unmarked unmoved page to the new margin.
           margin_set(A) ^L margin_set(B)  --> use (A)
           escE margin_set(B) --> use (B)
         */
        if (was_default && pcl_page_marked(pcs) == 0 )
            return pcl_set_cap_y(pcs, 0L, false, false, true, false);
    }
    return 0;
}
예제 #7
0
파일: pcjob.c 프로젝트: ststeiger/ghostsvg
static int /* ESC & l <bin_enum> G */
pcl_output_bin_selection(pcl_args_t *pargs, pcl_state_t *pcs)
{	uint i = uint_arg(pargs);
	if ( i < 1 || i > 2 )
	  return e_Range;
	return put_param1_int(pcs, "OutputBin", i);
}
예제 #8
0
/*
 * ESC & f <pp_enum> S
 *
 * Contrary to what is indicated in the "PCL 5 Printer Language Technical
 * Reference Manual", October 1992 ed., p. 6-16, pushd cursors are stored
 * in logical page space, not device space.
 */
static int
push_pop_cursor(pcl_args_t * pargs, pcl_state_t * pcs)
{
    int type = uint_arg(pargs);

    if ((type == 0) && (pcs->cursor_stk_size < countof(pcs->cursor_stk))) {
        gs_point *ppt = &(pcs->cursor_stk[pcs->cursor_stk_size++]);

        ppt->x = (double)pcs->cap.x;
        ppt->y = (double)pcs->cap.y;
        gs_point_transform(ppt->x, ppt->y, &(pcs->xfm_state.pd2lp_mtx), ppt);

    } else if ((type == 1) && (pcs->cursor_stk_size > 0)) {
        gs_point *ppt = &(pcs->cursor_stk[--pcs->cursor_stk_size]);
        gs_matrix lp2pd;

        pcl_invert_mtx(&(pcs->xfm_state.pd2lp_mtx), &lp2pd);
        gs_point_transform(ppt->x, ppt->y, &lp2pd, ppt);
        pcl_set_cap_x(pcs, (coord) ppt->x, false, false);
        pcl_set_cap_y(pcs,
                      (coord) ppt->y - pcs->margins.top,
                      false, false, false, false);
    }

    return 0;
}
예제 #9
0
/*
 * ESC & k G
 */
static int
set_line_termination(pcl_args_t * pargs, pcl_state_t * pcs)
{
    uint ui = uint_arg(pargs);

    if (ui <= 3)
        pcs->line_termination = ui;
    return 0;
}
예제 #10
0
파일: pcpage.c 프로젝트: hackqiang/gs
/*
 * ESC & l <enable> L
 *
 * Set perforation skip mode. Though performation skip is more closely related
 * to vertical motion than to margins, the command is included here because it
 * resets the vertical margins (top margin and text length) to their defaults.
 */
static int
set_perforation_skip(pcl_args_t * pargs, pcl_state_t * pcs)
{
    bool new_skip = uint_arg(pargs);

    if ((new_skip != pcs->perforation_skip) && (new_skip <= 1))
        pcs->perforation_skip = new_skip;
    return 0;
}
예제 #11
0
/*
 * ESC * l <bool> R
 *
 * Set prixel placement. Note that this feature is not yet properly
 * implemented.
 */
static int
pcl_pixel_placement(pcl_args_t * pargs, pcl_state_t * pcs)
{
    uint i = uint_arg(pargs);

    if (pcs->raster_state.graphics_mode)
        return 0;
    if (i > 1)
        return 0;
    pcs->pp_mode = i;
    return 0;
}
예제 #12
0
/*
 * ESC * r # t
 *
 * Set raster height. Note that the useable height may be less due to clipping.
 * This implementation ignores the sign of the dimension, which matches the
 * behavior of the HP Color LaserJet 5/5M. The behavior of the of the DeskJet
 * 1600C/CM differs: it ignores the command if a negative operand is provided.
 *
 * This command is ignored in graphics mode.
 */
  static int
set_src_raster_height(
    pcl_args_t *    pargs,
    pcl_state_t *   pcs
)
{
    if (!pcs->raster_state.graphics_mode) {
        pcs->raster_state.src_height = uint_arg(pargs);
        pcs->raster_state.src_height_set = true;
    }
    return 0;
}
예제 #13
0
/*
 * ESC * b # M
 *
 * Set compresson method.
 *
 * This command is unique among PCL commands in that it is interpreted both
 * inside and outside of graphics mode, and its execution neither starts nor
 * ends graphic mode.
 *
 * It is not possible to use adaptive compression (mode 5) with mutliple plane
 * pixel encodings, but it is not possible to check for a conflict at this
 * point as the pixel encoding may be changed before any raster data is
 * transfered. Hence, the transfer raster data command must perform the required
 * check.
 */
  static int
set_compression_method(
    pcl_args_t *    pargs,
    pcl_state_t *   pcs
)
{
    uint            mode = uint_arg(pargs);

    if ( (mode < count_of(pcl_decomp_proc))                                 &&
         ((pcl_decomp_proc[mode] != 0) || (mode == (uint)ADAPTIVE_COMPRESS))  )
        pcs->raster_state.compression_mode = mode;
    return 0;
}
예제 #14
0
파일: pcpage.c 프로젝트: hackqiang/gs
static int
set_logical_page(pcl_args_t * pargs, pcl_state_t * pcs)
{
    uint count = uint_arg(pargs);

    const pcl_logical_page_t *plogpage =
        (pcl_logical_page_t *) arg_data(pargs);
    pcl_paper_size_t *pcur_paper;

#ifdef DEBUG
    if (gs_debug_c('i')) {
        pcl_debug_dump_data(pcs->memory, arg_data(pargs), uint_arg(pargs));
    }
#endif

    /* the currently selected paper size */
    pcur_paper = (pcl_paper_size_t *) pcs->xfm_state.paper_size;

    /* the command can set width, height and offsets (10) or just
       offsets (4) */
    if (count != 10 && count != 4)
        return e_Range;

    if (count == 10) {
        pcur_paper->width = pl_get_uint16(plogpage->Width) * 10;
        pcur_paper->height = pl_get_uint16(plogpage->Height) * 10;
        if (pcur_paper->width == 0 || pcur_paper->height == 0)
            return e_Range;
    }

    pcur_paper->offset_portrait = pl_get_int16(plogpage->LeftOffset) * 10;
    pcur_paper->offset_landscape = pl_get_int16(plogpage->TopOffset) * 10;

    new_page_size(pcs, pcur_paper, false, false);
    gs_erasepage(pcs->pgs);
    pcs->page_marked = false;
    return 0;
}
예제 #15
0
/*
 * ESC & l <lpi> D
 *
 * Set line spacing. Though it is not documented anywhere, various HP devices
 * agree that a zero operand specifies 12 lines per inch (NOT the default).
 */
static int
set_line_spacing(pcl_args_t * pargs, pcl_state_t * pcs)
{
    uint lpi = uint_arg(pargs);
    bool cursor_at_home = pcl_cursor_at_home_pos(pcs);

    if (lpi == 0)               /* 0 ==> 12 lines per inch */
        lpi = 12;
    if ((48 % lpi) == 0)        /* lpi must divide 48 */
        pcs->vmi_cp = inch2coord(1.0 / lpi);
    if (cursor_at_home)
        pcl_home_cursor(pcs);
    return 0;
}
예제 #16
0
파일: pcpage.c 프로젝트: ststeiger/ghostsvg
 static int
set_logical_page(
    pcl_args_t *    pargs,
    pcl_state_t *   pcs
)
{
    uint count = uint_arg(pargs);
    const pcl_logical_page_t *plogpage =
        (pcl_logical_page_t *)arg_data(pargs);

    if (count != 10)
        return e_Range;
    return 0;
}
예제 #17
0
파일: pcpage.c 프로젝트: hackqiang/gs
/*
 * (From PCL5 Comparison Guide, p. 1-98)
 *
 * ESC & l <type> M
 *
 * Set media type.
 */
static int
pcl_media_type(pcl_args_t * pargs, pcl_state_t * pcs)
{
    int type = uint_arg(pargs);

    if (type <= 4) {
        int code = pcl_end_page_if_marked(pcs);

        if (code >= 0)
            pcl_home_cursor(pcs);
        return (code < 0 ? code : e_Unimplemented);
    } else
        return e_Range;
}
예제 #18
0
파일: pcpage.c 프로젝트: hackqiang/gs
/*
 * ESC & a <col> M
 *
 * Set right margin. The right margin is set to the *right* edge of the
 * specified column, so we need to add 1 to the column number.
 */
static int
set_right_margin(pcl_args_t * pargs, pcl_state_t * pcs)
{
    coord rmarg = (uint_arg(pargs) + 1) * pcl_hmi(pcs);

    if (rmarg > pcs->xfm_state.pd_size.x)
        rmarg = pcs->xfm_state.pd_size.x;
    if (rmarg > pcs->margins.left) {
        pcs->margins.right = rmarg;
        if (pcs->cap.x > rmarg)
            pcl_set_cap_x(pcs, rmarg, false, false);
    }

    return 0;
}
예제 #19
0
/*
 * ESC * l <rop> O
 *
 * Set logical operation.
 */
static int
pcl_logical_operation(pcl_args_t * pargs, pcl_state_t * pcs)
{
    uint rop = uint_arg(pargs);

    if (pcs->raster_state.graphics_mode)
        return 0;
    if (rop > 255)
        return e_Range;

    pcl_break_underline(pcs);   /* use the 5c convention; in 5e, the
                                 * underline is not broken by a change in
                                 * the logical operation */
    pcs->logical_op = rop;
    return 0;
}
예제 #20
0
파일: pcpage.c 프로젝트: hackqiang/gs
static int
set_paper_length(pcl_args_t * pargs, pcl_state_t * pcs)
{
    uint decipoints = uint_arg(pargs);
    int i;
    pcl_paper_size_t *psize;

    for (i = 0; i < pcl_paper_type_count; i++) {
        if (101 == PAPER_SIZES[i].tag) {
            psize = &(PAPER_SIZES[i].psize);
            break;
        }
    }
    psize->height = decipoints * 10L;
    return 0;
}
예제 #21
0
/*
 * ESC * r # F
 *
 * Set raster graphics presentation mode.
 *
 * This command is ignored if values other than 0 and 3 are provided, ignoring
 * any sign. The command is also ignored inside graphics mode.
 */
  static int
set_graphics_presentation_mode(
    pcl_args_t *    pargs,
    pcl_state_t *   pcs
)
{
    uint            mode = uint_arg(pargs);

    if (!pcs->raster_state.graphics_mode) {
        if (mode == 3)
            pcs->raster_state.pres_mode_3 = 1;
        else if (mode == 0)
            pcs->raster_state.pres_mode_3 = 0;
    }

    return 0;
}
예제 #22
0
파일: pcpage.c 프로젝트: hackqiang/gs
/*
 * ESC & l <lines> F
 *
 * Set text length (which indirectly sets the bottom margin).
 */
static int
set_text_length(pcl_args_t * pargs, pcl_state_t * pcs)
{
    coord len = uint_arg(pargs) * pcs->vmi_cp;

    if (len == 0) {
        len =
            pcs->xfm_state.pd_size.y - pcs->margins.top -
            inch2coord(1.0 / 2.0);
        if (len < 0) {
            len += inch2coord(1.0 / 2.0);
        }
    }
    if ((len >= 0) && (pcs->margins.top + len <= pcs->xfm_state.pd_size.y))
        pcs->margins.length = len;
    return 0;
}
예제 #23
0
파일: pcpage.c 프로젝트: hackqiang/gs
/*
 * ESC & a <col> L
 *
 * Set left margin.
 */
static int
set_left_margin(pcl_args_t * pargs, pcl_state_t * pcs)
{
    coord lmarg = uint_arg(pargs) * pcl_hmi(pcs);

    /* adjust underlining if the left margin passes to the right of
       the underline start position */
    if ((pcs->underline_enabled) && (lmarg > pcs->underline_start.x))
        pcs->underline_start.x = lmarg;

    if (lmarg < pcs->margins.right) {
        pcs->margins.left = lmarg;
        if (pcs->cap.x < lmarg)
            pcl_set_cap_x(pcs, lmarg, false, false);
    }
    return 0;
}
예제 #24
0
파일: pcpage.c 프로젝트: hackqiang/gs
/*
 * ESC & l <line> E
 *
 * Set top margin. This will also reset the page length.
 */
static int
set_top_margin(pcl_args_t * pargs, pcl_state_t * pcs)
{
    coord hgt = pcs->xfm_state.pd_size.y;
    coord tmarg = uint_arg(pargs) * pcs->vmi_cp;

    if ((pcs->vmi_cp != 0) && (tmarg <= hgt)) {
        pcs->margins.top = tmarg;
        pcs->margins.length = PAGE_LENGTH(hgt - tmarg, DFLT_BOTTOM_MARGIN);
        /* See the discussion in the Implementor's guide concerning
           "fixed" and "floating" cap.  If the page is not dirty we
           home the cursor - the guide talks about tracking the cursor
           for any movement and checking for data on the page */
        if (!pcl_page_marked(pcs) && !pcl_cursor_moved(pcs))
            return pcl_set_cap_y(pcs, 0L, false, false, true, false);
    }
    return 0;
}
예제 #25
0
파일: pcjob.c 프로젝트: ststeiger/ghostsvg
static int /* ESC & a <side_enum> G */
pcl_duplex_page_side_select(pcl_args_t *pargs, pcl_state_t *pcs)
{	uint i = uint_arg(pargs);
	int code;

	/* oddly the command goes to the next page irrespective of
           arguments */
	code = pcl_end_page_if_marked(pcs);
	if ( code < 0 )
	    return code;
	pcl_home_cursor(pcs);

	if ( i > 2 )
	  return 0;

	if ( i > 0 && pcs->duplex )
	  put_param1_bool(pcs, "FirstSide", i == 1);
	return 0;
}
예제 #26
0
/*
 * ESC * t # R
 *
 * Set raster graphics resolution. 
 * The value provided will be rounded up to the nearest legal value or down to 600dpi. 
 * 75 100 150 200 300 600 are legal;  120 and 85.7143 are multiples of 75 but not legal.
 */
  static int
set_graphics_resolution(
    pcl_args_t *    pargs,
    pcl_state_t *   pcs
)
{
    uint            res = arg_is_present(pargs) ? uint_arg(pargs) : 75;
    uint            qi = 600 / res;


    /* HP does not allow 120 dpi or 85.7 dpi as a resolution */
    qi = (qi == 0 ? 1 : (qi > 8 ? 8 : (qi == 7 ? 6 : (qi == 5 ? 4 : qi))));

    /* ignore if already in graphics mode */
    if (!pcs->raster_state.graphics_mode)
        pcs->raster_state.resolution = 600 / qi;

    return 0;
}
예제 #27
0
파일: pcpage.c 프로젝트: hackqiang/gs
/*
 * ESC & a <angle> P
 */
static int
set_print_direction(pcl_args_t * pargs, pcl_state_t * pcs)
{
    uint i = uint_arg(pargs);

    if ((i <= 270) && (i % 90 == 0)) {
        i /= 90;
        if (i != pcs->xfm_state.print_dir) {
            pcl_break_underline(pcs);
            pcs->xfm_state.print_dir = i;
            update_xfm_state(pcs, 0);
            pcl_continue_underline(pcs);
        } else {
            pcs->xfm_state.print_dir = i;
            update_xfm_state(pcs, 0);
        }
    }
    return 0;
}
예제 #28
0
/*
 * ESC * p # R
 *
 * Set pattern reference point.
 *
 */
  static int
set_pat_ref_pt(
    pcl_args_t *    pargs,
    pcl_state_t *   pcs
)
{
    uint            rotate = uint_arg(pargs);

    if (rotate <= 1) {
        pcl_break_underline(pcs);
        gs_point_transform( (floatp)pcs->cap.x,
                            (floatp)pcs->cap.y,
                            &(pcs->xfm_state.pd2lp_mtx),
                            &(pcs->pcl_pat_ref_pt)
                            );
        pcs->rotate_patterns = (rotate == 0);
    }
    return 0;
}
예제 #29
0
/*
 * ESC * r # A
 *
 * Start raster graphics mode.
 *
 * See the commment ahead of the procedure pcl_enter_graphics mode above for
 * a discussion of the rather curios manner in which the left raster graphics
 * margin is set below.
 */
  static int
start_graphics_mode(
    pcl_args_t *            pargs,
    pcl_state_t *           pcs
)
{
    pcl_gmode_entry_t       mode = (pcl_gmode_entry_t)uint_arg(pargs);
    pcl_raster_state_t *    prstate = &(pcs->raster_state);

    if (mode > SCALE_CUR_PTR)
        mode = NO_SCALE_LEFT_MARG;
    if (!prstate->graphics_mode) {
        int r90 = (pcs->xfm_state.lp_orient + pcs->xfm_state.print_dir) & 0x1;

        prstate->scale_raster = ((((int)mode) & 0x2) != 0);
        prstate->gmargin_cp = 0;
        if (prstate->pres_mode_3 && (r90 != 0))
            prstate->gmargin_cp += inch2coord(1.0 / 6.0);
        pcl_enter_graphics_mode(pcs, mode);
    }
    return 0;
}
예제 #30
0
파일: rtmisc.c 프로젝트: ststeiger/ghostsvg
/*
 * ESC & b <count> W
 */
  static int
pcl_appletalk_configuration(
    pcl_args_t *    pargs,
    pcl_state_t *   pcs
)
{
    const byte *    data = arg_data(pargs);
    uint            count = uint_arg(pargs);
    uint            i;

    if ((count < 2) || (data[0] == ' '))
	return e_Range;

    /* split the string at the first space */
    for (i = 1; data[i] != ' '; ++i) {
	if (i == count - 1)
	    return e_Range;
    }
    if (pcs->configure_appletalk == 0)
	return 0;
    return (*pcs->configure_appletalk)(data, i, data + i + 1, count - (i + 1));
}