Debian Codegraph @

test/testdither.c

raw symbols SCIP
1 /*
2 * Test/profiling program for dithering code.
3 *
4 * Copyright 1997-2000 Michael Sweet ([email protected])
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation; either version 2 of the License, or (at your option)
9 * any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20 #ifdef HAVE_CONFIG_Hcxx . . $ `<built-in>:411:9`!
21 #include <config.h>cxx . . $ `<file>/config.h`/
22 #endif
23 #include <gutenprint/gutenprint.h>cxx . . $ `<file>/include/gutenprint/gutenprint.h`/
24 #define STPI_TESTDITHERcxx . . $ `test/testdither.c:24:9`!
25
26 #include "../src/main/gutenprint-internal.h"cxx . . $ `<file>/src/main/gutenprint-internal.h`/
27 #include <stdio.h>
28 #include <sys/time.h>
29 #include <unistd.h>
30 #include <string.h>
31
32 /*
33 * Definitions for dither test...
34 */
35
36 #define MAX_IMAGE_WIDTHcxx . . $ `test/testdither.c:36:9`! 5760 /* 8in * 720dpi */
37 #define MAX_IMAGE_HEIGHTcxx . . $ `test/testdither.c:37:9`! 2880 /* 4in * 720dpi */
38 #define BUFFER_SIZEcxx . . $ `test/testdither.c:38:9`! MAX_IMAGE_WIDTHcxx . . $ `test/testdither.c:36:9`!
39
40 #define IMAGE_MIXEDcxx . . $ `test/testdither.c:40:9`! 0 /* Mix of line types */
41 #define IMAGE_WHITEcxx . . $ `test/testdither.c:41:9`! 1 /* All white image */
42 #define IMAGE_BLACKcxx . . $ `test/testdither.c:42:9`! 2 /* All black image */
43 #define IMAGE_COLORcxx . . $ `test/testdither.c:43:9`! 3 /* All color image */
44 #define IMAGE_RANDOMcxx . . $ `test/testdither.c:44:9`! 4 /* All random image */
45
46 #define DITHER_GRAYcxx . . $ `test/testdither.c:46:9`! 0 /* Dither grayscale pixels */
47 #define DITHER_COLORcxx . . $ `test/testdither.c:47:9`! 1 /* Dither color pixels */
48 #define DITHER_PHOTOcxx . . $ `test/testdither.c:48:9`! 2 /* Dither photo pixels */
49 #define DITHER_CMYKcxx . . $ `test/testdither.c:49:9`! 3 /* Dither photo pixels */
50 #define DITHER_PHOTO_CMYKcxx . . $ `test/testdither.c:50:9`! 4 /* Dither photo pixels */
51
52
53 /*
54 * Globals...
55 */
56
57 unsigned int image_typecxx . . $ image_type. = IMAGE_MIXEDcxx . . $ `test/testdither.c:40:9`!;
58 unsigned int dither_typecxx . . $ dither_type. = DITHER_COLORcxx . . $ `test/testdither.c:47:9`!;
59 const char *dither_namecxx . . $ dither_name. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!;
60 int dither_bitscxx . . $ dither_bits. = 1;
61 int write_imagecxx . . $ write_image. = 1;
62 int quietcxx . . $ quiet. = 0;
63 int dont_regenerate_inputcxx . . $ dont_regenerate_input. = 0;
64 int dimage_widthcxx . . $ dimage_width. = MAX_IMAGE_WIDTHcxx . . $ `test/testdither.c:36:9`!;
65 int dimage_heightcxx . . $ dimage_height. = MAX_IMAGE_HEIGHTcxx . . $ `test/testdither.c:37:9`!;
66 unsigned short white_linecxx . . $ white_line.[MAX_IMAGE_WIDTHcxx . . $ `test/testdither.c:36:9`! * 6],
67 black_linecxx . . $ black_line.[MAX_IMAGE_WIDTHcxx . . $ `test/testdither.c:36:9`! * 6],
68 color_linecxx . . $ color_line.[MAX_IMAGE_WIDTHcxx . . $ `test/testdither.c:36:9`! * 6],
69 random_linecxx . . $ random_line.[MAX_IMAGE_WIDTHcxx . . $ `test/testdither.c:36:9`! * 6];
70
71 static const char *dither_typescxx . . $ dither_types.[] = /* Different dithering modes */
72 {
73 "gray",
74 "color",
75 "photo",
76 "cmyk",
77 "photocmyk"
78 };
79 static const char *image_typescxx . . $ image_types.[] = /* Different image types */
80 {
81 "mixed",
82 "white",
83 "black",
84 "colorimage",
85 "random"
86 };
87
88
89 #define SHADEcxx . . $ `test/testdither.c:89:9`!(density, name) \
90 { density, sizeof(name)/sizeof(stp_dotsize_t), name }
91
92 static const stp_dotsize_tcxx . . $ stp_dotsize_t# single_dotsizecxx . . $ single_dotsize.[] =
93 {
94 { 0x1, 1.0 }
95 };
96
97 static const stp_dotsize_tcxx . . $ stp_dotsize_t# variable_dotsizescxx . . $ variable_dotsizes.[] =
98 {
99 { 0x1, 0.28 },
100 { 0x2, 0.58 },
101 { 0x3, 1.0 }
102 };
103
104 static const stp_shade_tcxx . . $ stp_shade_t# normal_1bit_shadescxx . . $ normal_1bit_shades.[] =
105 {
106 SHADEcxx . . $ `test/testdither.c:89:9`!(1.0, single_dotsize)
107 };
108
109 static const stp_shade_tcxx . . $ stp_shade_t# photo_1bit_shadescxx . . $ photo_1bit_shades.[] =
110 {
111 SHADEcxx . . $ `test/testdither.c:89:9`!(0.33, single_dotsize),
112 SHADEcxx . . $ `test/testdither.c:89:9`!(1.0, single_dotsize)
113 };
114
115 static const stp_shade_tcxx . . $ stp_shade_t# normal_2bit_shadescxx . . $ normal_2bit_shades.[] =
116 {
117 SHADEcxx . . $ `test/testdither.c:89:9`!(1.0, variable_dotsizes)
118 };
119
120 static const stp_shade_tcxx . . $ stp_shade_t# photo_2bit_shadescxx . . $ photo_2bit_shades.[] =
121 {
122 SHADEcxx . . $ `test/testdither.c:89:9`!(0.33, variable_dotsizes),
123 SHADEcxx . . $ `test/testdither.c:89:9`!(1.0, variable_dotsizes)
124 };
125
126
127 double compute_intervalcxx . . $ compute_interval(825d71882a1269ed).(struct timevalcxx . . $ timeval# *tv1, struct timevalcxx . . $ timeval# *tv2);
128 void image_initcxx . . $ image_init(49f6e7a06ebc5aa8).(void);
129 void image_get_rowcxx . . $ image_get_row(9ead97ff5579f406).(unsigned short *data, int row);
130 void write_graycxx . . $ write_gray(72d8949a74a95dc3).(FILEcxx . . $ FILE# *fp, unsigned char *black);
131 void write_colorcxx . . $ write_color(83d517cf2fc61ec3).(FILEcxx . . $ FILE# *fp, unsigned char *cyan, unsigned char *magenta,
132 unsigned char *yellow, unsigned char *black);
133 void write_photocxx . . $ write_photo(c8bbdc903c38717e).(FILEcxx . . $ FILE# *fp, unsigned char *cyan, unsigned char *lcyan,
134 unsigned char *magenta, unsigned char *lmagenta,
135 unsigned char *yellow, unsigned char *black);
136
137
138 double
139 compute_intervalcxx . . $ compute_interval(825d71882a1269ed).(struct timevalcxx . . $ timeval# *tv1, struct timevalcxx . . $ timeval# *tv2)
140 {
141 return ((double) tv2->tv_seccxx . . $ timeval#tv_sec. + (double) tv2->tv_useccxx . . $ timeval#tv_usec. / 1000000.) -
142 ((double) tv1->tv_seccxx . . $ timeval#tv_sec. + (double) tv1->tv_useccxx . . $ timeval#tv_usec. / 1000000.);
143 }
144
145 static void
146 writefunccxx . . $ writefunc(8e4e5e8cac233c6a).(void *file, const char *buf, size_t bytes)
147 {
148 FILEcxx . . $ FILE# *prn = (FILEcxx . . $ FILE# *)file;
149 fwritecxx . . $ fwrite(ab0609fa07c47d6e).(buf, 1, bytes, prn);
150 }
151
152 static int
153 image_widthcxx . . $ image_width(ba31fd85910919f2).(stp_image_tcxx . . $ stp_image_t# *image)
154 {
155 (void)image;
156 return dimage_widthcxx . . $ dimage_width.;
157 }
158
159 static stp_image_tcxx . . $ stp_image_t# theImagecxx . . $ theImage. =
160 {
161 .width = image_widthcxx . . $ image_width(ba31fd85910919f2).,
162 };
163
164 /*
165 * 'main()' - Test dithering code for performance measurement.
166 */
167
168 static int
169 run_one_testdithercxx . . $ run_one_testdither(b126dc7c1de90089).(void)
170 {
171 int print_progress = 0;
172 int i; /* Looping vars */
173 unsigned char black[BUFFER_SIZEcxx . . $ `test/testdither.c:38:9`!], /* Black bitmap data */
174 cyan[BUFFER_SIZEcxx . . $ `test/testdither.c:38:9`!], /* Cyan bitmap data */
175 magenta[BUFFER_SIZEcxx . . $ `test/testdither.c:38:9`!], /* Magenta bitmap data */
176 lcyan[BUFFER_SIZEcxx . . $ `test/testdither.c:38:9`!], /* Light cyan bitmap data */
177 lmagenta[BUFFER_SIZEcxx . . $ `test/testdither.c:38:9`!], /* Light magenta bitmap data */
178 yellow[BUFFER_SIZEcxx . . $ `test/testdither.c:38:9`!]; /* Yellow bitmap data */
179 unsigned short rgb[MAX_IMAGE_WIDTHcxx . . $ `test/testdither.c:36:9`! * 6], /* RGB buffer */
180 gray[MAX_IMAGE_WIDTHcxx . . $ `test/testdither.c:36:9`!]; /* Grayscale buffer */
181 FILEcxx . . $ FILE# *fp = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!; /* PPM/PGM output file */
182 char filename[1024]; /* Name of file */
183 stp_vars_tcxx . . $ stp_vars_t# *v; /* Dither variables */
184 stp_parameter_tcxx . . $ stp_parameter_t# desc;
185 struct timevalcxx . . $ timeval# tv1, tv2;
186
187 /*
188 * Initialise libgutenprint
189 */
190
191 stp_initcxx . . $ stp_init(b126dc7c1de90089).();
192 v = stp_vars_createcxx . . $ stp_vars_create(ca9164ca858eeb6f).();
193 stp_set_drivercxx . . $ stp_set_driver(f1526d77388867f8).(v, "escp2-ex");
194 stp_describe_parametercxx . . $ stp_describe_parameter(dfd5b9531b51a6d2).(v, "DitherAlgorithm", &desc);
195
196 /*
197 * Setup the image and color functions...
198 */
199
200 image_initcxx . . $ image_init(49f6e7a06ebc5aa8).();
201 stp_set_outfunccxx . . $ stp_set_outfunc(d4e9cdcd927ed799).(v, writefunccxx . . $ writefunc(8e4e5e8cac233c6a).);
202 stp_set_errfunccxx . . $ stp_set_errfunc(d4e9cdcd927ed799).(v, writefunccxx . . $ writefunc(8e4e5e8cac233c6a).);
203 stp_set_outdatacxx . . $ stp_set_outdata(da98ca80e19bc349).(v, stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
204 stp_set_errdatacxx . . $ stp_set_errdata(da98ca80e19bc349).(v, stderrcxx . . $ `<external>/232824719582829767/stdio.h:155:9`!);
205
206 /*
207 * Output the page...
208 */
209
210 if (dither_namecxx . . $ dither_name.)
211 stp_set_string_parametercxx . . $ stp_set_string_parameter(7405204ff890c7b8).(v, "DitherAlgorithm", dither_namecxx . . $ dither_name.);
212
213 stp_set_string_parametercxx . . $ stp_set_string_parameter(7405204ff890c7b8).(v, "ChannelBitDepth", "8");
214 switch (dither_typecxx . . $ dither_type.)
215 {
216 case DITHER_GRAYcxx . . $ `test/testdither.c:46:9`!:
217 stp_set_string_parametercxx . . $ stp_set_string_parameter(7405204ff890c7b8).(v, "PrintingMode", "BW");
218 stp_set_string_parametercxx . . $ stp_set_string_parameter(7405204ff890c7b8).(v, "InputImageType", "Grayscale");
219 break;
220 case DITHER_COLORcxx . . $ `test/testdither.c:47:9`!:
221 case DITHER_PHOTOcxx . . $ `test/testdither.c:48:9`!:
222 stp_set_string_parametercxx . . $ stp_set_string_parameter(7405204ff890c7b8).(v, "PrintingMode", "Color");
223 stp_set_string_parametercxx . . $ stp_set_string_parameter(7405204ff890c7b8).(v, "InputImageType", "RGB");
224 break;
225 case DITHER_CMYKcxx . . $ `test/testdither.c:49:9`!:
226 case DITHER_PHOTO_CMYKcxx . . $ `test/testdither.c:50:9`!:
227 stp_set_string_parametercxx . . $ stp_set_string_parameter(7405204ff890c7b8).(v, "PrintingMode", "Color");
228 stp_set_string_parametercxx . . $ stp_set_string_parameter(7405204ff890c7b8).(v, "InputImageType", "CMYK");
229 break;
230 }
231
232 stp_dither_initcxx . . $ stp_dither_init(d3ac8ed317e2c6e7).(v, &theImagecxx . . $ theImage., dimage_widthcxx . . $ dimage_width., 1, 1);
233
234 /*
235 * Now dither the "page"...
236 */
237
238 switch (dither_typecxx . . $ dither_type.)
239 {
240 case DITHER_PHOTOcxx . . $ `test/testdither.c:48:9`!:
241 stp_dither_add_channelcxx . . $ stp_dither_add_channel(4bbde36c7860b58e).(v, lcyan, STP_ECOLOR_Ccxx . . $ `include/gutenprint/dither.h:50:9`!, 1);
242 stp_dither_add_channelcxx . . $ stp_dither_add_channel(4bbde36c7860b58e).(v, lmagenta, STP_ECOLOR_Mcxx . . $ `include/gutenprint/dither.h:51:9`!, 1);
243 /* FALLTHROUGH */
244 case DITHER_COLORcxx . . $ `test/testdither.c:47:9`!:
245 stp_dither_add_channelcxx . . $ stp_dither_add_channel(4bbde36c7860b58e).(v, cyan, STP_ECOLOR_Ccxx . . $ `include/gutenprint/dither.h:50:9`!, 0);
246 stp_dither_add_channelcxx . . $ stp_dither_add_channel(4bbde36c7860b58e).(v, magenta, STP_ECOLOR_Mcxx . . $ `include/gutenprint/dither.h:51:9`!, 0);
247 stp_dither_add_channelcxx . . $ stp_dither_add_channel(4bbde36c7860b58e).(v, yellow, STP_ECOLOR_Ycxx . . $ `include/gutenprint/dither.h:52:9`!, 0);
248 break;
249 case DITHER_PHOTO_CMYKcxx . . $ `test/testdither.c:50:9`! :
250 stp_dither_add_channelcxx . . $ stp_dither_add_channel(4bbde36c7860b58e).(v, lcyan, STP_ECOLOR_Ccxx . . $ `include/gutenprint/dither.h:50:9`!, 1);
251 stp_dither_add_channelcxx . . $ stp_dither_add_channel(4bbde36c7860b58e).(v, lmagenta, STP_ECOLOR_Mcxx . . $ `include/gutenprint/dither.h:51:9`!, 1);
252 /* FALLTHROUGH */
253 case DITHER_CMYKcxx . . $ `test/testdither.c:49:9`! :
254 stp_dither_add_channelcxx . . $ stp_dither_add_channel(4bbde36c7860b58e).(v, cyan, STP_ECOLOR_Ccxx . . $ `include/gutenprint/dither.h:50:9`!, 0);
255 stp_dither_add_channelcxx . . $ stp_dither_add_channel(4bbde36c7860b58e).(v, magenta, STP_ECOLOR_Mcxx . . $ `include/gutenprint/dither.h:51:9`!, 0);
256 stp_dither_add_channelcxx . . $ stp_dither_add_channel(4bbde36c7860b58e).(v, yellow, STP_ECOLOR_Ycxx . . $ `include/gutenprint/dither.h:52:9`!, 0);
257 /* FALLTHROUGH */
258 case DITHER_GRAYcxx . . $ `test/testdither.c:46:9`!:
259 stp_dither_add_channelcxx . . $ stp_dither_add_channel(4bbde36c7860b58e).(v, black, STP_ECOLOR_Kcxx . . $ `include/gutenprint/dither.h:49:9`!, 0);
260 }
261
262 if (dither_typecxx . . $ dither_type. == DITHER_PHOTOcxx . . $ `test/testdither.c:48:9`!)
263 stp_set_float_parametercxx . . $ stp_set_float_parameter(bd523a1c1fbe60d3).(v, "GCRLower", 0.4 / dither_bitscxx . . $ dither_bits. + 0.1);
264 else
265 stp_set_float_parametercxx . . $ stp_set_float_parameter(bd523a1c1fbe60d3).(v, "GCRLower", 0.25 / dither_bitscxx . . $ dither_bits.);
266
267 stp_set_float_parametercxx . . $ stp_set_float_parameter(bd523a1c1fbe60d3).(v, "GCRUpper", .5);
268
269 switch (dither_typecxx . . $ dither_type.)
270 {
271 case DITHER_GRAYcxx . . $ `test/testdither.c:46:9`! :
272 switch (dither_bitscxx . . $ dither_bits.)
273 {
274 case 1 :
275 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Kcxx . . $ `include/gutenprint/dither.h:49:9`!, 1, normal_1bit_shadescxx . . $ normal_1bit_shades., 1.0, 1.0);
276 break;
277 case 2 :
278 stp_dither_set_transitioncxx . . $ stp_dither_set_transition(8ce3003bda9b93be).(v, 0.5);
279 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Kcxx . . $ `include/gutenprint/dither.h:49:9`!, 1, normal_2bit_shadescxx . . $ normal_2bit_shades., 1.0, 1.0);
280 break;
281 }
282 break;
283 case DITHER_COLORcxx . . $ `test/testdither.c:47:9`! :
284 switch (dither_bitscxx . . $ dither_bits.)
285 {
286 case 1 :
287 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Ccxx . . $ `include/gutenprint/dither.h:50:9`!, 1, normal_1bit_shadescxx . . $ normal_1bit_shades., 1.0, 0.65);
288 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Mcxx . . $ `include/gutenprint/dither.h:51:9`!, 1, normal_1bit_shadescxx . . $ normal_1bit_shades., 1.0, 0.6);
289 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Ycxx . . $ `include/gutenprint/dither.h:52:9`!, 1, normal_1bit_shadescxx . . $ normal_1bit_shades., 1.0, 0.08);
290 break;
291 case 2 :
292 stp_dither_set_transitioncxx . . $ stp_dither_set_transition(8ce3003bda9b93be).(v, 0.5);
293 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Ccxx . . $ `include/gutenprint/dither.h:50:9`!, 1, normal_2bit_shadescxx . . $ normal_2bit_shades., 1.0, 0.65);
294 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Mcxx . . $ `include/gutenprint/dither.h:51:9`!, 1, normal_2bit_shadescxx . . $ normal_2bit_shades., 1.0, 0.6);
295 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Ycxx . . $ `include/gutenprint/dither.h:52:9`!, 1, normal_2bit_shadescxx . . $ normal_2bit_shades., 1.0, 0.08);
296 break;
297 }
298 break;
299 case DITHER_CMYKcxx . . $ `test/testdither.c:49:9`! :
300 switch (dither_bitscxx . . $ dither_bits.)
301 {
302 case 1 :
303 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Ccxx . . $ `include/gutenprint/dither.h:50:9`!, 1, normal_1bit_shadescxx . . $ normal_1bit_shades., 1.0, 0.65);
304 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Mcxx . . $ `include/gutenprint/dither.h:51:9`!, 1, normal_1bit_shadescxx . . $ normal_1bit_shades., 1.0, 0.6);
305 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Ycxx . . $ `include/gutenprint/dither.h:52:9`!, 1, normal_1bit_shadescxx . . $ normal_1bit_shades., 1.0, 0.08);
306 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Kcxx . . $ `include/gutenprint/dither.h:49:9`!, 1, normal_1bit_shadescxx . . $ normal_1bit_shades., 1.0, 1.0);
307 break;
308 case 2 :
309 stp_dither_set_transitioncxx . . $ stp_dither_set_transition(8ce3003bda9b93be).(v, 0.5);
310 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Ccxx . . $ `include/gutenprint/dither.h:50:9`!, 1, normal_2bit_shadescxx . . $ normal_2bit_shades., 1.0, 0.65);
311 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Mcxx . . $ `include/gutenprint/dither.h:51:9`!, 1, normal_2bit_shadescxx . . $ normal_2bit_shades., 1.0, 0.6);
312 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Ycxx . . $ `include/gutenprint/dither.h:52:9`!, 1, normal_2bit_shadescxx . . $ normal_2bit_shades., 1.0, 0.08);
313 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Kcxx . . $ `include/gutenprint/dither.h:49:9`!, 1, normal_2bit_shadescxx . . $ normal_2bit_shades., 1.0, 1.0);
314 break;
315 }
316 break;
317 case DITHER_PHOTOcxx . . $ `test/testdither.c:48:9`! :
318 switch (dither_bitscxx . . $ dither_bits.)
319 {
320 case 1 :
321 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Ccxx . . $ `include/gutenprint/dither.h:50:9`!, 2, photo_1bit_shadescxx . . $ photo_1bit_shades., 1.0, 0.65);
322 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Mcxx . . $ `include/gutenprint/dither.h:51:9`!, 2, photo_1bit_shadescxx . . $ photo_1bit_shades., 1.0, 0.6);
323 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Ycxx . . $ `include/gutenprint/dither.h:52:9`!, 1, normal_1bit_shadescxx . . $ normal_1bit_shades., 1.0, 0.08);
324 break;
325 case 2 :
326 stp_dither_set_transitioncxx . . $ stp_dither_set_transition(8ce3003bda9b93be).(v, 0.7);
327 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Ccxx . . $ `include/gutenprint/dither.h:50:9`!, 2, photo_2bit_shadescxx . . $ photo_2bit_shades., 1.0, 0.65);
328 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Mcxx . . $ `include/gutenprint/dither.h:51:9`!, 2, photo_2bit_shadescxx . . $ photo_2bit_shades., 1.0, 0.6);
329 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Ycxx . . $ `include/gutenprint/dither.h:52:9`!, 1, normal_2bit_shadescxx . . $ normal_2bit_shades., 1.0, 0.08);
330 break;
331 }
332 break;
333 case DITHER_PHOTO_CMYKcxx . . $ `test/testdither.c:50:9`! :
334 switch (dither_bitscxx . . $ dither_bits.)
335 {
336 case 1 :
337 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Ccxx . . $ `include/gutenprint/dither.h:50:9`!, 2, photo_1bit_shadescxx . . $ photo_1bit_shades., 1.0, 0.65);
338 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Mcxx . . $ `include/gutenprint/dither.h:51:9`!, 2, photo_1bit_shadescxx . . $ photo_1bit_shades., 1.0, 0.6);
339 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Ycxx . . $ `include/gutenprint/dither.h:52:9`!, 1, normal_1bit_shadescxx . . $ normal_1bit_shades., 1.0, 0.08);
340 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Kcxx . . $ `include/gutenprint/dither.h:49:9`!, 1, normal_1bit_shadescxx . . $ normal_1bit_shades., 1.0, 1.0);
341 break;
342 case 2 :
343 stp_dither_set_transitioncxx . . $ stp_dither_set_transition(8ce3003bda9b93be).(v, 0.7);
344 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Ccxx . . $ `include/gutenprint/dither.h:50:9`!, 2, photo_2bit_shadescxx . . $ photo_2bit_shades., 1.0, 0.65);
345 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Mcxx . . $ `include/gutenprint/dither.h:51:9`!, 2, photo_2bit_shadescxx . . $ photo_2bit_shades., 1.0, 0.6);
346 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Ycxx . . $ `include/gutenprint/dither.h:52:9`!, 1, normal_2bit_shadescxx . . $ normal_2bit_shades., 1.0, 0.08);
347 stp_dither_set_inks_fullcxx . . $ stp_dither_set_inks_full(c3fa7fa481f2d18c).(v, STP_ECOLOR_Kcxx . . $ `include/gutenprint/dither.h:49:9`!, 1, normal_2bit_shadescxx . . $ normal_2bit_shades., 1.0, 1.0);
348 break;
349 }
350 break;
351 }
352
353 stp_dither_set_ink_spreadcxx . . $ stp_dither_set_ink_spread(c8b26ae77f1a10bd).(v, 12 + dither_bitscxx . . $ dither_bits.);
354
355 /*
356 * Open the PPM/PGM file...
357 */
358
359
360 sprintfcxx . . $ sprintf(26c8642d26409d6d).(filename, "%s-%s-%s-%dbit.%s", image_typescxx . . $ image_types.[image_typecxx . . $ image_type.],
361 dither_typescxx . . $ dither_types.[dither_typecxx . . $ dither_type.],
362 dither_namecxx . . $ dither_name. ? dither_namecxx . . $ dither_name. : desc.defltcxx . . $ $anonymous_type_c987533f3b833c82_8#deflt..strcxx . . $ $anonymous_type_c987533f3b833c82_8#$anonymous_type_10#str., dither_bitscxx . . $ dither_bits.,
363 (dither_typecxx . . $ dither_type. == DITHER_GRAYcxx . . $ `test/testdither.c:46:9`!) ? "pgm" : "ppm");
364
365 stp_parameter_description_destroycxx . . $ stp_parameter_description_destroy(6259b4d9050bb586).(&desc);
366
367 if (isattycxx . . $ isatty(7864480464b09eea).(1))
368 print_progress = 1;
369
370 if (print_progress && !quietcxx . . $ quiet.)
371 printfcxx . . $ printf(581fddd72a8db8fc).("%s ", filename);
372
373 if (write_imagecxx . . $ write_image.)
374 {
375 if ((fp = fopencxx . . $ fopen(82ec0787cd37e0a3).(filename, "wb")) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
376 {
377 if (dither_typecxx . . $ dither_type. == DITHER_GRAYcxx . . $ `test/testdither.c:46:9`!)
378 fputscxx . . $ fputs(874fa6a5e59ab9bd).("P5\n", fp);
379 else
380 fputscxx . . $ fputs(874fa6a5e59ab9bd).("P6\n", fp);
381
382 fprintfcxx . . $ fprintf(bc216f8e5b1ebeac).(fp, "%d\n%d\n255\n", dimage_widthcxx . . $ dimage_width., dimage_heightcxx . . $ dimage_height.);
383 }
384 else
385 perrorcxx . . $ perror(85c52e162fed56f9).("Create");
386 }
387
388 (void) gettimeofdaycxx . . $ gettimeofday(ee8865a94200b3d6).(&tv1, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
389
390 for (i = 0; i < dimage_heightcxx . . $ dimage_height.; i ++)
391 {
392 if (print_progress && !quietcxx . . $ quiet. && (i & 63) == 0)
393 {
394 printfcxx . . $ printf(581fddd72a8db8fc).("\rProcessing row %d...", i);
395 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
396 }
397
398 switch (dither_typecxx . . $ dither_type.)
399 {
400 case DITHER_GRAYcxx . . $ `test/testdither.c:46:9`! :
401 image_get_rowcxx . . $ image_get_row(9ead97ff5579f406).(gray, i);
402 stp_dither_internalcxx . . $ stp_dither_internal(525e4b1c00087d37).(v, i, gray, 0, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
403 if (fp)
404 write_graycxx . . $ write_gray(72d8949a74a95dc3).(fp, black);
405 break;
406 case DITHER_COLORcxx . . $ `test/testdither.c:47:9`! :
407 case DITHER_CMYKcxx . . $ `test/testdither.c:49:9`! :
408 image_get_rowcxx . . $ image_get_row(9ead97ff5579f406).(rgb, i);
409 stp_dither_internalcxx . . $ stp_dither_internal(525e4b1c00087d37).(v, i, rgb, 0, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
410 if (fp)
411 write_colorcxx . . $ write_color(83d517cf2fc61ec3).(fp, cyan, magenta, yellow, black);
412 break;
413 case DITHER_PHOTOcxx . . $ `test/testdither.c:48:9`! :
414 case DITHER_PHOTO_CMYKcxx . . $ `test/testdither.c:50:9`! :
415 image_get_rowcxx . . $ image_get_row(9ead97ff5579f406).(rgb, i);
416 stp_dither_internalcxx . . $ stp_dither_internal(525e4b1c00087d37).(v, i, rgb, 0, 0, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
417 if (fp)
418 write_photocxx . . $ write_photo(c8bbdc903c38717e).(fp, cyan, lcyan, magenta, lmagenta, yellow, black);
419 break;
420 }
421 }
422
423 (void) gettimeofdaycxx . . $ gettimeofday(ee8865a94200b3d6).(&tv2, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!);
424
425 stp_vars_destroycxx . . $ stp_vars_destroy(1a97b8462f9f913c).(v);
426
427 if (fp != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:419:9`!)
428 fclosecxx . . $ fclose(89bc1efcdac0ca22).(fp);
429
430 if (!quietcxx . . $ quiet.)
431 {
432 if (print_progress)
433 fputccxx . . $ fputc(b1cd03d6c470d1bd).('\r', stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
434 printfcxx . . $ printf(581fddd72a8db8fc).("%-30s %d pix %.3f sec %.2f pix/sec\n",
435 filename, dimage_widthcxx . . $ dimage_width. * dimage_heightcxx . . $ dimage_height., compute_intervalcxx . . $ compute_interval(825d71882a1269ed).(&tv1, &tv2),
436 (float)(dimage_widthcxx . . $ dimage_width. * dimage_heightcxx . . $ dimage_height.) / compute_intervalcxx . . $ compute_interval(825d71882a1269ed).(&tv1, &tv2));
437 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
438 }
439 return 0;
440 }
441
442 static int
443 run_testdither_from_cmdlinecxx . . $ run_testdither_from_cmdline(afcd3168fc1188a4).(int argc, char **argv)
444 {
445 int i, j;
446 int status;
447 for (i = 1; i < argc; i ++)
448 {
449 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(argv[i], "no-image") == 0)
450 {
451 write_imagecxx . . $ write_image. = 0;
452 continue;
453 }
454
455 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(argv[i], "quiet") == 0)
456 {
457 quietcxx . . $ quiet. = 1;
458 continue;
459 }
460
461 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(argv[i], "1-bit") == 0)
462 {
463 dither_bitscxx . . $ dither_bits. = 1;
464 continue;
465 }
466
467 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(argv[i], "2-bit") == 0)
468 {
469 dither_bitscxx . . $ dither_bits. = 2;
470 continue;
471 }
472
473 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(argv[i], "dont_regenerate_input") == 0)
474 {
475 dont_regenerate_inputcxx . . $ dont_regenerate_input. = 1;
476 continue;
477 }
478
479 for (j = 0; j < 5; j ++)
480 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(argv[i], dither_typescxx . . $ dither_types.[j]) == 0)
481 break;
482
483 if (j < 5)
484 {
485 dither_typecxx . . $ dither_type. = j;
486 continue;
487 }
488
489 for (j = 0; j < 5; j ++)
490 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(argv[i], image_typescxx . . $ image_types.[j]) == 0)
491 break;
492
493 if (j < 5)
494 {
495 image_typecxx . . $ image_type. = j;
496 continue;
497 }
498
499 dither_namecxx . . $ dither_name. = argv[i];
500 }
501 status = run_one_testdithercxx . . $ run_one_testdither(b126dc7c1de90089).();
502 if (status)
503 return 1;
504 else
505 return 0;
506 }
507
508 static int
509 run_standard_testditherscxx . . $ run_standard_testdithers(b126dc7c1de90089).(void)
510 {
511 stp_vars_tcxx . . $ stp_vars_t# *v = stp_vars_createcxx . . $ stp_vars_create(ca9164ca858eeb6f).();
512 stp_parameter_tcxx . . $ stp_parameter_t# desc;
513 unsigned int j;
514 int failures = 0;
515 int status;
516
517 stp_set_drivercxx . . $ stp_set_driver(f1526d77388867f8).(v, "escp2-ex");
518 stp_describe_parametercxx . . $ stp_describe_parameter(dfd5b9531b51a6d2).(v, "DitherAlgorithm", &desc);
519
520 write_imagecxx . . $ write_image. = 0;
521 quietcxx . . $ quiet. = 1;
522 dont_regenerate_inputcxx . . $ dont_regenerate_input. = 1;
523 /* For automatic test purposes, this should suffice -- rlk 20171230 */
524 dimage_widthcxx . . $ dimage_width. = dimage_widthcxx . . $ dimage_width. / 8;
525 dimage_heightcxx . . $ dimage_height. = dimage_heightcxx . . $ dimage_height. / 8;
526 for (j = 0; j < stp_string_list_countcxx . . $ stp_string_list_count(53b7214102d1daf6).(desc.boundscxx . . $ $anonymous_type_c987533f3b833c82_8#bounds..strcxx . . $ $anonymous_type_c987533f3b833c82_8#$anonymous_type_9#str.); j ++)
527 {
528 dither_namecxx . . $ dither_name. = stp_string_list_paramcxx . . $ stp_string_list_param(1d71fb1c8ad3926a).(desc.boundscxx . . $ $anonymous_type_c987533f3b833c82_8#bounds..strcxx . . $ $anonymous_type_c987533f3b833c82_8#$anonymous_type_9#str., j)->namecxx . . $ $anonymous_type_cb0224bbe5755622_0#name.;
529 if (strcmpcxx . . $ strcmp(5ae29d726ae57f88).(dither_namecxx . . $ dither_name., "None") == 0)
530 continue;
531 printfcxx . . $ printf(581fddd72a8db8fc).("%s", dither_namecxx . . $ dither_name.);
532 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
533 for (dither_bitscxx . . $ dither_bits. = 1; dither_bitscxx . . $ dither_bits. <= 2; dither_bitscxx . . $ dither_bits.++)
534 for (dither_typecxx . . $ dither_type. = 0;
535 dither_typecxx . . $ dither_type. < sizeof(dither_typescxx . . $ dither_types.) / sizeof(const char *);
536 dither_typecxx . . $ dither_type.++)
537 for (image_typecxx . . $ image_type. = 0;
538 image_typecxx . . $ image_type. < sizeof(image_typescxx . . $ image_types.) / sizeof(const char *);
539 image_typecxx . . $ image_type.++)
540 {
541 status = run_one_testdithercxx . . $ run_one_testdither(b126dc7c1de90089).();
542 if (status)
543 {
544 printfcxx . . $ printf(581fddd72a8db8fc).("%s %d %s %s\n", dither_namecxx . . $ dither_name., dither_bitscxx . . $ dither_bits.,
545 dither_typescxx . . $ dither_types.[dither_typecxx . . $ dither_type.],
546 image_typescxx . . $ image_types.[image_typecxx . . $ image_type.]);
547 failures++;
548 }
549 else
550 printfcxx . . $ printf(581fddd72a8db8fc).(".");
551 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
552 }
553 printfcxx . . $ printf(581fddd72a8db8fc).("\n");
554 fflushcxx . . $ fflush(89bc1efcdac0ca22).(stdoutcxx . . $ `<external>/232824719582829767/stdio.h:154:9`!);
555 }
556 stp_parameter_description_destroycxx . . $ stp_parameter_description_destroy(6259b4d9050bb586).(&desc);
557 stp_vars_destroycxx . . $ stp_vars_destroy(1a97b8462f9f913c).(v);
558 return (failures ? 1 : 0);
559 }
560
561 int
562 maincxx . . $ main(afcd3168fc1188a4).(int argc, char **argv)
563 {
564 stp_initcxx . . $ stp_init(b126dc7c1de90089).();
565
566 if (argc == 1)
567 return run_standard_testditherscxx . . $ run_standard_testdithers(b126dc7c1de90089).();
568 else
569 return run_testdither_from_cmdlinecxx . . $ run_testdither_from_cmdline(afcd3168fc1188a4).(argc, argv);
570 }
571
572
573 void
574 image_get_rowcxx . . $ image_get_row(9ead97ff5579f406).(unsigned short *data,
575 int row)
576 {
577 unsigned short *src;
578
579 switch (image_typecxx . . $ image_type.)
580 {
581 case IMAGE_MIXEDcxx . . $ `test/testdither.c:40:9`! :
582 switch ((row / 100) & 3)
583 {
584 case 0 :
585 src = white_linecxx . . $ white_line.;
586 break;
587 case 1 :
588 src = color_linecxx . . $ color_line.;
589 break;
590 case 2 :
591 src = black_linecxx . . $ black_line.;
592 break;
593 case 3 :
594 default:
595 src = random_linecxx . . $ random_line.;
596 break;
597 }
598 break;
599 case IMAGE_WHITEcxx . . $ `test/testdither.c:41:9`! :
600 src = white_linecxx . . $ white_line.;
601 break;
602 case IMAGE_BLACKcxx . . $ `test/testdither.c:42:9`! :
603 src = black_linecxx . . $ black_line.;
604 break;
605 case IMAGE_COLORcxx . . $ `test/testdither.c:43:9`! :
606 src = color_linecxx . . $ color_line.;
607 break;
608 case IMAGE_RANDOMcxx . . $ `test/testdither.c:44:9`! :
609 default:
610 src = random_linecxx . . $ random_line.;
611 break;
612 }
613
614 switch (dither_typecxx . . $ dither_type.)
615 {
616 case DITHER_GRAYcxx . . $ `test/testdither.c:46:9`!:
617 memcpycxx . . $ memcpy(cc817cb175f282d).(data, src, dimage_widthcxx . . $ dimage_width. * 2);
618 break;
619 case DITHER_COLORcxx . . $ `test/testdither.c:47:9`!:
620 memcpycxx . . $ memcpy(cc817cb175f282d).(data, src, dimage_widthcxx . . $ dimage_width. * 6);
621 break;
622 case DITHER_CMYKcxx . . $ `test/testdither.c:49:9`!:
623 memcpycxx . . $ memcpy(cc817cb175f282d).(data, src, dimage_widthcxx . . $ dimage_width. * 8);
624 break;
625 case DITHER_PHOTOcxx . . $ `test/testdither.c:48:9`!:
626 memcpycxx . . $ memcpy(cc817cb175f282d).(data, src, dimage_widthcxx . . $ dimage_width. * 10);
627 break;
628 case DITHER_PHOTO_CMYKcxx . . $ `test/testdither.c:50:9`!:
629 memcpycxx . . $ memcpy(cc817cb175f282d).(data, src, dimage_widthcxx . . $ dimage_width. * 12);
630 break;
631 }
632 }
633
634
635 /*
636 * Much faster than built-in rand(), and quite good enough.
637 * From rand(3), attributed to POSIX.1-2001.
638 */
639 static unsigned long nextcxx . . $ next. = 1;
640 static unsigned
641 myrandcxx . . $ myrand(db52760e79bf9054).(void)
642 {
643 nextcxx . . $ next. = nextcxx . . $ next. * 1103515245 + 12345;
644 return((unsigned)(nextcxx . . $ next./65536) % 256);
645 }
646
647 static int image_is_initializedcxx . . $ image_is_initialized. = 0;
648
649 void
650 image_initcxx . . $ image_init(49f6e7a06ebc5aa8).(void)
651 {
652 int i, j;
653 unsigned short *cptr,
654 *rptr;
655
656 if (image_is_initializedcxx . . $ image_is_initialized. && dont_regenerate_inputcxx . . $ dont_regenerate_input.)
657 return;
658 image_is_initializedcxx . . $ image_is_initialized. = 1;
659
660 /*
661 * Set the white and black line data...
662 */
663
664 memsetcxx . . $ memset(d1de1e4fb215f1c6).(white_linecxx . . $ white_line., 0, sizeof(white_linecxx . . $ white_line.));
665 memsetcxx . . $ memset(d1de1e4fb215f1c6).(black_linecxx . . $ black_line., 255, sizeof(black_linecxx . . $ black_line.));
666
667 /*
668 * Fill in the color and random data...
669 */
670
671 for (i = dimage_widthcxx . . $ dimage_width., cptr = color_linecxx . . $ color_line., rptr = random_linecxx . . $ random_line.; i > 0; i --)
672 {
673 /*
674 * Do 64 color or grayscale blocks over the line...
675 */
676
677 j = i / (dimage_widthcxx . . $ dimage_width. / 64);
678
679 switch (dither_typecxx . . $ dither_type.)
680 {
681 case DITHER_GRAYcxx . . $ `test/testdither.c:46:9`!:
682 *cptr++ = 65535 * j / 63;
683 *rptr++ = 65535 * myrandcxx . . $ myrand(db52760e79bf9054).() / 255;
684 break;
685 case DITHER_COLORcxx . . $ `test/testdither.c:47:9`!:
686 *cptr++ = 65535 * (j >> 4) / 3;
687 *cptr++ = 65535 * ((j >> 2) & 3) / 3;
688 *cptr++ = 65535 * (j & 3) / 3;
689 *rptr++ = 65535 * myrandcxx . . $ myrand(db52760e79bf9054).() / 255;
690 *rptr++ = 65535 * myrandcxx . . $ myrand(db52760e79bf9054).() / 255;
691 *rptr++ = 65535 * myrandcxx . . $ myrand(db52760e79bf9054).() / 255;
692 break;
693 case DITHER_CMYKcxx . . $ `test/testdither.c:49:9`!:
694 *cptr++ = 65535 * (j >> 4) / 3;
695 *cptr++ = 65535 * ((j >> 2) & 3) / 3;
696 *cptr++ = 65535 * (j & 3) / 3;
697 *cptr++ = 65535 * j / 63;
698 *rptr++ = 65535 * myrandcxx . . $ myrand(db52760e79bf9054).() / 255;
699 *rptr++ = 65535 * myrandcxx . . $ myrand(db52760e79bf9054).() / 255;
700 *rptr++ = 65535 * myrandcxx . . $ myrand(db52760e79bf9054).() / 255;
701 *rptr++ = 65535 * myrandcxx . . $ myrand(db52760e79bf9054).() / 255;
702 break;
703 case DITHER_PHOTOcxx . . $ `test/testdither.c:48:9`!:
704 *cptr++ = 65535 * (j >> 4) / 3;
705 *cptr++ = 65535 * ((j >> 2) & 3) / 3;
706 *cptr++ = 65535 * (j & 3) / 3;
707 *cptr++ = 65535 * j / 63;
708 *cptr++ = 65535 * (j >> 4) / 3;
709 *rptr++ = 65535 * myrandcxx . . $ myrand(db52760e79bf9054).() / 255;
710 *rptr++ = 65535 * myrandcxx . . $ myrand(db52760e79bf9054).() / 255;
711 *rptr++ = 65535 * myrandcxx . . $ myrand(db52760e79bf9054).() / 255;
712 *rptr++ = 65535 * myrandcxx . . $ myrand(db52760e79bf9054).() / 255;
713 *rptr++ = 65535 * myrandcxx . . $ myrand(db52760e79bf9054).() / 255;
714 break;
715 case DITHER_PHOTO_CMYKcxx . . $ `test/testdither.c:50:9`!:
716 *cptr++ = 65535 * (j >> 4) / 3;
717 *cptr++ = 65535 * ((j >> 2) & 3) / 3;
718 *cptr++ = 65535 * (j & 3) / 3;
719 *cptr++ = 65535 * j / 63;
720 *cptr++ = 65535 * (j >> 4) / 3;
721 *cptr++ = 65535 * ((j >> 2) & 3) / 3;
722 *rptr++ = 65535 * myrandcxx . . $ myrand(db52760e79bf9054).() / 255;
723 *rptr++ = 65535 * myrandcxx . . $ myrand(db52760e79bf9054).() / 255;
724 *rptr++ = 65535 * myrandcxx . . $ myrand(db52760e79bf9054).() / 255;
725 *rptr++ = 65535 * myrandcxx . . $ myrand(db52760e79bf9054).() / 255;
726 *rptr++ = 65535 * myrandcxx . . $ myrand(db52760e79bf9054).() / 255;
727 *rptr++ = 65535 * myrandcxx . . $ myrand(db52760e79bf9054).() / 255;
728 break;
729 }
730 }
731 }
732
733
734 void
735 write_graycxx . . $ write_gray(72d8949a74a95dc3).(FILEcxx . . $ FILE# *fp,
736 unsigned char *black)
737 {
738 int count;
739 unsigned char byte,
740 bit,
741 shift;
742
743
744 if (dither_bitscxx . . $ dither_bits. == 1)
745 {
746 for (count = dimage_widthcxx . . $ dimage_width., byte = *black++, bit = 128; count > 0; count --)
747 {
748 if (byte & bit)
749 putccxx . . $ putc(b1cd03d6c470d1bd).(0, fp);
750 else
751 putccxx . . $ putc(b1cd03d6c470d1bd).(255, fp);
752
753 if (bit > 1)
754 bit >>= 1;
755 else
756 {
757 byte = *black++;
758 bit = 128;
759 }
760 }
761 }
762 else
763 {
764 unsigned char kb[BUFFER_SIZEcxx . . $ `test/testdither.c:38:9`!];
765 unsigned char *kbuf = kb;
766 stp_foldcxx . . $ stp_fold(7127c6a555fcd89a).(black, dimage_widthcxx . . $ dimage_width. / 8, kbuf);
767 for (count = dimage_widthcxx . . $ dimage_width., byte = *kbuf++, shift = 6; count > 0; count --)
768 {
769 putccxx . . $ putc(b1cd03d6c470d1bd).(255 - 255 * ((byte >> shift) & 3) / 3, fp);
770
771 if (shift > 0)
772 shift -= 2;
773 else
774 {
775 byte = *kbuf++;
776 shift = 6;
777 }
778 }
779 }
780 }
781
782
783 void
784 write_colorcxx . . $ write_color(83d517cf2fc61ec3).(FILEcxx . . $ FILE# *fp,
785 unsigned char *cyan,
786 unsigned char *magenta,
787 unsigned char *yellow,
788 unsigned char *black)
789 {
790 int count;
791 unsigned char cbyte,
792 mbyte,
793 ybyte,
794 kbyte,
795 bit,
796 shift;
797 int r, g, b, k;
798
799
800 if (dither_bitscxx . . $ dither_bits. == 1)
801 {
802 for (count = dimage_widthcxx . . $ dimage_width., cbyte = *cyan++, mbyte = *magenta++,
803 ybyte = *yellow++, kbyte = *black++, bit = 128;
804 count > 0;
805 count --)
806 {
807 if (kbyte & bit)
808 {
809 putccxx . . $ putc(b1cd03d6c470d1bd).(0, fp);
810 putccxx . . $ putc(b1cd03d6c470d1bd).(0, fp);
811 putccxx . . $ putc(b1cd03d6c470d1bd).(0, fp);
812 }
813 else
814 {
815 if (cbyte & bit)
816 putccxx . . $ putc(b1cd03d6c470d1bd).(0, fp);
817 else
818 putccxx . . $ putc(b1cd03d6c470d1bd).(255, fp);
819
820 if (mbyte & bit)
821 putccxx . . $ putc(b1cd03d6c470d1bd).(0, fp);
822 else
823 putccxx . . $ putc(b1cd03d6c470d1bd).(255, fp);
824
825 if (ybyte & bit)
826 putccxx . . $ putc(b1cd03d6c470d1bd).(0, fp);
827 else
828 putccxx . . $ putc(b1cd03d6c470d1bd).(255, fp);
829 }
830
831 if (bit > 1)
832 bit >>= 1;
833 else
834 {
835 cbyte = *cyan++;
836 mbyte = *magenta++;
837 ybyte = *yellow++;
838 kbyte = *black++;
839 bit = 128;
840 }
841 }
842 }
843 else
844 {
845 unsigned char kb[BUFFER_SIZEcxx . . $ `test/testdither.c:38:9`!];
846 unsigned char cb[BUFFER_SIZEcxx . . $ `test/testdither.c:38:9`!];
847 unsigned char mb[BUFFER_SIZEcxx . . $ `test/testdither.c:38:9`!];
848 unsigned char yb[BUFFER_SIZEcxx . . $ `test/testdither.c:38:9`!];
849 unsigned char *kbuf = kb;
850 unsigned char *cbuf = cb;
851 unsigned char *mbuf = mb;
852 unsigned char *ybuf = yb;
853 stp_foldcxx . . $ stp_fold(7127c6a555fcd89a).(black, dimage_widthcxx . . $ dimage_width. / 8, kbuf);
854 stp_foldcxx . . $ stp_fold(7127c6a555fcd89a).(cyan, dimage_widthcxx . . $ dimage_width. / 8, cbuf);
855 stp_foldcxx . . $ stp_fold(7127c6a555fcd89a).(magenta, dimage_widthcxx . . $ dimage_width. / 8, mbuf);
856 stp_foldcxx . . $ stp_fold(7127c6a555fcd89a).(yellow, dimage_widthcxx . . $ dimage_width. / 8, ybuf);
857 for (count = dimage_widthcxx . . $ dimage_width., cbyte = *cbuf++, mbyte = *mbuf++,
858 ybyte = *ybuf++, kbyte = *kbuf++, shift = 6;
859 count > 0;
860 count --)
861 {
862 k = 255 * ((kbyte >> shift) & 3) / 3;
863 r = 255 - 255 * ((cbyte >> shift) & 3) / 3 - k;
864 g = 255 - 255 * ((mbyte >> shift) & 3) / 3 - k;
865 b = 255 - 255 * ((ybyte >> shift) & 3) / 3 - k;
866
867 if (r < 0)
868 putccxx . . $ putc(b1cd03d6c470d1bd).(0, fp);
869 else
870 putccxx . . $ putc(b1cd03d6c470d1bd).(r, fp);
871
872 if (g < 0)
873 putccxx . . $ putc(b1cd03d6c470d1bd).(0, fp);
874 else
875 putccxx . . $ putc(b1cd03d6c470d1bd).(g, fp);
876
877 if (b < 0)
878 putccxx . . $ putc(b1cd03d6c470d1bd).(0, fp);
879 else
880 putccxx . . $ putc(b1cd03d6c470d1bd).(b, fp);
881
882 if (shift > 0)
883 shift -= 2;
884 else
885 {
886 cbyte = *cbuf++;
887 mbyte = *mbuf++;
888 ybyte = *ybuf++;
889 kbyte = *kbuf++;
890 shift = 6;
891 }
892 }
893 }
894 }
895
896
897 void
898 write_photocxx . . $ write_photo(c8bbdc903c38717e).(FILEcxx . . $ FILE# *fp,
899 unsigned char *cyan,
900 unsigned char *lcyan,
901 unsigned char *magenta,
902 unsigned char *lmagenta,
903 unsigned char *yellow,
904 unsigned char *black)
905 {
906 int count;
907 unsigned char cbyte,
908 lcbyte,
909 mbyte,
910 lmbyte,
911 ybyte,
912 kbyte,
913 bit,
914 shift;
915 int r, g, b, k;
916
917
918 if (dither_bitscxx . . $ dither_bits. == 1)
919 {
920 for (count = dimage_widthcxx . . $ dimage_width., cbyte = *cyan++, lcbyte = *lcyan++,
921 mbyte = *magenta++, lmbyte = *lmagenta++,
922 ybyte = *yellow++, kbyte = *black++, bit = 128;
923 count > 0;
924 count --)
925 {
926 if (kbyte & bit)
927 {
928 putccxx . . $ putc(b1cd03d6c470d1bd).(0, fp);
929 putccxx . . $ putc(b1cd03d6c470d1bd).(0, fp);
930 putccxx . . $ putc(b1cd03d6c470d1bd).(0, fp);
931 }
932 else
933 {
934 if (cbyte & bit)
935 putccxx . . $ putc(b1cd03d6c470d1bd).(0, fp);
936 else if (lcbyte & bit)
937 putccxx . . $ putc(b1cd03d6c470d1bd).(127, fp);
938 else
939 putccxx . . $ putc(b1cd03d6c470d1bd).(255, fp);
940
941 if (mbyte & bit)
942 putccxx . . $ putc(b1cd03d6c470d1bd).(0, fp);
943 else if (lmbyte & bit)
944 putccxx . . $ putc(b1cd03d6c470d1bd).(127, fp);
945 else
946 putccxx . . $ putc(b1cd03d6c470d1bd).(255, fp);
947
948 if (ybyte & bit)
949 putccxx . . $ putc(b1cd03d6c470d1bd).(0, fp);
950 else
951 putccxx . . $ putc(b1cd03d6c470d1bd).(255, fp);
952 }
953
954 if (bit > 1)
955 bit >>= 1;
956 else
957 {
958 cbyte = *cyan++;
959 lcbyte = *lcyan++;
960 mbyte = *magenta++;
961 lmbyte = *lmagenta++;
962 ybyte = *yellow++;
963 kbyte = *black++;
964 bit = 128;
965 }
966 }
967 }
968 else
969 {
970 unsigned char kb[BUFFER_SIZEcxx . . $ `test/testdither.c:38:9`!];
971 unsigned char cb[BUFFER_SIZEcxx . . $ `test/testdither.c:38:9`!];
972 unsigned char mb[BUFFER_SIZEcxx . . $ `test/testdither.c:38:9`!];
973 unsigned char lcb[BUFFER_SIZEcxx . . $ `test/testdither.c:38:9`!];
974 unsigned char lmb[BUFFER_SIZEcxx . . $ `test/testdither.c:38:9`!];
975 unsigned char yb[BUFFER_SIZEcxx . . $ `test/testdither.c:38:9`!];
976 unsigned char *kbuf = kb;
977 unsigned char *cbuf = cb;
978 unsigned char *mbuf = mb;
979 unsigned char *lcbuf = lcb;
980 unsigned char *lmbuf = lmb;
981 unsigned char *ybuf = yb;
982 stp_foldcxx . . $ stp_fold(7127c6a555fcd89a).(black, dimage_widthcxx . . $ dimage_width. / 8, kbuf);
983 stp_foldcxx . . $ stp_fold(7127c6a555fcd89a).(cyan, dimage_widthcxx . . $ dimage_width. / 8, cbuf);
984 stp_foldcxx . . $ stp_fold(7127c6a555fcd89a).(magenta, dimage_widthcxx . . $ dimage_width. / 8, mbuf);
985 stp_foldcxx . . $ stp_fold(7127c6a555fcd89a).(yellow, dimage_widthcxx . . $ dimage_width. / 8, ybuf);
986 stp_foldcxx . . $ stp_fold(7127c6a555fcd89a).(lcyan, dimage_widthcxx . . $ dimage_width. / 8, lcbuf);
987 stp_foldcxx . . $ stp_fold(7127c6a555fcd89a).(lmagenta, dimage_widthcxx . . $ dimage_width. / 8, lmbuf);
988 for (count = dimage_widthcxx . . $ dimage_width., cbyte = *cbuf++, mbyte = *mbuf++,
989 ybyte = *ybuf++, kbyte = *kbuf++, lmbyte = *lmbuf++,
990 lcbyte = *lcyan++, shift = 6;
991 count > 0;
992 count --)
993 {
994 k = 255 * ((kbyte >> shift) & 3) / 3;
995 r = 255 - 255 * ((cbyte >> shift) & 3) / 3 -
996 127 * ((lcbyte >> shift) & 3) / 3 - k;
997 g = 255 - 255 * ((mbyte >> shift) & 3) / 3 -
998 127 * ((lmbyte >> shift) & 3) / 3 - k;
999 b = 255 - 255 * ((ybyte >> shift) & 3) / 3 - k;
1000
1001 if (r < 0)
1002 putccxx . . $ putc(b1cd03d6c470d1bd).(0, fp);
1003 else
1004 putccxx . . $ putc(b1cd03d6c470d1bd).(r, fp);
1005
1006 if (g < 0)
1007 putccxx . . $ putc(b1cd03d6c470d1bd).(0, fp);
1008 else
1009 putccxx . . $ putc(b1cd03d6c470d1bd).(g, fp);
1010
1011 if (b < 0)
1012 putccxx . . $ putc(b1cd03d6c470d1bd).(0, fp);
1013 else
1014 putccxx . . $ putc(b1cd03d6c470d1bd).(b, fp);
1015
1016 if (shift > 0)
1017 shift -= 2;
1018 else
1019 {
1020 cbyte = *cbuf++;
1021 mbyte = *mbuf++;
1022 ybyte = *ybuf++;
1023 kbyte = *kbuf++;
1024 lmbyte = *lmbuf++;
1025 lcbyte = *lcbuf++;
1026 shift = 6;
1027 }
1028 }
1029 }
1030 }