]> git.pld-linux.org Git - packages/ghostscript.git/blame - ghostscript-gdevcd8-fixes.patch
- use system freetype
[packages/ghostscript.git] / ghostscript-gdevcd8-fixes.patch
CommitLineData
b6094c96 1Fixes:
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
11Jakub Bogusz <qboosh@pld-linux.org>
5e14796c
JB
12--- ghostscript-9.04/contrib/gdevcd8.c.orig 2011-08-05 13:12:20.000000000 +0200
13+++ ghostscript-9.04/contrib/gdevcd8.c 2011-08-15 21:10:22.919653641 +0200
14@@ -600,6 +600,7 @@
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 {
5e14796c 22@@ -655,7 +656,7 @@
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)\
5e14796c 31@@ -674,7 +675,7 @@
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 */
5e14796c 40@@ -694,7 +695,7 @@
b6094c96
JB
41 blackcorrect,\
42 start_raster_mode,\
43 print_non_blank_line,\
44- terminate_page\
45+ terminate_page, 1\
46 }
47
48 #define cmyk_colour_procs(proc_colour_open, proc_get_params, proc_put_params, \
5e14796c 49@@ -1052,6 +1053,7 @@
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)) <
57@@ -1075,6 +1077,7 @@
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;
5e14796c 65@@ -1087,6 +1090,7 @@
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);
70 code = cdj_put_param_float(plist, "MasterGamma", &mastergamma, 0.1, 9.0, code);
71 code = cdj_put_param_float(plist, "GammaValC", &gammavalc, 0.0, 9.0, code);
72 code = cdj_put_param_float(plist, "GammaValM", &gammavalm, 0.0, 9.0, code);
5e14796c 73@@ -1103,6 +1107,7 @@
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;
5e14796c
JB
81@@ -1155,7 +1160,13 @@
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);
96@@ -2018,7 +2029,10 @@
97 }
98 /* Skip blank lines if any */
99 if (num_blank_lines > 0) {
100+ if(cdj850->ptype == DJ880C)
101 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));
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,
107@@ -2028,7 +2042,10 @@
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 */
111+ if(cdj850->ptype == DJ880C)
112 fprintf(prn_stream, "\033*b0V");
113+ else /* still in *b if not dj880 */
114+ putc('v', prn_stream);
115 }
116 /* now output all non blank lines */
117 while (lnum < lend && llen != 0) {
118@@ -2054,9 +2071,11 @@
b6094c96
JB
119 int out_count = gdev_pcl_mode9compress(plane_size, curr, prev, out_data);
120
121 /* and output the data */
5e14796c 122- fprintf(prn_stream, "%d%c", out_count, plane_code);
b6094c96 123 if (out_count > 0) {
5e14796c
JB
124+ fprintf(prn_stream, "%d%c", out_count, plane_code);
125 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
5e14796c 131@@ -2113,15 +2132,22 @@
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,
5e14796c 156@@ -2191,15 +2217,22 @@
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,
5e14796c 181@@ -2408,7 +2441,7 @@
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)
5e14796c
JB
190@@ -2449,11 +2482,12 @@
191 /* Test whether we 've already computet the value */
b6094c96 192 if (*inword == last_color_value) {
5e14796c
JB
193 /* save a copy of the current color before it will be modified */
194- last_color_value = *inword;
195+ last_color_value = *inword; /* NOP --q */
b6094c96 196 /* debug_print_string("\n", 1);*/
5e14796c
JB
197 /* copy the result of the old value onto the new position */
198 *inword = *last_color;
b6094c96 199 } else {
5e14796c
JB
200+ /* ??? ALL these NOBLACKs will be NOPs after the first NOBLACK! what are they for??? --q */
201 /* save a copy of the current color before it will be modified */
202 last_color_value = *inword;
b6094c96 203 NOBLACK(cyan, magenta, yellow, black);
5e14796c 204@@ -2490,6 +2524,7 @@
b6094c96
JB
205 debug_print_string(output, strlen(output));
206 }
207 #endif /* 0 */
5e14796c
JB
208+ /* XXX: how byte could be >255??? --q */
209 if ( *cyan > 255) *cyan = 255;
210 if (*magenta > 255) *magenta = 255;
211 if ( *yellow > 255) *yellow = 255;
212@@ -2497,6 +2532,95 @@
213 *cyan = *(cvalues + *cyan);
214 *magenta = *(mvalues + *magenta);
215 *yellow = *(yvalues + *yellow);
b6094c96
JB
216+ last_color = inword; /* save pointer */
217+ }/* end current_color */
218+ } /* end of if c+m+y > 0 */
219+ *black = *(kvalues + *black);
220+ inword = inword + 1;
221+ } /* end of for bytecount */
222+ return is_color;
223+}
224+
225+static int
226+do_gcr_gcr(int bytecount, byte * inbyte, const byte kvalues[256],
227+ const byte cvalues[256], const byte mvalues[256],
228+ const byte yvalues[256], const int kcorrect[256],
229+ word * inword)
230+{
231+ int i, ucr, kadd, is_color = 0;
232+ float uca_fac;
233+ byte *black, *cyan, *magenta, *yellow;
234+ word last_color_value = 0;
235+ word *last_color;
236+ char output[255], out2[128];
237+
238+ /* initialise *last_color with a dummmy value */
239+ last_color = &last_color_value;
240+ /* Grey component replacement */
241+ for (i = 0; i < bytecount; i += 4) {
242+
243+ /* Assign to black the current address of inbyte */
244+ black = inbyte++;
245+ cyan = inbyte++;
246+ magenta = inbyte++;
247+ yellow = inbyte++;
248+
249+ if (*magenta + *yellow + *cyan > 0) { /* if any color at all */
250+
251+#if 0
252+ if ((*cyan > 0) && (*magenta > 0) && (*yellow > 0))
253+ {
254+ sprintf(output, "%3d %3d %3d %3d - ", *cyan, *magenta, *yellow, *black);
255+ debug_print_string(output, strlen(output));
256+ }
257+#endif /* 0 */
258+
259+ is_color = 1;
260+
261+ /* Test whether we've already computed the value */
262+ if (*inword == last_color_value) {
263+/* debug_print_string("\n", 1);*/
5e14796c
JB
264+ /* copy the result of the old value onto the new position */
265+ *inword = *last_color;
b6094c96 266+ } else {
5e14796c
JB
267+ /* save a copy of the current color before it will be modified */
268+ last_color_value = *inword;
269+ if ((*cyan >= *magenta)
270+ && (*magenta >= *yellow)
271+ && (*yellow > 0)) { /* if any grey component */
272+ DOGCR(cyan, magenta, yellow, black);
273+ } else if ((*cyan >= *yellow)
274+ && (*yellow >= *magenta)
275+ && (*magenta > 0)) {
276+ DOGCR(cyan, yellow, magenta, black);
277+ } else if ((*yellow >= *magenta)
278+ && (*magenta >= *cyan)
279+ && (*cyan > 0)) {
280+ DOGCR(yellow, magenta, cyan, black);
281+ } else if ((*yellow >= *cyan)
282+ && (*cyan >= *magenta)
283+ && (*magenta > 0)) {
284+ DOGCR(yellow, cyan, magenta, black);
285+ } else if ((*magenta >= *yellow)
286+ && (*yellow >= *cyan)
287+ && (*cyan > 0)) {
288+ DOGCR(magenta, yellow, cyan, black);
289+ } else if ((*magenta >= *cyan)
290+ && (*cyan >= *yellow)
291+ && (*yellow > 0)) {
292+ DOGCR(magenta, cyan, yellow, black);
293+ } else { /* do gamma only if no black */
294+ }
b6094c96 295+#if 0
5e14796c
JB
296+ if (ucr > 0)
297+ {
b6094c96
JB
298+ sprintf(output, "%3d %3d %3d %3d - %5d\n", *cyan, *magenta, *yellow, *black, ucr);
299+ debug_print_string(output, strlen(output));
300+ }
301+#endif /* 0 */
5e14796c
JB
302+ *cyan = *(cvalues + *cyan);
303+ *magenta = *(mvalues + *magenta);
304+ *yellow = *(yvalues + *yellow);
305 last_color = inword; /* save pointer */
b6094c96
JB
306 }/* end current_color */
307 } /* end of if c+m+y > 0 */
This page took 0.118812 seconds and 4 git commands to generate.