1 /* Copyright (C) 2001-2006 Artifex Software, Inc.
2    All Rights Reserved.
3 
4    This software is provided AS-IS with no warranty, either express or
5    implied.
6 
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.
12 */
13 
14 /* $Id: gxctable.h 8022 2007-06-05 22:23:38Z giles $ */
15 /* Interface to color table lookup and interpolation */
16 
17 #ifndef gxctable_INCLUDED
18 #  define gxctable_INCLUDED
19 
20 #include "gxfixed.h"
21 #include "gxfrac.h"
22 
23 /*
24  * Define a 3- or 4-D color lookup table.
25  * n is the number of dimensions (input indices), 3 or 4.
26  * dims[0..n-1] are the table dimensions.
27  * m is the number of output values, typically 3 (RGB) or 4 (CMYK).
28  * For n = 3:
29  *   table[i], 0 <= i < dims[0], point to strings of length
30  *     dims[1] x dims[2] x m.
31  * For n = 4:
32  *   table[i], 0 <= i < dims[0] x dims[1], points to strings of length
33  *     dims[2] x dims[3] x m.
34  * It isn't really necessary to store the size of each string, since
35  * they're all the same size, but it makes things a lot easier for the GC.
36  */
37 typedef struct gx_color_lookup_table_s {
38     int n;
39     int dims[4];		/* [ndims] */
40     int m;
41     const gs_const_string *table;
42 } gx_color_lookup_table;
43 
44 /*
45  * Interpolate in a 3- or 4-D color lookup table.
46  * pi[0..n-1] are the table indices, guaranteed to be in the ranges
47  * [0..dims[n]-1] respectively.
48  * Return interpolated values in pv[0..m-1].
49  */
50 
51 /* Return the nearest value without interpolation. */
52 void gx_color_interpolate_nearest(const fixed * pi,
53 			    const gx_color_lookup_table * pclt, frac * pv);
54 
55 /* Use trilinear interpolation. */
56 void gx_color_interpolate_linear(const fixed * pi,
57 			    const gx_color_lookup_table * pclt, frac * pv);
58 
59 #endif /* gxctable_INCLUDED */
60