]>
Commit | Line | Data |
---|---|---|
b6094c96 | 1 | Fixes: |
5e14796c JB |
2 | - cdj850 and cdj1600 were broken, because of terminating *b command |
3 | (by 'Y' or 'V' instead of 'y' or 'v'); now *b is terminated only | |
4 | for cdj880 | |
5 | - do_gcr replaced whole black component by CMY (so everything was | |
6 | printed using colour ink!); do_gcr with NOBLACK looks strange, | |
7 | like somebody didn't know what he's doing... (see the "XXX" comments); | |
8 | now old, actual DOGCR is used, but NOBLACK can be enabled by -dUseBlack=0 | |
9 | though | |
b6094c96 JB |
10 | |
11 | Jakub Bogusz <qboosh@pld-linux.org> | |
5810cb5e JB |
12 | --- ghostscript-9.55.0/contrib/gdevcd8.c.orig 2021-09-27 09:44:02.000000000 +0200 |
13 | +++ ghostscript-9.55.0/contrib/gdevcd8.c 2021-11-27 16:28:48.395077465 +0100 | |
14 | @@ -604,6 +604,7 @@ typedef struct gx_device_cdj850_s { | |
b6094c96 JB |
15 | StartRasterMode start_raster_mode; /* output function to start raster mode */ |
16 | PrintNonBlankLines print_non_blank_lines; /* output function to print a non blank line */ | |
17 | TerminatePage terminate_page; /* page termination output function */ | |
18 | + int useblack; /* use K compound */ | |
19 | } gx_device_cdj850; | |
20 | ||
21 | typedef struct { | |
5810cb5e | 22 | @@ -659,7 +660,7 @@ typedef struct { |
b6094c96 JB |
23 | blackcorrect,\ |
24 | start_raster_mode,\ | |
25 | print_non_blank_line,\ | |
26 | - terminate_page\ | |
27 | + terminate_page, 1\ | |
28 | } | |
29 | ||
30 | #define cdj_1600_device(procs, dev_name, x_dpi, y_dpi, bpp, print_page, correction, quality, papertype, intensities,ptype,compression,mastergamma,gammavalc,gammavalm,gammavaly,gammavalk,blackcorrect,start_raster_mode,print_non_blank_line,terminate_page)\ | |
5810cb5e | 31 | @@ -678,7 +679,7 @@ typedef struct { |
b6094c96 JB |
32 | blackcorrect,\ |
33 | start_raster_mode,\ | |
34 | print_non_blank_line,\ | |
35 | - terminate_page\ | |
36 | + terminate_page, 1\ | |
37 | } | |
38 | ||
39 | /* HP2200 and DNJ500 is a RGB printer */ | |
5810cb5e | 40 | @@ -698,7 +699,7 @@ typedef struct { |
b6094c96 JB |
41 | blackcorrect,\ |
42 | start_raster_mode,\ | |
43 | print_non_blank_line,\ | |
44 | - terminate_page\ | |
45 | + terminate_page, 1\ | |
46 | } | |
47 | ||
5810cb5e JB |
48 | /* Printer-specific functions. Most printers are handled by the cdj850_xx() |
49 | @@ -1077,6 +1078,7 @@ cdj850_get_params(gx_device * pdev, gs_p | |
b6094c96 | 50 | if (code < 0 || |
5e14796c JB |
51 | (code = param_write_int(plist, "Quality", &cdj850->quality)) < 0 || |
52 | (code = param_write_int(plist, "Papertype", &cdj850->papertype)) < 0 || | |
53 | + (code = param_write_int(plist, "UseBlack", &cdj850->useblack)) < 0 || | |
54 | (code = param_write_float(plist, "MasterGamma", &cdj850->gammavalc)) | |
55 | < 0 || | |
56 | (code = param_write_float(plist, "GammaValC", &cdj850->gammavalc)) < | |
5810cb5e | 57 | @@ -1100,6 +1102,7 @@ cdj850_put_params(gx_device * pdev, gs_p |
b6094c96 JB |
58 | { |
59 | int quality = cdj850->quality; | |
60 | int papertype = cdj850->papertype; | |
61 | + int useblack = cdj850->useblack; | |
62 | float mastergamma = cdj850->mastergamma; | |
63 | float gammavalc = cdj850->gammavalc; | |
64 | float gammavalm = cdj850->gammavalm; | |
5810cb5e | 65 | @@ -1112,6 +1115,7 @@ cdj850_put_params(gx_device * pdev, gs_p |
b6094c96 JB |
66 | code = cdj_put_param_int(plist, "BitsPerPixel", &bpp, 1, 32, code); |
67 | code = cdj_put_param_int(plist, "Quality", &quality, 0, 2, code); | |
68 | code = cdj_put_param_int(plist, "Papertype", &papertype, 0, 4, code); | |
69 | + code = cdj_put_param_int(plist, "UseBlack", &useblack, 0, 1, code); | |
13e3dc9d JB |
70 | code = cdj_put_param_float(plist, "MasterGamma", &mastergamma, 0.1f, 9.0f, code); |
71 | code = cdj_put_param_float(plist, "GammaValC", &gammavalc, 0.0f, 9.0f, code); | |
72 | code = cdj_put_param_float(plist, "GammaValM", &gammavalm, 0.0f, 9.0f, code); | |
5810cb5e | 73 | @@ -1128,6 +1132,7 @@ cdj850_put_params(gx_device * pdev, gs_p |
b6094c96 JB |
74 | |
75 | cdj850->quality = quality; | |
76 | cdj850->papertype = papertype; | |
77 | + cdj850->useblack = useblack; | |
78 | cdj850->mastergamma = mastergamma; | |
79 | cdj850->gammavalc = gammavalc; | |
80 | cdj850->gammavalm = gammavalm; | |
5810cb5e | 81 | @@ -1180,7 +1185,13 @@ static void |
5e14796c JB |
82 | gx_device_printer * pdev, |
83 | struct error_val_field *error_values); | |
b6094c96 JB |
84 | static int |
85 | - do_gcr(int bytecount, byte * inbyte, const byte * kvalues, | |
86 | + do_gcr_noblack(int bytecount, byte * inbyte, const byte * kvalues, | |
5e14796c JB |
87 | + const byte * cvalues, const byte * mvalues, |
88 | + const byte * yvalues, const int *kcorrect, | |
89 | + word * inword); | |
b6094c96 JB |
90 | + |
91 | +static int | |
92 | + do_gcr_gcr(int bytecount, byte * inbyte, const byte * kvalues, | |
5e14796c JB |
93 | const byte * cvalues, const byte * mvalues, |
94 | const byte * yvalues, const int *kcorrect, | |
95 | word * inword); | |
5810cb5e | 96 | @@ -2045,7 +2056,10 @@ send_scan_lines(gx_device_printer * pdev |
5e14796c JB |
97 | } |
98 | /* Skip blank lines if any */ | |
99 | if (num_blank_lines > 0) { | |
f05ebc2f AM |
100 | + if(cdj850->ptype == DJ880C) |
101 | gp_fprintf(prn_stream, "\033*b%dY", num_blank_lines / (cdj850->yscal + 1)); | |
102 | + else /* still in *b if not dj880 */ | |
103 | + fprintf(prn_stream, "%dy", num_blank_lines / (cdj850->yscal + 1)); | |
5e14796c JB |
104 | memset(data_ptrs->plane_data[0][0], 0, |
105 | (misc_vars->plane_size * 2 * misc_vars->num_comps)); | |
106 | memset(data_ptrs->plane_data_c[0][0], 0, | |
5810cb5e | 107 | @@ -2055,7 +2069,10 @@ send_scan_lines(gx_device_printer * pdev |
5e14796c JB |
108 | /* all blank lines printed, now for the non-blank lines */ |
109 | if (cdj850->yscal && odd(lnum)) { | |
110 | /* output a blank black plane for odd lines */ | |
f05ebc2f AM |
111 | + if(cdj850->ptype == DJ880C) |
112 | gp_fprintf(prn_stream, "\033*b0V"); | |
113 | + else /* still in *b if not dj880 */ | |
114 | + putc('v', prn_stream); | |
5e14796c JB |
115 | } |
116 | /* now output all non blank lines */ | |
117 | while (lnum < lend && llen != 0) { | |
5810cb5e | 118 | @@ -2081,9 +2098,11 @@ print_c9plane(gp_file * prn_stream, char |
b6094c96 JB |
119 | int out_count = gdev_pcl_mode9compress(plane_size, curr, prev, out_data); |
120 | ||
121 | /* and output the data */ | |
f05ebc2f | 122 | - gp_fprintf(prn_stream, "%d%c", out_count, plane_code); |
b6094c96 | 123 | if (out_count > 0) { |
f05ebc2f AM |
124 | + gp_fprintf(prn_stream, "%d%c", out_count, plane_code); |
125 | gp_fwrite(out_data, sizeof(byte), out_count, prn_stream); | |
b6094c96 | 126 | + } else { /* single plane_code is sufficient for cdj850 */ |
5e14796c | 127 | + putc(plane_code, prn_stream); |
b6094c96 JB |
128 | } |
129 | } | |
130 | ||
5810cb5e | 131 | @@ -2142,15 +2161,22 @@ cdj850_print_non_blank_lines(gx_device_p |
b6094c96 JB |
132 | byte *dp = data_ptrs->data[misc_vars->scan + 2]; |
133 | int *ep = data_ptrs->errors[misc_vars->scan]; | |
134 | ||
135 | - /* we need cmyk color separation befor all the rest, since | |
136 | + /* we need cmyk color separation before all the rest, since | |
137 | black may be contained in the color fields. This needs to | |
138 | be done on all pixel-rows, since even unused color-bytes | |
139 | might generate black */ | |
140 | ||
141 | + if(cdj850->useblack) { | |
142 | misc_vars->is_color_data = | |
5e14796c JB |
143 | - do_gcr(misc_vars->databuff_size, data_ptrs->data[misc_vars->scan], |
144 | + do_gcr_gcr(misc_vars->databuff_size, data_ptrs->data[misc_vars->scan], | |
145 | gamma->k, gamma->c, gamma->m, gamma->y, gamma->correct, | |
146 | (word *) data_ptrs->data[misc_vars->scan]); | |
b6094c96 JB |
147 | + } else { |
148 | + misc_vars->is_color_data = | |
5e14796c JB |
149 | + do_gcr_noblack(misc_vars->databuff_size, data_ptrs->data[misc_vars->scan], |
150 | + gamma->k, gamma->c, gamma->m, gamma->y, gamma->correct, | |
151 | + (word *) data_ptrs->data[misc_vars->scan]); | |
b6094c96 | 152 | + } |
5e14796c | 153 | |
b6094c96 JB |
154 | /* dithering the black-plane */ |
155 | FSDlinebw(misc_vars->scan, misc_vars->plane_size, | |
5810cb5e | 156 | @@ -2220,15 +2246,22 @@ cdj880_print_non_blank_lines(gx_device_p |
b6094c96 JB |
157 | byte *dp = data_ptrs->data[misc_vars->scan + 2]; |
158 | int *ep = data_ptrs->errors[misc_vars->scan]; | |
159 | ||
160 | - /* we need cmyk color separation befor all the rest, since | |
161 | + /* we need cmyk color separation before all the rest, since | |
162 | black may be contained in the color fields. This needs to | |
163 | be done on all pixel-rows, since even unused color-bytes | |
164 | might generate black */ | |
165 | ||
166 | + if(cdj850->useblack) { | |
b6094c96 | 167 | + misc_vars->is_color_data = |
5e14796c JB |
168 | + do_gcr_gcr(misc_vars->databuff_size, data_ptrs->data[misc_vars->scan], |
169 | + gamma->k, gamma->c, gamma->m, gamma->y, gamma->correct, | |
170 | + (word *) data_ptrs->data[misc_vars->scan]); | |
171 | + } else { | |
172 | misc_vars->is_color_data = | |
173 | - do_gcr(misc_vars->databuff_size, data_ptrs->data[misc_vars->scan], | |
174 | + do_gcr_noblack(misc_vars->databuff_size, data_ptrs->data[misc_vars->scan], | |
175 | gamma->k, gamma->c, gamma->m, gamma->y, gamma->correct, | |
176 | (word *) data_ptrs->data[misc_vars->scan]); | |
b6094c96 JB |
177 | + } |
178 | ||
179 | /* dithering the black-plane */ | |
180 | FSDlinebw(misc_vars->scan, misc_vars->plane_size, | |
5810cb5e | 181 | @@ -2431,7 +2464,7 @@ do_black_correction(float kvalue, int kc |
b6094c96 JB |
182 | do real color separation, here we try a real grey component |
183 | replacement */ | |
184 | static int | |
185 | -do_gcr(int bytecount, byte * inbyte, const byte kvalues[256], | |
186 | +do_gcr_noblack(int bytecount, byte * inbyte, const byte kvalues[256], | |
187 | const byte cvalues[256], const byte mvalues[256], | |
188 | const byte yvalues[256], const int kcorrect[256], | |
189 | word * inword) | |
5810cb5e | 190 | @@ -2441,7 +2474,7 @@ do_gcr(int bytecount, byte * inbyte, con |
d7fcaa57 JB |
191 | word last_color_value = 0; |
192 | word *last_color; | |
193 | ||
194 | - /* initialise *last_color with a dummmy value */ | |
195 | + /* initialise *last_color with a dummy value */ | |
196 | last_color = &last_color_value; | |
197 | /* Grey component replacement */ | |
198 | for (i = 0; i < bytecount; i += 4) { | |
5810cb5e | 199 | @@ -2471,11 +2504,12 @@ do_gcr(int bytecount, byte * inbyte, con |
5e14796c | 200 | /* Test whether we 've already computet the value */ |
b6094c96 | 201 | if (*inword == last_color_value) { |
5e14796c JB |
202 | /* save a copy of the current color before it will be modified */ |
203 | - last_color_value = *inword; | |
204 | + last_color_value = *inword; /* NOP --q */ | |
b6094c96 | 205 | /* debug_print_string("\n", 1);*/ |
5e14796c JB |
206 | /* copy the result of the old value onto the new position */ |
207 | *inword = *last_color; | |
b6094c96 | 208 | } else { |
5e14796c JB |
209 | + /* ??? ALL these NOBLACKs will be NOPs after the first NOBLACK! what are they for??? --q */ |
210 | /* save a copy of the current color before it will be modified */ | |
211 | last_color_value = *inword; | |
b6094c96 | 212 | NOBLACK(cyan, magenta, yellow, black); |
5810cb5e | 213 | @@ -2513,6 +2547,7 @@ do_gcr(int bytecount, byte * inbyte, con |
d7fcaa57 JB |
214 | debug_print_string(output, strlen(output)); |
215 | } | |
b6094c96 | 216 | #endif /* 0 */ |
d7fcaa57 JB |
217 | + /* XXX: how byte could be >255??? --q */ |
218 | if ( *cyan > 255) *cyan = 255; | |
219 | if (*magenta > 255) *magenta = 255; | |
220 | if ( *yellow > 255) *yellow = 255; | |
5810cb5e | 221 | @@ -2520,6 +2555,96 @@ do_gcr(int bytecount, byte * inbyte, con |
d7fcaa57 JB |
222 | *cyan = *(cvalues + *cyan); |
223 | *magenta = *(mvalues + *magenta); | |
224 | *yellow = *(yvalues + *yellow); | |
225 | + last_color = inword; /* save pointer */ | |
b6094c96 JB |
226 | + }/* end current_color */ |
227 | + } /* end of if c+m+y > 0 */ | |
228 | + *black = *(kvalues + *black); | |
229 | + inword = inword + 1; | |
230 | + } /* end of for bytecount */ | |
231 | + return is_color; | |
232 | +} | |
233 | + | |
234 | +static int | |
235 | +do_gcr_gcr(int bytecount, byte * inbyte, const byte kvalues[256], | |
236 | + const byte cvalues[256], const byte mvalues[256], | |
237 | + const byte yvalues[256], const int kcorrect[256], | |
238 | + word * inword) | |
239 | +{ | |
240 | + int i, ucr, kadd, is_color = 0; | |
241 | + float uca_fac; | |
242 | + byte *black, *cyan, *magenta, *yellow; | |
243 | + word last_color_value = 0; | |
244 | + word *last_color; | |
b6094c96 | 245 | + |
d7fcaa57 | 246 | + /* initialise *last_color with a dummy value */ |
b6094c96 JB |
247 | + last_color = &last_color_value; |
248 | + /* Grey component replacement */ | |
249 | + for (i = 0; i < bytecount; i += 4) { | |
d7fcaa57 | 250 | + |
b6094c96 | 251 | + /* Assign to black the current address of inbyte */ |
d7fcaa57 | 252 | + black = inbyte++; |
b6094c96 JB |
253 | + cyan = inbyte++; |
254 | + magenta = inbyte++; | |
255 | + yellow = inbyte++; | |
256 | + | |
257 | + if (*magenta + *yellow + *cyan > 0) { /* if any color at all */ | |
258 | + | |
259 | +#if 0 | |
260 | + if ((*cyan > 0) && (*magenta > 0) && (*yellow > 0)) | |
261 | + { | |
d7fcaa57 JB |
262 | + char output[255]; |
263 | + gs_sprintf(output, "%3d %3d %3d %3d - ", *cyan, *magenta, *yellow, *black); | |
b6094c96 JB |
264 | + debug_print_string(output, strlen(output)); |
265 | + } | |
266 | +#endif /* 0 */ | |
d7fcaa57 | 267 | + |
b6094c96 JB |
268 | + is_color = 1; |
269 | + | |
d7fcaa57 | 270 | + /* Test whether we 've already computet the value */ |
b6094c96 JB |
271 | + if (*inword == last_color_value) { |
272 | +/* debug_print_string("\n", 1);*/ | |
5e14796c JB |
273 | + /* copy the result of the old value onto the new position */ |
274 | + *inword = *last_color; | |
b6094c96 | 275 | + } else { |
5e14796c JB |
276 | + /* save a copy of the current color before it will be modified */ |
277 | + last_color_value = *inword; | |
278 | + if ((*cyan >= *magenta) | |
279 | + && (*magenta >= *yellow) | |
d7fcaa57 | 280 | + && (*yellow > 0)) { /* if any grey component */ |
5e14796c JB |
281 | + DOGCR(cyan, magenta, yellow, black); |
282 | + } else if ((*cyan >= *yellow) | |
283 | + && (*yellow >= *magenta) | |
284 | + && (*magenta > 0)) { | |
285 | + DOGCR(cyan, yellow, magenta, black); | |
286 | + } else if ((*yellow >= *magenta) | |
287 | + && (*magenta >= *cyan) | |
288 | + && (*cyan > 0)) { | |
289 | + DOGCR(yellow, magenta, cyan, black); | |
290 | + } else if ((*yellow >= *cyan) | |
291 | + && (*cyan >= *magenta) | |
292 | + && (*magenta > 0)) { | |
293 | + DOGCR(yellow, cyan, magenta, black); | |
294 | + } else if ((*magenta >= *yellow) | |
295 | + && (*yellow >= *cyan) | |
296 | + && (*cyan > 0)) { | |
297 | + DOGCR(magenta, yellow, cyan, black); | |
298 | + } else if ((*magenta >= *cyan) | |
299 | + && (*cyan >= *yellow) | |
300 | + && (*yellow > 0)) { | |
301 | + DOGCR(magenta, cyan, yellow, black); | |
d7fcaa57 | 302 | + } else { /* do gamma only if no black */ |
5e14796c | 303 | + } |
b6094c96 | 304 | +#if 0 |
d7fcaa57 JB |
305 | + if (ucr > 0) |
306 | + { | |
307 | + char output[255]; | |
308 | + gs_sprintf(output, "%3d %3d %3d %3d - %5d\n", *cyan, *magenta, *yellow, *black, ucr); | |
309 | + debug_print_string(output, strlen(output)); | |
310 | + } | |
b6094c96 | 311 | +#endif /* 0 */ |
d7fcaa57 JB |
312 | + *cyan = *(cvalues + *cyan); |
313 | + *magenta = *(mvalues + *magenta); | |
314 | + *yellow = *(yvalues + *yellow); | |
315 | last_color = inword; /* save pointer */ | |
b6094c96 JB |
316 | }/* end current_color */ |
317 | } /* end of if c+m+y > 0 */ |