1/*
2 * "$Id: color-conversion.h,v 1.12 2008/01/21 23:19:39 rlk Exp $"
3 *
4 *   Gutenprint color management module - traditional Gimp-Print algorithm.
5 *
6 *   Copyright 1997-2000 Michael Sweet (mike@easysw.com) and
7 *	Robert Krawitz (rlk@alum.mit.edu)
8 *
9 *   This program is free software; you can redistribute it and/or modify it
10 *   under the terms of the GNU General Public License as published by the Free
11 *   Software Foundation; either version 2 of the License, or (at your option)
12 *   any later version.
13 *
14 *   This program is distributed in the hope that it will be useful, but
15 *   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16 *   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
17 *   for more details.
18 *
19 *   You should have received a copy of the GNU General Public License
20 *   along with this program; if not, write to the Free Software
21 *   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */
23
24#ifndef GUTENPRINT_INTERNAL_COLOR_CONVERSION_H
25#define GUTENPRINT_INTERNAL_COLOR_CONVERSION_H
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#ifdef HAVE_CONFIG_H
32#include <config.h>
33#endif
34#include <gutenprint/gutenprint.h>
35#include <gutenprint/curve-cache.h>
36
37typedef enum
38{
39  COLOR_CORRECTION_DEFAULT,
40  COLOR_CORRECTION_UNCORRECTED,
41  COLOR_CORRECTION_BRIGHT,
42  COLOR_CORRECTION_HUE,
43  COLOR_CORRECTION_ACCURATE,
44  COLOR_CORRECTION_THRESHOLD,
45  COLOR_CORRECTION_DESATURATED,
46  COLOR_CORRECTION_DENSITY,
47  COLOR_CORRECTION_RAW,
48  COLOR_CORRECTION_PREDITHERED
49} color_correction_enum_t;
50
51typedef struct
52{
53  const char *name;
54  const char *text;
55  color_correction_enum_t correction;
56  int correct_hsl;
57} color_correction_t;
58
59typedef enum
60{
61  COLOR_WHITE,			/* RGB */
62  COLOR_BLACK,			/* CMY */
63  COLOR_UNKNOWN			/* Printer-specific uninterpreted */
64} color_model_t;
65
66#define CHANNEL_K	0
67#define CHANNEL_C	1
68#define CHANNEL_M	2
69#define CHANNEL_Y	3
70#define CHANNEL_W	4
71#define CHANNEL_R	5
72#define CHANNEL_G	6
73#define CHANNEL_B	7
74#define CHANNEL_MAX	8
75
76#define CMASK_K		(1 << CHANNEL_K)
77#define CMASK_C		(1 << CHANNEL_C)
78#define CMASK_M		(1 << CHANNEL_M)
79#define CMASK_Y		(1 << CHANNEL_Y)
80#define CMASK_W		(1 << CHANNEL_W)
81#define CMASK_R		(1 << CHANNEL_R)
82#define CMASK_G		(1 << CHANNEL_G)
83#define CMASK_B		(1 << CHANNEL_B)
84#define CMASK_RAW       (1 << CHANNEL_MAX)
85
86typedef struct
87{
88  unsigned channel_id;
89  const char *gamma_name;
90  const char *curve_name;
91  const char *rgb_gamma_name;
92  const char *rgb_curve_name;
93} channel_param_t;
94
95/* Color conversion function */
96typedef unsigned (*stp_convert_t)(const stp_vars_t *vars,
97				  const unsigned char *in,
98				  unsigned short *out);
99
100#define CMASK_NONE   (0)
101#define CMASK_RGB    (CMASK_R | CMASK_G | CMASK_B)
102#define CMASK_CMY    (CMASK_C | CMASK_M | CMASK_Y)
103#define CMASK_CMYK   (CMASK_CMY | CMASK_K)
104#define CMASK_ALL    (CMASK_CMYK | CMASK_RGB | CMASK_W)
105#define CMASK_EVERY  (CMASK_ALL | CMASK_RAW)
106
107typedef enum
108{
109  COLOR_ID_GRAY,
110  COLOR_ID_WHITE,
111  COLOR_ID_RGB,
112  COLOR_ID_CMY,
113  COLOR_ID_CMYK,
114  COLOR_ID_KCMY,
115  COLOR_ID_RAW
116} color_id_t;
117
118typedef struct
119{
120  const char *name;
121  int input;
122  int output;
123  color_id_t color_id;
124  color_model_t color_model;
125  unsigned channels;
126  int channel_count;
127  color_correction_enum_t default_correction;
128  stp_convert_t conversion_function;
129} color_description_t;
130
131typedef struct
132{
133  const char *name;
134  size_t bits;
135} channel_depth_t;
136
137typedef struct
138{
139  unsigned steps;
140  int channel_depth;
141  int image_width;
142  int in_channels;
143  int out_channels;
144  int channels_are_initialized;
145  int invert_output;
146  const color_description_t *input_color_description;
147  const color_description_t *output_color_description;
148  const color_correction_t *color_correction;
149  stp_cached_curve_t brightness_correction;
150  stp_cached_curve_t contrast_correction;
151  stp_cached_curve_t user_color_correction;
152  stp_cached_curve_t channel_curves[STP_CHANNEL_LIMIT];
153  double gamma_values[STP_CHANNEL_LIMIT];
154  double print_gamma;
155  double app_gamma;
156  double screen_gamma;
157  double contrast;
158  double brightness;
159  int linear_contrast_adjustment;
160  int printed_colorfunc;
161  int simple_gamma_correction;
162  stp_cached_curve_t hue_map;
163  stp_cached_curve_t lum_map;
164  stp_cached_curve_t sat_map;
165  unsigned short *gray_tmp;	/* Color -> Gray */
166  unsigned short *cmy_tmp;	/* CMY -> CMYK */
167  unsigned char *in_data;
168} lut_t;
169
170extern unsigned stpi_color_convert_to_gray(const stp_vars_t *v,
171					   const unsigned char *,
172					   unsigned short *);
173extern unsigned stpi_color_convert_to_color(const stp_vars_t *v,
174					    const unsigned char *,
175					    unsigned short *);
176extern unsigned stpi_color_convert_to_kcmy(const stp_vars_t *v,
177					   const unsigned char *,
178					   unsigned short *);
179extern unsigned stpi_color_convert_raw(const stp_vars_t *v,
180				       const unsigned char *,
181				       unsigned short *);
182
183#ifdef __cplusplus
184  }
185#endif
186
187#endif /* GUTENPRINT_INTERNAL_COLOR_CONVERSION_H */
188