386BSD 0.1 development
[unix-history] / usr / othersrc / public / ghostscript-2.4.1 / gdevprn.h
CommitLineData
6dcd8667
WJ
1/* Copyright (C) 1989, 1992 Aladdin Enterprises. All rights reserved.
2 Distributed by Free Software Foundation, Inc.
3
4This file is part of Ghostscript.
5
6Ghostscript is distributed in the hope that it will be useful, but
7WITHOUT ANY WARRANTY. No author or distributor accepts responsibility
8to anyone for the consequences of using it or for whether it serves any
9particular purpose or works at all, unless he says so in writing. Refer
10to the Ghostscript General Public License for full details.
11
12Everyone is granted permission to copy, modify and redistribute
13Ghostscript, but only under the conditions described in the Ghostscript
14General Public License. A copy of this license is supposed to have been
15given to you along with Ghostscript so you can know your rights and
16responsibilities. It should be in a file named COPYING. Among other
17things, the copyright notice and this notice must be preserved on all
18copies. */
19
20/* gdevprn.h */
21/* Common header file for memory-buffered printers */
22
23#include "memory_.h"
24#include "string_.h"
25#include "gs.h"
26#include "gsmatrix.h" /* for gxdevice.h */
27#include "gxdevice.h"
28#include "gxdevmem.h"
29#include "gxclist.h"
30
31/* Define the parameters for the printer rendering method. */
32/* If the entire bitmap fits in PRN_MAX_BITMAP, render in RAM, */
33/* otherwise use a command list with a size of PRN_BUFFER_SPACE. */
34/* (These are "properties" that can be changed by a Ghostscript program.) */
35#if arch_ints_are_short
36/* 16-bit machines have little dinky RAMs.... */
37# define PRN_MAX_BITMAP 32000
38# define PRN_BUFFER_SPACE 25000
39#else
40/* 32-bit machines have great big hulking RAMs.... */
41# define PRN_MAX_BITMAP 10000000L
42# define PRN_BUFFER_SPACE 1000000L
43#endif
44
45/* Define the declaration macro for print_page procedures. */
46#define dev_proc_print_page(proc)\
47 int proc(P2(gx_device_printer *, FILE *))
48
49/* Structure for generic printer devices. */
50/* This must be preceded by gx_device_common. */
51/* Printer devices are actually a union of a memory device */
52/* and a clist device, plus some additional state. */
53#define gx_prn_device_common\
54 byte skip[max(sizeof(gx_device_memory), sizeof(gx_device_clist)) -\
55 sizeof(gx_device) + sizeof(double) /* padding */];\
56 /* The following is required only for devices where */\
57 /* output_page is gdev_prn_output_page; */\
58 /* it is ignored for other devices. */\
59 dev_proc_print_page((*print_page));\
60 /* ------ The following items must be set before ------ */\
61 /* ------ calling the device open routine. ------ */\
62 long max_bitmap; /* max size of non-buffered bitmap */\
63 long use_buffer_space; /* space to use for buffer */\
64 char fname[80]; /* output file name */\
65 /* ------ End of preset items ------ */\
66 FILE *file; /* output file */\
67 char ccfname[30]; /* clist file name */\
68 FILE *ccfile; /* command list scratch file */\
69 char cbfname[30]; /* clist block file name */\
70 FILE *cbfile; /* command list block scratch file */\
71 long buffer_space; /* amount of space for clist buffer, */\
72 /* 0 means not using clist */\
73 byte *buf; /* buffer for rendering */\
74 int page_count; /* # of pages printed so far */\
75 gx_device_procs *orig_procs; /* original procs */\
76 gx_device_procs mod_procs /* modified procs */
77
78/* The device descriptor */
79typedef struct gx_device_printer_s gx_device_printer;
80struct gx_device_printer_s {
81 gx_device_common;
82 gx_prn_device_common;
83};
84
85/* Macro for casting gx_device argument */
86#define prn_dev ((gx_device_printer *)dev)
87
88/* Standard device procedures for printers */
89dev_proc_open_device(gdev_prn_open);
90dev_proc_output_page(gdev_prn_output_page);
91dev_proc_close_device(gdev_prn_close);
92dev_proc_map_rgb_color(gdev_prn_map_rgb_color);
93dev_proc_map_color_rgb(gdev_prn_map_color_rgb);
94dev_proc_get_props(gdev_prn_get_props);
95dev_proc_put_props(gdev_prn_put_props);
96
97/* Macro for generating procedure table */
98#define prn_procs(proc_open, proc_output_page, proc_close)\
99 prn_color_procs(proc_open, proc_output_page, proc_close,\
100 gdev_prn_map_rgb_color, gdev_prn_map_color_rgb)
101/* See gdev_prn_open for explanation of the NULLs below. */
102#define prn_color_procs(proc_open, proc_output_page, proc_close, proc_map_rgb_color, proc_map_color_rgb) {\
103 proc_open,\
104 gx_default_get_initial_matrix,\
105 gx_default_sync_output,\
106 proc_output_page,\
107 proc_close,\
108 proc_map_rgb_color,\
109 proc_map_color_rgb,\
110 NULL, /* fill_rectangle */\
111 NULL, /* tile_rectangle */\
112 NULL, /* copy_mono */\
113 NULL, /* copy_color */\
114 NULL, /* draw_line */\
115 gx_default_get_bits,\
116 gdev_prn_get_props,\
117 gdev_prn_put_props\
118}
119
120/* The standard printer device procedures */
121/* (using gdev_prn_open/output_page/close). */
122extern gx_device_procs prn_std_procs;
123
124/* Macro for generating the device descriptor. */
125/*
126 * The computations of page width and height in pixels should really be
127 * ((int)(page_width_inches*x_dpi))
128 * but some compilers (the Ultrix 3.X pcc compiler and the HPUX compiler)
129 * can't cast a computed float to an int. That's why we specify
130 * the page width and height in inches/10 instead of inches.
131 *
132 * Note that the macro is broken up so as to be usable for devices that
133 * add further initialized state to the printer device.
134 */
135#define prn_device_body(devtype, procs, dev_name, width_10ths, height_10ths, x_dpi, y_dpi, l_margin, b_margin, r_margin, t_margin, num_comp, depth, max_gray, max_rgb, dither_gray, dither_rgb, print_page)\
136 sizeof(devtype),\
137 &procs,\
138 dev_name,\
139 (int)((long)width_10ths * x_dpi / 10), /* width */\
140 (int)((long)height_10ths * y_dpi / 10), /* height */\
141 x_dpi,\
142 y_dpi,\
143 l_margin, b_margin, r_margin, t_margin,\
144 { num_comp, depth, max_gray, max_rgb, dither_gray, dither_rgb },\
145 0, /* not initialized yet */\
146 { 0 }, /* skip */\
147 print_page,\
148 PRN_MAX_BITMAP,\
149 PRN_BUFFER_SPACE,\
150 { 0 }, /* fname */\
151 0, { 0 }, 0, { 0 }, 0, 0, 0, 0, 0, { 0 } /* ... mod_procs */
152#define prn_device(procs, dev_name, width_10ths, height_10ths, x_dpi, y_dpi, l_margin, b_margin, r_margin, t_margin, color_bits, print_page)\
153{ prn_device_body(gx_device_printer, procs, dev_name,\
154 width_10ths, height_10ths, x_dpi, y_dpi,\
155 l_margin, b_margin, r_margin, t_margin,\
156 (color_bits > 1 ? 3 : 1),\
157 ((color_bits > 1) & (color_bits < 8) ? 8 : color_bits),\
158 (color_bits >= 8 ? 255 : 1),\
159 (color_bits >= 8 ? 255 : color_bits > 1 ? 1 : 0),\
160 (color_bits >= 8 ? 5 : 2),\
161 (color_bits >= 8 ? 5 : color_bits > 1 ? 2 : 0),\
162 print_page)\
163}
164
165/* Common procedures defined in gdevprn.c */
166int gdev_prn_open_printer(P1(gx_device *));
167uint gdev_prn_bytes_per_scan_line(P1(gx_device_printer *));
168int gdev_prn_copy_scan_lines(P4(gx_device_printer *, int, byte *, uint));
169int gdev_prn_get_bits(P5(gx_device_printer *, int, byte *, uint, int));
170int gdev_prn_close_printer(P1(gx_device *));
171
172/* BACKWARD COMPATIBILITY */
173#define gdev_mem_bytes_per_scan_line(dev)\
174 gdev_prn_bytes_per_scan_line((gx_device_printer *)(dev))
175#define gdev_prn_transpose_8x8(inp,ils,outp,ols)\
176 memflip8x8(inp,ils,outp,ols)