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: gxcmap.h 8422 2007-12-03 21:31:16Z henrys $ */
15
/* Color mapping procedures */
16
/* Requires gxdcolor.h. */
18
#ifndef gxcmap_INCLUDED
19
# define gxcmap_INCLUDED
24
#ifndef gx_device_DEFINED
25
# define gx_device_DEFINED
26
typedef struct gx_device_s gx_device;
28
#ifndef gx_device_color_DEFINED
29
# define gx_device_color_DEFINED
30
typedef struct gx_device_color_s gx_device_color;
33
/* Procedures for rendering colors specified by fractions. */
35
#define cmap_proc_gray(proc)\
36
void proc(frac, gx_device_color *, const gs_imager_state *,\
37
gx_device *, gs_color_select_t)
38
#define cmap_proc_rgb(proc)\
39
void proc(frac, frac, frac, gx_device_color *, const gs_imager_state *,\
40
gx_device *, gs_color_select_t)
41
#define cmap_proc_cmyk(proc)\
42
void proc(frac, frac, frac, frac, gx_device_color *,\
43
const gs_imager_state *, gx_device *, gs_color_select_t)
44
#define cmap_proc_rgb_alpha(proc)\
45
void proc(frac, frac, frac, frac, gx_device_color *,\
46
const gs_imager_state *, gx_device *, gs_color_select_t)
47
#define cmap_proc_separation(proc)\
48
void proc(frac, gx_device_color *, const gs_imager_state *,\
49
gx_device *, gs_color_select_t)
50
#define cmap_proc_devicen(proc)\
51
void proc(const frac *, gx_device_color *, const gs_imager_state *, \
52
gx_device *, gs_color_select_t)
53
#define cmap_proc_is_halftoned(proc)\
54
bool proc(const gs_imager_state *, gx_device *)
57
* List of mapping functions from the standard color spaces to the
58
* device color model. Any unused component will be mapped to 0.
60
#define cm_map_proc_gray(proc) \
61
void proc (gx_device * dev, frac gray, \
64
#define cm_map_proc_rgb(proc) \
65
void proc (gx_device * dev, \
66
const gs_imager_state *pis, \
67
frac r, frac g, frac b, \
70
#define cm_map_proc_cmyk(proc) \
71
void proc (gx_device * dev, \
72
frac c, frac m, frac y, frac k, \
76
* The following procedures come from the device. It they are
77
* specified then they are used to convert from the given
78
* color space to the device's color model. Otherwise the
79
* standard conversions are used. The procedures must be defined
80
* for a DeviceN color model
82
* Because of a bug in the Watcom C compiler, we have to split the
83
* struct from the typedef.
85
struct gx_cm_color_map_procs_s {
86
cm_map_proc_gray((*map_gray));
87
cm_map_proc_rgb((*map_rgb));
88
cm_map_proc_cmyk((*map_cmyk));
91
typedef struct gx_cm_color_map_procs_s gx_cm_color_map_procs;
94
* Make some routine global for use in the forwarding device.
96
cm_map_proc_gray(gray_cs_to_gray_cm);
97
cm_map_proc_rgb(rgb_cs_to_rgb_cm);
98
cm_map_proc_cmyk(cmyk_cs_to_cmyk_cm);
101
* Color mapping may now be device specific, so the color space
102
* to color model mapping is separated from other maps, such as
103
* applying the current transfer function or halftone.
105
* The routine pointed to by get_cmap_procs (a field in the image
106
* state; see gxistate.h) should initialize the cm_color_map_procs
107
* pointer, using the get_color_mapping_procs method of the device.
109
* Because of a bug in the Watcom C compiler, we have to split the
110
* struct from the typedef.
112
struct gx_color_map_procs_s {
113
cmap_proc_gray((*map_gray));
114
cmap_proc_rgb((*map_rgb));
115
cmap_proc_cmyk((*map_cmyk));
116
cmap_proc_rgb_alpha((*map_rgb_alpha));
117
cmap_proc_separation((*map_separation));
118
cmap_proc_devicen((*map_devicen));
119
cmap_proc_is_halftoned((*is_halftoned));
121
typedef struct gx_color_map_procs_s gx_color_map_procs;
124
* Determine the color mapping procedures for a device. Even though this
125
* does not currently use information from the imager state, it must be
126
* a virtual procedure of the state for internal reasons.
128
const gx_color_map_procs *
129
gx_get_cmap_procs(const gs_imager_state *, const gx_device *);
130
const gx_color_map_procs *
131
gx_default_get_cmap_procs(const gs_imager_state *, const gx_device *);
134
* Set the color mapping procedures in the graphics state. This is
135
* currently only needed when switching devices, but might be used more
136
* often in the future.
138
void gx_set_cmap_procs(gs_imager_state *, const gx_device *);
140
/* Remap a concrete (frac) gray, RGB or CMYK color. */
141
/* These cannot fail, and do not return a value. */
142
#define gx_remap_concrete_gray(cgray, pdc, pis, dev, select)\
143
((pis)->cmap_procs->map_gray)(cgray, pdc, pis, dev, select)
144
#define gx_remap_concrete_rgb(cr, cg, cb, pdc, pis, dev, select)\
145
((pis)->cmap_procs->map_rgb)(cr, cg, cb, pdc, pis, dev, select)
146
#define gx_remap_concrete_cmyk(cc, cm, cy, ck, pdc, pis, dev, select)\
147
((pis)->cmap_procs->map_cmyk)(cc, cm, cy, ck, pdc, pis, dev, select)
148
#define gx_remap_concrete_rgb_alpha(cr, cg, cb, ca, pdc, pis, dev, select)\
149
((pis)->cmap_procs->map_rgb_alpha)(cr, cg, cb, ca, pdc, pis, dev, select)
150
#define gx_remap_concrete_separation(pcc, pdc, pis, dev, select)\
151
((pis)->cmap_procs->map_separation)(pcc, pdc, pis, dev, select)
152
#define gx_remap_concrete_devicen(pcc, pdc, pis, dev, select)\
153
((pis)->cmap_procs->map_devicen)(pcc, pdc, pis, dev, select)
156
#include "gxcindex.h"
157
#include "gxcvalue.h"
160
* These are the default routines for converting a color space into
161
* a list of device colorants.
163
extern cm_map_proc_gray(gx_default_gray_cs_to_gray_cm);
164
extern cm_map_proc_rgb(gx_default_rgb_cs_to_gray_cm);
165
extern cm_map_proc_cmyk(gx_default_cmyk_cs_to_gray_cm);
167
extern cm_map_proc_gray(gx_default_gray_cs_to_rgb_cm);
168
extern cm_map_proc_rgb(gx_default_rgb_cs_to_rgb_cm);
169
extern cm_map_proc_cmyk(gx_default_cmyk_cs_to_rgb_cm);
171
extern cm_map_proc_gray(gx_default_gray_cs_to_cmyk_cm);
172
extern cm_map_proc_rgb(gx_default_rgb_cs_to_cmyk_cm);
173
extern cm_map_proc_cmyk(gx_default_cmyk_cs_to_cmyk_cm);
175
extern cm_map_proc_gray(gx_default_gray_cs_to_cmyk_cm);
176
extern cm_map_proc_rgb(gx_default_rgb_cs_to_cmyk_cm);
177
extern cm_map_proc_cmyk(gx_default_cmyk_cs_to_cmyk_cm);
179
extern cm_map_proc_gray(gx_error_gray_cs_to_cmyk_cm);
180
extern cm_map_proc_rgb(gx_error_rgb_cs_to_cmyk_cm);
181
extern cm_map_proc_cmyk(gx_error_cmyk_cs_to_cmyk_cm);
185
Get the mapping procedures appropriate for the currently set
188
#define dev_t_proc_get_color_mapping_procs(proc, dev_t) \
189
const gx_cm_color_map_procs * (proc)(const dev_t * dev)
191
#define dev_proc_get_color_mapping_procs(proc) \
192
dev_t_proc_get_color_mapping_procs(proc, gx_device)
195
Define the options for the component_type parameter to get_color_comp_index
196
routines. Note: This information is currently being used by the routines
197
for identifying when they are being given a separation name. Some devices
198
automaticaly add separations to the device's components if the separation
199
is not previously known and there is room in the device.
201
#define NO_COMP_NAME_TYPE 0
202
#define SEPARATION_NAME 1
205
Convert a color component name into a colorant index.
207
#define dev_t_proc_get_color_comp_index(proc, dev_t) \
208
int (proc)(dev_t * dev, const char * pname, int name_size, int component_type)
210
#define dev_proc_get_color_comp_index(proc) \
211
dev_t_proc_get_color_comp_index(proc, gx_device)
214
Map a color into the device's color model.
216
#define dev_t_proc_encode_color(proc, dev_t) \
217
gx_color_index (proc)(dev_t * dev, const gx_color_value colors[])
219
#define dev_proc_encode_color(proc) \
220
dev_t_proc_encode_color(proc, gx_device)
223
Map a color index from the device's current color model into a list of
226
#define dev_t_proc_decode_color(proc, dev_t) \
227
int (proc)(dev_t * dev, gx_color_index cindex, gx_color_value colors[])
229
#define dev_proc_decode_color(proc) \
230
dev_t_proc_decode_color(proc, gx_device)
235
* These are the default routines for translating a color component
236
* name into the device colorant index.
238
dev_proc_get_color_comp_index(gx_error_get_color_comp_index);
239
dev_proc_get_color_comp_index(gx_default_DevGray_get_color_comp_index);
240
dev_proc_get_color_comp_index(gx_default_DevRGB_get_color_comp_index);
241
dev_proc_get_color_comp_index(gx_default_DevCMYK_get_color_comp_index);
242
dev_proc_get_color_comp_index(gx_default_DevRGBK_get_color_comp_index);
245
* These are the default routines for getting the color space conversion
248
dev_proc_get_color_mapping_procs(gx_error_get_color_mapping_procs);
249
dev_proc_get_color_mapping_procs(gx_default_DevGray_get_color_mapping_procs);
250
dev_proc_get_color_mapping_procs(gx_default_DevRGB_get_color_mapping_procs);
251
dev_proc_get_color_mapping_procs(gx_default_DevCMYK_get_color_mapping_procs);
252
dev_proc_get_color_mapping_procs(gx_default_DevRGBK_get_color_mapping_procs);
255
* These are the default routines for converting a colorant value list
256
* into a gx_color_index.
258
dev_proc_encode_color(gx_error_encode_color);
259
dev_proc_encode_color(gx_default_encode_color);
262
* These are the default routines for converting a colorant value list
263
* into a gx_color_index.
265
dev_proc_encode_color(gx_default_gray_fast_encode);
266
dev_proc_encode_color(gx_default_gray_encode);
269
* This is the default encode_color routine for grayscale devices
270
* that provide a map_rgb_color procedure, but don't themselves
271
* provide encode_color.
273
dev_proc_encode_color(gx_backwards_compatible_gray_encode);
276
* These are the default routines for converting a gx_color_index into
277
* a list of device colorant values
279
dev_proc_decode_color(gx_error_decode_color);
280
dev_proc_decode_color(gx_default_decode_color);
283
* convert a float paint value to a fractional value with clamping to
286
frac gx_unit_frac(float fvalue);
288
#endif /* gxcmap_INCLUDED */