Debian Codegraph @

src/main/color-conversion.h

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