1 /* Copyright (C) 1995, 1999 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: gxctable.h,v 1.5 2002/06/16 08:45:43 lpd Exp $ */ 18 /* Interface to color table lookup and interpolation */ 19 20 #ifndef gxctable_INCLUDED 21 # define gxctable_INCLUDED 22 23 #include "gxfixed.h" 24 #include "gxfrac.h" 25 26 /* 27 * Define a 3- or 4-D color lookup table. 28 * n is the number of dimensions (input indices), 3 or 4. 29 * dims[0..n-1] are the table dimensions. 30 * m is the number of output values, typically 3 (RGB) or 4 (CMYK). 31 * For n = 3: 32 * table[i], 0 <= i < dims[0], point to strings of length 33 * dims[1] x dims[2] x m. 34 * For n = 4: 35 * table[i], 0 <= i < dims[0] x dims[1], points to strings of length 36 * dims[2] x dims[3] x m. 37 * It isn't really necessary to store the size of each string, since 38 * they're all the same size, but it makes things a lot easier for the GC. 39 */ 40 typedef struct gx_color_lookup_table_s { 41 int n; 42 int dims[4]; /* [ndims] */ 43 int m; 44 const gs_const_string *table; 45 } gx_color_lookup_table; 46 47 /* 48 * Interpolate in a 3- or 4-D color lookup table. 49 * pi[0..n-1] are the table indices, guaranteed to be in the ranges 50 * [0..dims[n]-1] respectively. 51 * Return interpolated values in pv[0..m-1]. 52 */ 53 54 /* Return the nearest value without interpolation. */ 55 void gx_color_interpolate_nearest(const fixed * pi, 56 const gx_color_lookup_table * pclt, frac * pv); 57 58 /* Use trilinear interpolation. */ 59 void gx_color_interpolate_linear(const fixed * pi, 60 const gx_color_lookup_table * pclt, frac * pv); 61 62 #endif /* gxctable_INCLUDED */ 63