summaryrefslogtreecommitdiff
path: root/gs/contrib/lips4/gdevlprn.h
blob: a7fb57e012fd5e2ea8b4e224284a1f1d14f97a9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
/* Copyright (C) 1999 Norihito Ohmori.

   Ghostscript laser printer driver supprting Library.

   This software is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY.  No author or distributor accepts responsibility
   to anyone for the consequences of using it or for whether it serves any
   particular purpose or works at all, unless he says so in writing.  Refer
   to the GNU General Public License for full details.

   Everyone is granted permission to copy, modify and redistribute
   this software, but only under the conditions described in the GNU
   General Public License.  A copy of this license is supposed to have been
   given to you along with this software so you can know your rights and
   responsibilities.  It should be in a file named COPYING.  Among other
   things, the copyright notice and this notice must be preserved on all
   copies.
 */

/*$Id: gdevlprn.h,v 1.4 2002/10/12 23:24:34 tillkamppeter Exp $ */
/* Library for Laser Printer Driver */

/*
   Main part of this library was taked from Hiroshi Narimatsu's
   Ghostscript driver, epag-3.08.
   <ftp://ftp.humblesoft.com/pub/epag-3.08.tar.gz>
 */

#include "gdevprn.h"

#if GS_VERSION_MAJOR >= 8
#define lprn_dev_proc_image_out(proc)\
    void proc(gx_device_printer *, FILE *, int, int, int, int)
#else
#define lprn_dev_proc_image_out(proc)\
  void proc(P6(gx_device_printer *, FILE *, int, int, int, int))
#endif

#define dev_proc_image_out(proc) lprn_dev_proc_image_out(proc)

#define gx_lprn_device_common\
	lprn_dev_proc_image_out((*image_out));\
        bool initialized;\
        bool ManualFeed;\
        bool NegativePrint;\
	bool Tumble;           /* for Duplex */\
	bool RITOff;           /* currently only escpage.dev use this */\
	int prev_x;\
	int prev_y;\
	int BlockLine;\
	byte *ImageBuf;		/* Image Buffer */\
	byte *TmpBuf;           /* Tmporary buffer */\
	byte *CompBuf;		/* Compress buffer */\
	byte *CompBuf2;		/* Compress buffer */\
	int nBw; /* block width (byte,8dot)    */\
	int nBh; /* block height(line)         */\
	struct _Bubble **bubbleTbl;\
	struct _Bubble *freeBubbleList;\
	bool ShowBubble

#define lp_device_body_rest_(print_page_copies, image_out)\
	 { 0 },		/* std_procs */\
	 { 0 },		/* skip */\
	 { NULL,\
	   print_page_copies,\
	   { gx_default_create_buf_device,\
	     gx_default_size_buf_device,\
	     gx_default_setup_buf_device,\
	     gx_default_destroy_buf_device\
	   },\
	   gdev_prn_default_get_space_params,\
	   gx_default_start_render_thread,\
	   gx_default_open_render_device,\
	   gx_default_close_render_device,\
	   gx_default_buffer_page\
	 },\
	 { PRN_MAX_BITMAP, PRN_BUFFER_SPACE,\
	     { BAND_PARAMS_INITIAL_VALUES },\
	   0/*false*/,	/* params_are_read_only */\
	   BandingAuto	/* banding_type */\
	 },\
	 { 0 },		/* fname */\
	0/*false*/,	/* OpenOutputFile */\
	0/*false*/,	/* ReopenPerPage */\
	0/*false*/, -1,	/* Duplex[_set] */\
	0/*false*/, 0, 0, 0, /* file_is_new ... buf */\
	0, 0, 0, 0, 0/*false*/, 0, 0, /* buffer_memory ... clist_dis'_mask */\
	{ 0 },	/* ... orig_procs */\
       image_out,\
       0/*false*/,    /* initialized */\
       0/*false*/,    /* ManualFeed */\
       0/*false*/,    /* NegativePrint */\
       0/*false*/,    /* Tumble */\
       0/*false*/,    /* RITOff */\
       0, 0,\
       256,\
       NULL, NULL, NULL, NULL,\
       4,\
       32,\
       NULL, NULL,\
       0			/*false */

#define lp_duplex_device_body_rest_(print_page_copies, image_out)\
	 { 0 },		/* std_procs */\
	 { 0 },		/* skip */\
	 { NULL,\
	   print_page_copies,\
	   { gx_default_create_buf_device,\
	     gx_default_size_buf_device,\
	     gx_default_setup_buf_device,\
	     gx_default_destroy_buf_device\
	   },\
	   gdev_prn_default_get_space_params,\
	   gx_default_start_render_thread,\
	   gx_default_open_render_device,\
	   gx_default_close_render_device,\
	   gx_default_buffer_page\
	 },\
	 { PRN_MAX_BITMAP, PRN_BUFFER_SPACE,\
	     { BAND_PARAMS_INITIAL_VALUES },\
	   0/*false*/,	/* params_are_read_only */\
	   BandingAuto	/* banding_type */\
	 },\
	 { 0 },		/* fname */\
	0/*false*/,	/* OpenOutputFile */\
	0/*false*/,	/* ReopenPerPage */\
	0/*false*/, 0,	/* Duplex[_set] */\
	0/*false*/, 0, 0, 0, /* file_is_new ... buf */\
	0, 0, 0, 0, 0/*false*/, 0, 0, /* buffer_memory ... clist_dis'_mask */\
	{ 0 },	/* ... orig_procs */\
       image_out,\
       0/*false*/,    /* initialized */\
       0/*false*/,    /* ManualFeed */\
       0/*false*/,    /* NegativePrint */\
       0/*false*/,    /* Tumble */\
       0/*false*/,    /* RITOff */\
       0, 0,\
       256,\
       NULL, NULL, NULL, NULL,\
       4,\
       32,\
       NULL, NULL,\
       0			/*false */

#define lprn_device(dtype, procs, dname, xdpi, ydpi, lm, bm, rm, tm, color_bits,\
		    print_page_copies, image_out)\
{        std_device_std_color_full_body(dtype, &procs, dname,\
          (int)((long)(DEFAULT_WIDTH_10THS) * (xdpi) / 10),\
          (int)((long)(DEFAULT_HEIGHT_10THS) * (ydpi) / 10),\
          xdpi, ydpi, color_bits,\
          -(lm) * (xdpi), -(tm) * (ydpi),\
          (lm) * 72.0, (bm) * 72.0,\
          (rm) * 72.0, (tm) * 72.0\
        ),\
       lp_device_body_rest_(print_page_copies, image_out)\
}

#define lprn_duplex_device(dtype, procs, dname, xdpi, ydpi, lm, bm, rm, tm, color_bits,\
		    print_page_copies, image_out)\
{        std_device_std_color_full_body(dtype, &procs, dname,\
          (int)((long)(DEFAULT_WIDTH_10THS) * (xdpi) / 10),\
          (int)((long)(DEFAULT_HEIGHT_10THS) * (ydpi) / 10),\
          xdpi, ydpi, color_bits,\
          -(lm) * (xdpi), -(tm) * (ydpi),\
          (lm) * 72.0, (bm) * 72.0,\
          (rm) * 72.0, (tm) * 72.0\
        ),\
       lp_duplex_device_body_rest_(print_page_copies, image_out)\
}

#define lprn_procs(p_open, p_output_page, p_close)\
  prn_params_procs(p_open, p_output_page, p_close, lprn_get_params, lprn_put_params)

typedef struct _Bubble
{
    struct _Bubble *next;
    gs_int_rect brect;
}
Bubble;

typedef struct gx_device_lprn_s gx_device_lprn;
struct gx_device_lprn_s
{
    gx_device_common;
    gx_prn_device_common;
    gx_lprn_device_common;
};

#define ESC 0x1b		/* \033 */
#define GS  0x1d		/* \035 */

#ifndef assert
# define assert(x)
#endif

dev_proc_get_params(lprn_get_params);
dev_proc_put_params(lprn_put_params);

int lprn_print_image(gx_device_printer * pdev, FILE * fp);