Subversion Repositories planix.SVN

Rev

Rev 2 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
/* Copyright (C) 1998, 1999, 2000 Aladdin Enterprises.  All rights reserved.
2
 
3
  This software is provided AS-IS with no warranty, either express or
4
  implied.
5
 
6
  This software is distributed under license and may not be copied,
7
  modified or distributed except as expressly authorized under the terms
8
  of the license contained in the file LICENSE in this distribution.
9
 
10
  For more information about licensing, please refer to
11
  http://www.ghostscript.com/licensing/. For information on
12
  commercial licensing, go to http://www.artifex.com/licensing/ or
13
  contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14
  San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15
*/
16
 
17
/* $Id: gdevcljc.c,v 1.7 2004/05/26 04:10:58 dan Exp $ */
18
/*
19
 * H-P Color LaserJet 5/5M contone device; based on the gdevclj.c.
20
 */
21
#include "math_.h"
22
#include "gdevprn.h"
23
#include "gdevpcl.h"
24
 
25
/* X_DPI and Y_DPI must be the same */
26
#define X_DPI 300
27
#define Y_DPI 300
28
 
29
/* Send the page to the printer.  Compress each scan line.  NB - the
30
 * render mode as well as color parameters - bpp etc. are all
31
 * hardwired.
32
 */
33
private int
34
cljc_print_page(gx_device_printer * pdev, FILE * prn_stream)
35
{
36
    gs_memory_t *mem = pdev->memory;
37
    uint raster = gx_device_raster((gx_device *)pdev, false);
38
    int i;
39
    int worst_case_comp_size = raster + (raster / 8) + 1;
40
    byte *data = 0;
41
    byte *cdata = 0;
42
    byte *prow = 0;
43
    int code = 0;
44
 
45
    /* allocate memory for the raw data and compressed data.  */
46
    if (((data = gs_alloc_bytes(mem, raster, "cljc_print_page(data)")) == 0) ||
47
	((cdata = gs_alloc_bytes(mem, worst_case_comp_size, "cljc_print_page(cdata)")) == 0) ||
48
	((prow = gs_alloc_bytes(mem, worst_case_comp_size, "cljc_print_page(prow)")) == 0)) {
49
	code = gs_note_error(gs_error_VMerror);
50
	goto out;
51
    }
52
    /* send a reset and the the paper definition */
53
    fprintf(prn_stream, "\033E\033&u300D\033&l%dA",
54
	    gdev_pcl_paper_size((gx_device *) pdev));
55
    /* turn off source and pattern transparency */
56
    fprintf(prn_stream, "\033*v1N\033*v1O");
57
    /* set color render mode and the requested resolution */
58
    fprintf(prn_stream, "\033*t4J\033*t%dR", (int)(pdev->HWResolution[0]));
59
    /* set up the color model - NB currently hardwired to direct by
60
       pixel which requires 8 bits per component.  See PCL color
61
       technical reference manual for other possible encodings. */
62
    fprintf(prn_stream, "\033*v6W%c%c%c%c%c%c", 0, 3, 0, 8, 8, 8);
63
    /* set up raster width and height, compression mode 3 */
64
    fprintf(prn_stream, "\033&l0e-180u36Z\033*p0x0Y\033*r1A\033*b3M");
65
    /* initialize the seed row */
66
    memset(prow, 0, worst_case_comp_size);
67
    /* process each scanline */
68
    for (i = 0; i < pdev->height; i++) {
69
	int compressed_size;
70
 
71
	code = gdev_prn_copy_scan_lines(pdev, i, (byte *) data, raster);
72
	if (code < 0)
73
	    break;
74
	compressed_size = gdev_pcl_mode3compress(raster, data, prow, cdata);
75
	fprintf(prn_stream, "\033*b%dW", compressed_size);
76
	fwrite(cdata, sizeof(byte), compressed_size, prn_stream);
77
    }
78
    /* PCL will take care of blank lines at the end */
79
    fputs("\033*rC\f", prn_stream);
80
out:
81
    gs_free_object(mem, prow, "cljc_print_page(prow)");
82
    gs_free_object(mem, cdata, "cljc_print_page(cdata)");
83
    gs_free_object(mem, data, "cljc_print_page(data)");
84
    return code;
85
}
86
 
87
/* CLJ device methods */
88
private gx_device_procs cljc_procs =
89
prn_color_procs(gdev_prn_open, gdev_prn_output_page, gdev_prn_close,
90
		gx_default_rgb_map_rgb_color, gx_default_rgb_map_color_rgb);
91
 
92
/* the CLJ device */
93
const gx_device_printer gs_cljet5c_device =
94
{
95
    prn_device_body(gx_device_printer, cljc_procs, "cljet5c",
96
		    85, 110, X_DPI, Y_DPI,
97
		    0.167, 0.167,
98
		    0.167, 0.167,
99
		    3, 24, 255, 255, 256, 256,
100
		    cljc_print_page)
101
};