386BSD 0.1 development
[unix-history] / usr / othersrc / public / ghostscript-2.4.1 / gxdevice.h
CommitLineData
6fb4bba9
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/* gxdevice.h */
21/* Device description structure for Ghostscript library */
22#include "gsmatrix.h"
23#include "gxbitmap.h"
24
25/* See drivers.doc for documentation of the driver interface. */
26
27/* Define the type for device color indices. */
28typedef unsigned long gx_color_index;
29/* Define the 'transparent' color index. */
30#define gx_no_color_value (-1) /* no cast -> can be used in #if */
31#define gx_no_color_index ((gx_color_index)gx_no_color_value)
32
33/* Define the type for gray or RGB values at the driver interface. */
34typedef unsigned short gx_color_value;
35/* We might use less than the full range someday. */
36/* ...bits must lie between 8 and 16. */
37#define gx_color_value_bits (sizeof(gx_color_value) * 8)
38#define gx_max_color_value ((gx_color_value)((1L << gx_color_value_bits) - 1))
39#define gx_color_value_to_byte(cv)\
40 ((cv) >> (gx_color_value_bits - 8))
41#define gx_color_value_from_byte(cb)\
42 (((cb) << (gx_color_value_bits - 8)) + ((cb) >> (16 - gx_color_value_bits)))
43
44/* Define the structure for device color capabilities. */
45typedef struct gx_device_color_info_s {
46 int num_components; /* 1 = gray only, 3 = RGB, */
47 /* 4 = CMYK (not supported) */
48 int depth; /* # of bits per pixel */
49 gx_color_value max_gray; /* # of distinct gray levels -1 */
50 gx_color_value max_rgb; /* # of distinct color levels -1 */
51 /* (only relevant if num_comp. > 1) */
52 gx_color_value dither_gray; /* size of gray ramp for dithering */
53 gx_color_value dither_rgb; /* size of color cube ditto */
54 /* (only relevant if num_comp. > 1) */
55} gx_device_color_info;
56#define dci_black_and_white { 1, 1, 1, 0, 2, 0 }
57#define dci_color(depth,maxv,dither) { 3, depth, maxv, maxv, dither, dither }
58#define gx_device_has_color(dev) ((dev)->color_info.num_components > 1)
59
60/* Structure for device procedures */
61typedef struct gx_device_procs_s gx_device_procs;
62
63/* Structure for generic device description */
64#define gx_device_common\
65 int params_size; /* size of this structure */\
66 gx_device_procs *procs;\
67 const char *dname; /* the device name */\
68 int width; /* width in pixels */\
69 int height; /* height in pixels */\
70 float x_pixels_per_inch; /* x density */\
71 float y_pixels_per_inch; /* y density */\
72 float l_margin, b_margin, r_margin, t_margin; /* margins around */\
73 /* imageable area, in inches */\
74 gx_device_color_info color_info; /* color information */\
75 int is_open /* true if device has been opened */
76#define no_margins 0, 0, 0, 0
77/* A generic device */
78struct gx_device_s {
79 gx_device_common;
80};
81#ifndef gx_device_DEFINED
82# define gx_device_DEFINED
83typedef struct gx_device_s gx_device;
84#endif
85
86/* Define an opaque type for property lists. */
87#ifndef gs_prop_item_DEFINED
88# define gs_prop_item_DEFINED
89typedef struct gs_prop_item_s gs_prop_item;
90#endif
91
92/* Definition of device procedures */
93struct gx_device_procs_s {
94
95#define dev_proc_open_device(proc)\
96 int proc(P1(gx_device *dev))
97 dev_proc_open_device((*open_device));
98
99#define dev_proc_get_initial_matrix(proc)\
100 void proc(P2(gx_device *dev, gs_matrix *pmat))
101 dev_proc_get_initial_matrix((*get_initial_matrix));
102
103#define dev_proc_sync_output(proc)\
104 int proc(P1(gx_device *dev))
105 dev_proc_sync_output((*sync_output));
106
107#define dev_proc_output_page(proc)\
108 int proc(P3(gx_device *dev, int num_copies, int flush))
109 dev_proc_output_page((*output_page));
110
111#define dev_proc_close_device(proc)\
112 int proc(P1(gx_device *dev))
113 dev_proc_close_device((*close_device));
114
115#define dev_proc_map_rgb_color(proc)\
116 gx_color_index proc(P4(gx_device *dev,\
117 gx_color_value red, gx_color_value green, gx_color_value blue))
118 dev_proc_map_rgb_color((*map_rgb_color));
119
120#define dev_proc_map_color_rgb(proc)\
121 int proc(P3(gx_device *dev,\
122 gx_color_index color, gx_color_value rgb[3]))
123 dev_proc_map_color_rgb((*map_color_rgb));
124
125#define dev_proc_fill_rectangle(proc)\
126 int proc(P6(gx_device *dev,\
127 int x, int y, int width, int height, gx_color_index color))
128 dev_proc_fill_rectangle((*fill_rectangle));
129
130#define dev_proc_tile_rectangle(proc)\
131 int proc(P10(gx_device *dev,\
132 gx_bitmap *tile, int x, int y, int width, int height,\
133 gx_color_index color0, gx_color_index color1,\
134 int phase_x, int phase_y))
135 dev_proc_tile_rectangle((*tile_rectangle));
136
137#define dev_proc_copy_mono(proc)\
138 int proc(P11(gx_device *dev,\
139 unsigned char *data, int data_x, int raster, gx_bitmap_id id,\
140 int x, int y, int width, int height,\
141 gx_color_index color0, gx_color_index color1))
142 dev_proc_copy_mono((*copy_mono));
143
144#define dev_proc_copy_color(proc)\
145 int proc(P9(gx_device *dev,\
146 unsigned char *data, int data_x, int raster, gx_bitmap_id id,\
147 int x, int y, int width, int height))
148 dev_proc_copy_color((*copy_color));
149
150#define dev_proc_draw_line(proc)\
151 int proc(P6(gx_device *dev,\
152 int x0, int y0, int x1, int y1, gx_color_index color))
153 dev_proc_draw_line((*draw_line));
154
155#define dev_proc_get_bits(proc)\
156 int proc(P5(gx_device *dev,\
157 int y, unsigned char *data, unsigned int size, int pad_to_word))
158 dev_proc_get_bits((*get_bits));
159
160#define dev_proc_get_props(proc)\
161 int proc(P2(gx_device *dev, gs_prop_item *plist))
162 dev_proc_get_props((*get_props));
163
164#define dev_proc_put_props(proc)\
165 int proc(P3(gx_device *dev, gs_prop_item *plist, int count))
166 dev_proc_put_props((*put_props));
167
168};
169
170/* Calculate the number of bytes in a scan line, */
171/* with byte or word padding. */
172extern unsigned int gx_device_bytes_per_scan_line(P2(gx_device *dev, int pad_to_word));
173
174/* Default implementations of optional procedures */
175dev_proc_open_device(gx_default_open_device);
176dev_proc_get_initial_matrix(gx_default_get_initial_matrix);
177dev_proc_sync_output(gx_default_sync_output);
178dev_proc_output_page(gx_default_output_page);
179dev_proc_close_device(gx_default_close_device);
180dev_proc_map_rgb_color(gx_default_map_rgb_color);
181dev_proc_map_color_rgb(gx_default_map_color_rgb);
182dev_proc_tile_rectangle(gx_default_tile_rectangle);
183dev_proc_copy_color(gx_default_copy_color);
184dev_proc_draw_line(gx_default_draw_line);
185dev_proc_get_bits(gx_default_get_bits);
186dev_proc_get_props(gx_default_get_props);
187dev_proc_put_props(gx_default_put_props);