1
/* Copyright (C) 2001-2006 Artifex Software, Inc.
4
This software is provided AS-IS with no warranty, either express or
7
This software is distributed under license and may not be copied, modified
8
or distributed except as expressly authorized under the terms of that
9
license. Refer to licensing information at http://www.artifex.com/
10
or contact Artifex Software, Inc., 7 Mt. Lassen Drive - Suite A-134,
11
San Rafael, CA 94903, U.S.A., +1(415)492-9861, for further information.
14
/* $Id: gxht.h 8022 2007-06-05 22:23:38Z giles $ */
15
/* Rest of (client) halftone definitions */
18
# define gxht_INCLUDED
27
* Halftone types. Note that for this implementation there are only
28
* spot functions, thresholds, and multi-component halftones; the peculiar
29
* colored halftones supported by PostScript (HalftoneType's 2 and 4) are
32
* NB1: While this code supports relocation of the client data, it will not
33
* free that data when the halftone is released. The client must handle
36
* NB2: The garbage collection code will deal with the user provided data as
37
* a structure pointer allocated on the heap. The client must make
38
* certain this is the case.
40
* There is, somewhat unfortunately, no identifier applied to these
41
* halftones. This reflects the origin of this graphics library as a set
42
* of routines for use by a PostScript interpreter.
44
* In PostScript, halftone objects do not exist in an identified form outside
45
* of the graphic state. Though Level 2 and PostScript 3 support halftone
46
* dictionaries, these are neither read-only structures nor tagged
47
* by a unique identifier. Hence, they are not suitable for use as cache keys.
48
* Caching of halftones for PostScript is confined to the graphic state,
49
* and this holds true for the graphic library as well.
51
* Note also that implementing a generalized halftone cache is not trivial,
52
* as the device-specific representation of spot halftones depends on the
53
* default transformation for the device, and more generally the device
54
* specific representation of halftones may depend on the sense of the device
55
* (additive or subtract). Hence, a halftone cache would need to be keyed
56
* by device. (This is not an issue when caching halftones in the graphic
57
* state as the device is also a component of the graphic state).
61
* Note that the transfer_closure members will replace transfer sometime
62
* in the future. For the moment, transfer_closure is only used if
66
/* Type 1 halftone. This is just a Level 1 halftone with */
67
/* a few extra members. */
68
typedef struct gs_spot_halftone_s {
69
gs_screen_halftone screen;
70
bool accurate_screens;
71
gs_mapping_proc transfer; /* OBSOLETE */
72
gs_mapping_closure_t transfer_closure;
75
#define st_spot_halftone_max_ptrs st_screen_halftone_max_ptrs + 1
77
/* Define common elements for Type 3 and extended Type 3 halftones. */
78
#define GS_THRESHOLD_HALFTONE_COMMON\
81
gs_mapping_closure_t transfer_closure
82
typedef struct gs_threshold_halftone_common_s {
83
GS_THRESHOLD_HALFTONE_COMMON;
84
} gs_threshold_halftone_common;
86
/* Type 3 halftone. */
87
typedef struct gs_threshold_halftone_s {
88
GS_THRESHOLD_HALFTONE_COMMON; /* must be first */
89
gs_const_string thresholds;
90
gs_mapping_proc transfer; /* OBSOLETE */
91
} gs_threshold_halftone;
93
#define st_threshold_halftone_max_ptrs 2
95
/* Extended Type 3 halftone. */
96
typedef struct gs_threshold2_halftone_s {
97
GS_THRESHOLD_HALFTONE_COMMON; /* must be first */
100
int bytes_per_sample; /* 1 or 2 */
101
gs_const_bytestring thresholds; /* nota bene */
102
} gs_threshold2_halftone;
104
/* Client-defined halftone that generates a halftone order. */
105
typedef struct gs_client_order_halftone_s gs_client_order_halftone;
107
#ifndef gx_ht_order_DEFINED
108
# define gx_ht_order_DEFINED
109
typedef struct gx_ht_order_s gx_ht_order;
111
typedef struct gs_client_order_ht_procs_s {
114
* Allocate and fill in the order. gx_ht_alloc_client_order
115
* (see gzht.h) does everything but fill in the actual data.
118
int (*create_order) (gx_ht_order * porder,
120
const gs_client_order_halftone * phcop,
123
} gs_client_order_ht_procs_t;
124
struct gs_client_order_halftone_s {
128
const gs_client_order_ht_procs_t *procs;
129
const void *client_data;
130
gs_mapping_closure_t transfer_closure;
133
#define st_client_order_halftone_max_ptrs 2
135
/* Define the elements of a Type 5 halftone. */
136
typedef struct gs_halftone_component_s {
139
gs_halftone_type type;
141
gs_spot_halftone spot; /* Type 1 */
142
gs_threshold_halftone threshold; /* Type 3 */
143
gs_threshold2_halftone threshold2; /* Extended Type 3 */
144
gs_client_order_halftone client_order; /* client order */
146
} gs_halftone_component;
148
extern_st(st_halftone_component);
149
#define public_st_halftone_component() /* in gsht1.c */\
150
gs_public_st_composite(st_halftone_component, gs_halftone_component,\
151
"gs_halftone_component", halftone_component_enum_ptrs,\
152
halftone_component_reloc_ptrs)
153
extern_st(st_ht_component_element);
154
#define public_st_ht_component_element() /* in gsht1.c */\
155
gs_public_st_element(st_ht_component_element, gs_halftone_component,\
156
"gs_halftone_component[]", ht_comp_elt_enum_ptrs, ht_comp_elt_reloc_ptrs,\
157
st_halftone_component)
158
#define st_halftone_component_max_ptrs\
159
max(max(st_spot_halftone_max_ptrs, st_threshold_halftone_max_ptrs),\
160
st_client_order_halftone_max_ptrs)
162
/* Define the Type 5 halftone itself. */
163
typedef struct gs_multiple_halftone_s {
164
gs_halftone_component *components;
166
int (*get_colorname_string)(const gs_memory_t *mem, gs_separation_name colorname_index,
167
unsigned char **ppstr, unsigned int *pname_size);
168
} gs_multiple_halftone;
170
#define st_multiple_halftone_max_ptrs 1
173
* The halftone stored in the graphics state is the union of
174
* setscreen, setcolorscreen, Type 1, Type 3, and Type 5.
176
* NOTE: it is assumed that all subsidiary structures of halftones (the
177
* threshold array(s) for Type 3 halftones or halftone components, and the
178
* components array for Type 5 halftones) are allocated with the same
179
* allocator as the halftone structure itself.
181
struct gs_halftone_s {
182
gs_halftone_type type;
185
gs_screen_halftone screen; /* setscreen */
186
gs_colorscreen_halftone colorscreen; /* setcolorscreen */
187
gs_spot_halftone spot; /* Type 1 */
188
gs_threshold_halftone threshold; /* Type 3 */
189
gs_threshold2_halftone threshold2; /* Extended Type 3 */
190
gs_client_order_halftone client_order; /* client order */
191
gs_multiple_halftone multiple; /* Type 5 */
195
extern_st(st_halftone);
196
#define public_st_halftone() /* in gsht.c */\
197
gs_public_st_composite(st_halftone, gs_halftone, "gs_halftone",\
198
halftone_enum_ptrs, halftone_reloc_ptrs)
199
#define st_halftone_max_ptrs\
200
max(max(st_screen_halftone_max_ptrs, st_colorscreen_halftone_max_ptrs),\
201
max(max(st_spot_halftone_max_ptrs, st_threshold_halftone_max_ptrs),\
202
max(st_client_order_halftone_max_ptrs,\
203
st_multiple_halftone_max_ptrs)))
205
/* Procedural interface for AccurateScreens */
208
* Set/get the default AccurateScreens value (for set[color]screen).
209
* Note that this value is stored in a static variable.
211
void gs_setaccuratescreens(bool);
212
bool gs_currentaccuratescreens(void);
215
* Set/get the value for UseWTS. Also a static, but it's going away.
217
void gs_setusewts(bool);
218
bool gs_currentusewts(void);
220
/* Initiate screen sampling with optional AccurateScreens. */
221
int gs_screen_init_memory(gs_screen_enum *, gs_state *,
222
gs_screen_halftone *, bool, gs_memory_t *);
224
#define gs_screen_init_accurate(penum, pgs, phsp, accurate)\
225
gs_screen_init_memory(penum, pgs, phsp, accurate, pgs->memory)
227
/* Procedural interface for MinScreenLevels (a Ghostscript extension) */
230
* Set/get the MinScreenLevels value.
232
* Note that this value is stored in a static variable.
234
void gs_setminscreenlevels(uint);
235
uint gs_currentminscreenlevels(void);
237
#endif /* gxht_INCLUDED */