2 |
- |
1 |
/* Copyright (C) 1993, 1995, 1996, 1997, 1998 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: gxht.h,v 1.9 2004/08/04 19:36:12 stefan Exp $ */
|
|
|
18 |
/* Rest of (client) halftone definitions */
|
|
|
19 |
|
|
|
20 |
#ifndef gxht_INCLUDED
|
|
|
21 |
# define gxht_INCLUDED
|
|
|
22 |
|
|
|
23 |
#include "gsht1.h"
|
|
|
24 |
#include "gsrefct.h"
|
|
|
25 |
#include "gxhttype.h"
|
|
|
26 |
#include "gxtmap.h"
|
|
|
27 |
#include "gscspace.h"
|
|
|
28 |
|
|
|
29 |
/*
|
|
|
30 |
* Halftone types. Note that for this implementation there are only
|
|
|
31 |
* spot functions, thresholds, and multi-component halftones; the peculiar
|
|
|
32 |
* colored halftones supported by PostScript (HalftoneType's 2 and 4) are
|
|
|
33 |
* not supported.
|
|
|
34 |
*
|
|
|
35 |
* NB1: While this code supports relocation of the client data, it will not
|
|
|
36 |
* free that data when the halftone is released. The client must handle
|
|
|
37 |
* that task directly.
|
|
|
38 |
*
|
|
|
39 |
* NB2: The garbage collection code will deal with the user provided data as
|
|
|
40 |
* a structure pointer allocated on the heap. The client must make
|
|
|
41 |
* certain this is the case.
|
|
|
42 |
*
|
|
|
43 |
* There is, somewhat unfortunately, no identifier applied to these
|
|
|
44 |
* halftones. This reflects the origin of this graphics library as a set
|
|
|
45 |
* of routines for use by a PostScript interpreter.
|
|
|
46 |
*
|
|
|
47 |
* In PostScript, halftone objects do not exist in an identified form outside
|
|
|
48 |
* of the graphic state. Though Level 2 and PostScript 3 support halftone
|
|
|
49 |
* dictionaries, these are neither read-only structures nor tagged
|
|
|
50 |
* by a unique identifier. Hence, they are not suitable for use as cache keys.
|
|
|
51 |
* Caching of halftones for PostScript is confined to the graphic state,
|
|
|
52 |
* and this holds true for the graphic library as well.
|
|
|
53 |
*
|
|
|
54 |
* Note also that implementing a generalized halftone cache is not trivial,
|
|
|
55 |
* as the device-specific representation of spot halftones depends on the
|
|
|
56 |
* default transformation for the device, and more generally the device
|
|
|
57 |
* specific representation of halftones may depend on the sense of the device
|
|
|
58 |
* (additive or subtract). Hence, a halftone cache would need to be keyed
|
|
|
59 |
* by device. (This is not an issue when caching halftones in the graphic
|
|
|
60 |
* state as the device is also a component of the graphic state).
|
|
|
61 |
*/
|
|
|
62 |
|
|
|
63 |
/*
|
|
|
64 |
* Note that the transfer_closure members will replace transfer sometime
|
|
|
65 |
* in the future. For the moment, transfer_closure is only used if
|
|
|
66 |
* transfer = 0.
|
|
|
67 |
*/
|
|
|
68 |
|
|
|
69 |
/* Type 1 halftone. This is just a Level 1 halftone with */
|
|
|
70 |
/* a few extra members. */
|
|
|
71 |
typedef struct gs_spot_halftone_s {
|
|
|
72 |
gs_screen_halftone screen;
|
|
|
73 |
bool accurate_screens;
|
|
|
74 |
gs_mapping_proc transfer; /* OBSOLETE */
|
|
|
75 |
gs_mapping_closure_t transfer_closure;
|
|
|
76 |
} gs_spot_halftone;
|
|
|
77 |
|
|
|
78 |
#define st_spot_halftone_max_ptrs st_screen_halftone_max_ptrs + 1
|
|
|
79 |
|
|
|
80 |
/* Define common elements for Type 3 and extended Type 3 halftones. */
|
|
|
81 |
#define GS_THRESHOLD_HALFTONE_COMMON\
|
|
|
82 |
int width;\
|
|
|
83 |
int height;\
|
|
|
84 |
gs_mapping_closure_t transfer_closure
|
|
|
85 |
typedef struct gs_threshold_halftone_common_s {
|
|
|
86 |
GS_THRESHOLD_HALFTONE_COMMON;
|
|
|
87 |
} gs_threshold_halftone_common;
|
|
|
88 |
|
|
|
89 |
/* Type 3 halftone. */
|
|
|
90 |
typedef struct gs_threshold_halftone_s {
|
|
|
91 |
GS_THRESHOLD_HALFTONE_COMMON; /* must be first */
|
|
|
92 |
gs_const_string thresholds;
|
|
|
93 |
gs_mapping_proc transfer; /* OBSOLETE */
|
|
|
94 |
} gs_threshold_halftone;
|
|
|
95 |
|
|
|
96 |
#define st_threshold_halftone_max_ptrs 2
|
|
|
97 |
|
|
|
98 |
/* Extended Type 3 halftone. */
|
|
|
99 |
typedef struct gs_threshold2_halftone_s {
|
|
|
100 |
GS_THRESHOLD_HALFTONE_COMMON; /* must be first */
|
|
|
101 |
int width2;
|
|
|
102 |
int height2;
|
|
|
103 |
int bytes_per_sample; /* 1 or 2 */
|
|
|
104 |
gs_const_bytestring thresholds; /* nota bene */
|
|
|
105 |
} gs_threshold2_halftone;
|
|
|
106 |
|
|
|
107 |
/* Client-defined halftone that generates a halftone order. */
|
|
|
108 |
typedef struct gs_client_order_halftone_s gs_client_order_halftone;
|
|
|
109 |
|
|
|
110 |
#ifndef gx_ht_order_DEFINED
|
|
|
111 |
# define gx_ht_order_DEFINED
|
|
|
112 |
typedef struct gx_ht_order_s gx_ht_order;
|
|
|
113 |
#endif
|
|
|
114 |
typedef struct gs_client_order_ht_procs_s {
|
|
|
115 |
|
|
|
116 |
/*
|
|
|
117 |
* Allocate and fill in the order. gx_ht_alloc_client_order
|
|
|
118 |
* (see gzht.h) does everything but fill in the actual data.
|
|
|
119 |
*/
|
|
|
120 |
|
|
|
121 |
int (*create_order) (gx_ht_order * porder,
|
|
|
122 |
gs_state * pgs,
|
|
|
123 |
const gs_client_order_halftone * phcop,
|
|
|
124 |
gs_memory_t * mem);
|
|
|
125 |
|
|
|
126 |
} gs_client_order_ht_procs_t;
|
|
|
127 |
struct gs_client_order_halftone_s {
|
|
|
128 |
int width;
|
|
|
129 |
int height;
|
|
|
130 |
int num_levels;
|
|
|
131 |
const gs_client_order_ht_procs_t *procs;
|
|
|
132 |
const void *client_data;
|
|
|
133 |
gs_mapping_closure_t transfer_closure;
|
|
|
134 |
};
|
|
|
135 |
|
|
|
136 |
#define st_client_order_halftone_max_ptrs 2
|
|
|
137 |
|
|
|
138 |
/* Define the elements of a Type 5 halftone. */
|
|
|
139 |
typedef struct gs_halftone_component_s {
|
|
|
140 |
int comp_number;
|
|
|
141 |
int cname;
|
|
|
142 |
gs_halftone_type type;
|
|
|
143 |
union {
|
|
|
144 |
gs_spot_halftone spot; /* Type 1 */
|
|
|
145 |
gs_threshold_halftone threshold; /* Type 3 */
|
|
|
146 |
gs_threshold2_halftone threshold2; /* Extended Type 3 */
|
|
|
147 |
gs_client_order_halftone client_order; /* client order */
|
|
|
148 |
} params;
|
|
|
149 |
} gs_halftone_component;
|
|
|
150 |
|
|
|
151 |
extern_st(st_halftone_component);
|
|
|
152 |
#define public_st_halftone_component() /* in gsht1.c */\
|
|
|
153 |
gs_public_st_composite(st_halftone_component, gs_halftone_component,\
|
|
|
154 |
"gs_halftone_component", halftone_component_enum_ptrs,\
|
|
|
155 |
halftone_component_reloc_ptrs)
|
|
|
156 |
extern_st(st_ht_component_element);
|
|
|
157 |
#define public_st_ht_component_element() /* in gsht1.c */\
|
|
|
158 |
gs_public_st_element(st_ht_component_element, gs_halftone_component,\
|
|
|
159 |
"gs_halftone_component[]", ht_comp_elt_enum_ptrs, ht_comp_elt_reloc_ptrs,\
|
|
|
160 |
st_halftone_component)
|
|
|
161 |
#define st_halftone_component_max_ptrs\
|
|
|
162 |
max(max(st_spot_halftone_max_ptrs, st_threshold_halftone_max_ptrs),\
|
|
|
163 |
st_client_order_halftone_max_ptrs)
|
|
|
164 |
|
|
|
165 |
/* Define the Type 5 halftone itself. */
|
|
|
166 |
typedef struct gs_multiple_halftone_s {
|
|
|
167 |
gs_halftone_component *components;
|
|
|
168 |
uint num_comp;
|
|
|
169 |
int (*get_colorname_string)(const gs_memory_t *mem, gs_separation_name colorname_index,
|
|
|
170 |
unsigned char **ppstr, unsigned int *pname_size);
|
|
|
171 |
} gs_multiple_halftone;
|
|
|
172 |
|
|
|
173 |
#define st_multiple_halftone_max_ptrs 1
|
|
|
174 |
|
|
|
175 |
/*
|
|
|
176 |
* The halftone stored in the graphics state is the union of
|
|
|
177 |
* setscreen, setcolorscreen, Type 1, Type 3, and Type 5.
|
|
|
178 |
*
|
|
|
179 |
* NOTE: it is assumed that all subsidiary structures of halftones (the
|
|
|
180 |
* threshold array(s) for Type 3 halftones or halftone components, and the
|
|
|
181 |
* components array for Type 5 halftones) are allocated with the same
|
|
|
182 |
* allocator as the halftone structure itself.
|
|
|
183 |
*/
|
|
|
184 |
struct gs_halftone_s {
|
|
|
185 |
gs_halftone_type type;
|
|
|
186 |
rc_header rc;
|
|
|
187 |
union {
|
|
|
188 |
gs_screen_halftone screen; /* setscreen */
|
|
|
189 |
gs_colorscreen_halftone colorscreen; /* setcolorscreen */
|
|
|
190 |
gs_spot_halftone spot; /* Type 1 */
|
|
|
191 |
gs_threshold_halftone threshold; /* Type 3 */
|
|
|
192 |
gs_threshold2_halftone threshold2; /* Extended Type 3 */
|
|
|
193 |
gs_client_order_halftone client_order; /* client order */
|
|
|
194 |
gs_multiple_halftone multiple; /* Type 5 */
|
|
|
195 |
} params;
|
|
|
196 |
};
|
|
|
197 |
|
|
|
198 |
extern_st(st_halftone);
|
|
|
199 |
#define public_st_halftone() /* in gsht.c */\
|
|
|
200 |
gs_public_st_composite(st_halftone, gs_halftone, "gs_halftone",\
|
|
|
201 |
halftone_enum_ptrs, halftone_reloc_ptrs)
|
|
|
202 |
#define st_halftone_max_ptrs\
|
|
|
203 |
max(max(st_screen_halftone_max_ptrs, st_colorscreen_halftone_max_ptrs),\
|
|
|
204 |
max(max(st_spot_halftone_max_ptrs, st_threshold_halftone_max_ptrs),\
|
|
|
205 |
max(st_client_order_halftone_max_ptrs,\
|
|
|
206 |
st_multiple_halftone_max_ptrs)))
|
|
|
207 |
|
|
|
208 |
/* Procedural interface for AccurateScreens */
|
|
|
209 |
|
|
|
210 |
/*
|
|
|
211 |
* Set/get the default AccurateScreens value (for set[color]screen).
|
|
|
212 |
* Note that this value is stored in a static variable.
|
|
|
213 |
*/
|
|
|
214 |
void gs_setaccuratescreens(bool);
|
|
|
215 |
bool gs_currentaccuratescreens(void);
|
|
|
216 |
|
|
|
217 |
/*
|
|
|
218 |
* Set/get the value for UseWTS. Also a static, but it's going away.
|
|
|
219 |
*/
|
|
|
220 |
void gs_setusewts(bool);
|
|
|
221 |
bool gs_currentusewts(void);
|
|
|
222 |
|
|
|
223 |
/* Initiate screen sampling with optional AccurateScreens. */
|
|
|
224 |
int gs_screen_init_memory(gs_screen_enum *, gs_state *,
|
|
|
225 |
gs_screen_halftone *, bool, gs_memory_t *);
|
|
|
226 |
|
|
|
227 |
#define gs_screen_init_accurate(penum, pgs, phsp, accurate)\
|
|
|
228 |
gs_screen_init_memory(penum, pgs, phsp, accurate, pgs->memory)
|
|
|
229 |
|
|
|
230 |
/* Procedural interface for MinScreenLevels (a Ghostscript extension) */
|
|
|
231 |
|
|
|
232 |
/*
|
|
|
233 |
* Set/get the MinScreenLevels value.
|
|
|
234 |
*
|
|
|
235 |
* Note that this value is stored in a static variable.
|
|
|
236 |
*/
|
|
|
237 |
void gs_setminscreenlevels(uint);
|
|
|
238 |
uint gs_currentminscreenlevels(void);
|
|
|
239 |
|
|
|
240 |
#endif /* gxht_INCLUDED */
|