SOURCES: ghostscript-gpl-gdevcd8-fixes.patch (NEW) - add to be fix...

djurban djurban at pld-linux.org
Thu Sep 1 19:47:02 CEST 2005


Author: djurban                      Date: Thu Sep  1 17:47:02 2005 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- add to be fixed in the future, not sure that i need it though

---- Files affected:
SOURCES:
   ghostscript-gpl-gdevcd8-fixes.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/ghostscript-gpl-gdevcd8-fixes.patch
diff -u /dev/null SOURCES/ghostscript-gpl-gdevcd8-fixes.patch:1.1
--- /dev/null	Thu Sep  1 19:47:02 2005
+++ SOURCES/ghostscript-gpl-gdevcd8-fixes.patch	Thu Sep  1 19:46:57 2005
@@ -0,0 +1,314 @@
+Fixes:
+	- cdj850 and cdj1600 were broken, because of terminating *b command
+	  (by 'Y' or 'V' instead of 'y' or 'v'); now *b is terminated only
+	  for cdj880)
+	- do_gcr replaced whole black component by CMY (so everything was
+	  printed using colour ink!); do_gcr with NOBLACK looks strange,
+	  like somebody didn't know what he's doing... now old, actual
+	  DOGCR is used, but NOBLACK can be enabled by -dUseBlack=0 though
+
+--- espgs-7.05.6/src/gdevcdj.c.orig	2003-07-08 21:26:53.000000000 +0200
++++ espgs-7.05.6/src/gdevcdj.c	2003-07-09 23:07:04.000000000 +0200
+@@ -606,6 +606,7 @@
+     StartRasterMode start_raster_mode;	/* output function to start raster mode */
+     PrintNonBlankLines print_non_blank_lines;	/* output function to print a non blank line */
+     TerminatePage terminate_page;	/* page termination output function */
++    int useblack;
+ } gx_device_cdj850;
+ 
+ typedef struct {
+@@ -662,7 +663,7 @@
+     blackcorrect,\
+     start_raster_mode,\
+     print_non_blank_line,\
+-    terminate_page\
++    terminate_page, 1\
+ }
+ 
+ #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)\
+@@ -681,7 +682,7 @@
+     blackcorrect,\
+     start_raster_mode,\
+     print_non_blank_line,\
+-    terminate_page\
++    terminate_page, 1\
+ }
+ 
+ /* HP2200 is a RGB printer */
+@@ -701,7 +702,7 @@
+     blackcorrect,\
+     start_raster_mode,\
+     print_non_blank_line,\
+-    terminate_page\
++    terminate_page, 1\
+ }
+ 
+ #define cmyk_colour_procs(proc_colour_open, proc_get_params, proc_put_params, \
+@@ -1028,6 +1029,7 @@
+     if (code < 0 ||
+ 	(code = param_write_int(plist, "Quality", &cdj850->quality)) < 0 ||
+ 	(code = param_write_int(plist, "Papertype", &cdj850->papertype)) < 0 ||
++	(code = param_write_int(plist, "UseBlack", &cdj850->useblack)) < 0 ||
+ 	(code = param_write_float(plist, "MasterGamma", &cdj850->gammavalc))
+ 	< 0 ||
+ 	(code = param_write_float(plist, "GammaValC", &cdj850->gammavalc)) <
+@@ -1051,6 +1053,7 @@
+ {
+     int quality = cdj850->quality;
+     int papertype = cdj850->papertype;
++    int useblack = cdj850->useblack;
+     float mastergamma = cdj850->mastergamma;
+     float gammavalc = cdj850->gammavalc;
+     float gammavalm = cdj850->gammavalm;
+@@ -1063,6 +1066,7 @@
+     code = cdj_put_param_int(plist, "BitsPerPixel", &bpp, 1, 32, code);
+     code = cdj_put_param_int(plist, "Quality", &quality, 0, 2, code);
+     code = cdj_put_param_int(plist, "Papertype", &papertype, 0, 4, code);
++    code = cdj_put_param_int(plist, "UseBlack", &useblack, 0, 1, code);
+     code = cdj_put_param_float(plist, "MasterGamma", &mastergamma, 0.1, 9.0, code);
+     code = cdj_put_param_float(plist, "GammaValC", &gammavalc, 0.0, 9.0, code);
+     code = cdj_put_param_float(plist, "GammaValM", &gammavalm, 0.0, 9.0, code);
+@@ -1084,6 +1084,7 @@
+ 
+     cdj850->quality = quality;
+     cdj850->papertype = papertype;
++    cdj850->useblack = useblack;
+     cdj850->mastergamma = mastergamma;
+     cdj850->gammavalc = gammavalc;
+     cdj850->gammavalm = gammavalm;
+@@ -1137,7 +1137,13 @@
+ 			   gx_device_printer * pdev,
+ 			   struct error_val_field *error_values));
+ private int
+-    do_gcr(P8(int bytecount, byte * inbyte, const byte * kvalues,
++    do_gcr_noblack(P8(int bytecount, byte * inbyte, const byte * kvalues,
++	      const byte * cvalues, const byte * mvalues,
++	      const byte * yvalues, const int *kcorrect,
++	      word * inword));
++
++private int
++    do_gcr_gcr(P8(int bytecount, byte * inbyte, const byte * kvalues,
+ 	      const byte * cvalues, const byte * mvalues,
+ 	      const byte * yvalues, const int *kcorrect,
+ 	      word * inword));
+@@ -1847,7 +1851,10 @@
+ 	}
+ 	/* Skip blank lines if any */
+ 	if (num_blank_lines > 0) {
+-	    fprintf(prn_stream, "\033*b%dY", num_blank_lines / (cdj850->yscal + 1));
++	    if (cdj850->ptype == DJ880C)
++		fprintf(prn_stream, "\033*b%dY", num_blank_lines / (cdj850->yscal + 1));
++	    else	/* still in *b if !dj880 */
++		fprintf(prn_stream, "%dy", num_blank_lines / (cdj850->yscal + 1));
+ 	    memset(data_ptrs->plane_data[0][0], 0,
+ 		   (misc_vars->plane_size * 2 * misc_vars->num_comps));
+ 	    memset(data_ptrs->plane_data_c[0][0], 0,
+@@ -1857,7 +1864,10 @@
+ 	/* all blank lines printed, now for the non-blank lines */
+ 	if (cdj850->yscal && odd(lnum)) {
+ 	    /* output a blank black plane for odd lines */
+-	    fprintf(prn_stream, "\033*b0V");
++	    if (cdj850->ptype == DJ880C)
++		fprintf(prn_stream, "\033*b0V");
++	    else	/* still in *b if !dj880 */
++		putc('v', prn_stream);
+ 	}
+ 	/* now output all non blank lines */
+ 	while (lnum < lend && llen != 0) {
+@@ -1883,9 +1893,11 @@
+     int out_count = gdev_pcl_mode9compress(plane_size, curr, prev, out_data);
+ 
+     /* and output the data */
+-	fprintf(prn_stream, "%d%c", out_count, plane_code);
+     if (out_count > 0) {
++	fprintf(prn_stream, "%d%c", out_count, plane_code);
+ 	fwrite(out_data, sizeof(byte), out_count, prn_stream);
++    } else {	/* single plane_code is sufficient for cdj850 */
++	putc(plane_code, prn_stream);
+     }
+ }
+ 
+@@ -1945,15 +1957,22 @@
+     byte *dp = data_ptrs->data[misc_vars->scan + 2];
+     int *ep = data_ptrs->errors[misc_vars->scan];
+ 
+-    /* we need cmyk color separation befor all the rest, since
++    /* we need cmyk color separation before all the rest, since
+        black may be contained in the color fields. This needs to
+        be done on all pixel-rows, since even unused color-bytes
+        might generate black */
+ 
++    if(cdj850->useblack) {
+     misc_vars->is_color_data =
+-	do_gcr(misc_vars->databuff_size, data_ptrs->data[misc_vars->scan],
++	do_gcr_gcr(misc_vars->databuff_size, data_ptrs->data[misc_vars->scan],
+ 	       gamma->k, gamma->c, gamma->m, gamma->y, gamma->correct,
+ 	       (word *) data_ptrs->data[misc_vars->scan]);
++    } else {
++    misc_vars->is_color_data =
++	do_gcr_noblack(misc_vars->databuff_size, data_ptrs->data[misc_vars->scan],
++	       gamma->k, gamma->c, gamma->m, gamma->y, gamma->correct,
++	       (word *) data_ptrs->data[misc_vars->scan]);
++    }
+ 
+     /* dithering the black-plane */
+     FSDlinebw(misc_vars->scan, misc_vars->plane_size,
+@@ -2028,10 +2047,17 @@
+        be done on all pixel-rows, since even unused color-bytes
+        might generate black */
+ 
++    if(cdj850->useblack) {
++    misc_vars->is_color_data =
++	do_gcr_gcr(misc_vars->databuff_size, data_ptrs->data[misc_vars->scan],
++	       gamma->k, gamma->c, gamma->m, gamma->y, gamma->correct,
++	       (word *) data_ptrs->data[misc_vars->scan]);
++    } else {
+     misc_vars->is_color_data =
+-	do_gcr(misc_vars->databuff_size, data_ptrs->data[misc_vars->scan],
++	do_gcr_noblack(misc_vars->databuff_size, data_ptrs->data[misc_vars->scan],
+ 	       gamma->k, gamma->c, gamma->m, gamma->y, gamma->correct,
+ 	       (word *) data_ptrs->data[misc_vars->scan]);
++    }
+ 
+     /* dithering the black-plane */
+     FSDlinebw(misc_vars->scan, misc_vars->plane_size,
+@@ -2171,8 +2197,6 @@
+     int i;
+ 
+     for (i = 0; i < 256; i++) {
+-      kcorrect[i] = 0;
+-#if 0
+ 	kcorrect[i] = (int)
+ 	    (100.0 * kvalue * (
+ 				  pow(10.0,
+@@ -2181,7 +2205,6 @@
+ 				  - 1.0
+ 	     )
+ 	    );
+-#endif /* 0 */
+     }
+ 
+     return;
+@@ -2240,7 +2263,7 @@
+    do real color separation, here we try a real grey component
+    replacement */
+ private int
+-do_gcr(int bytecount, byte * inbyte, const byte kvalues[256],
++do_gcr_noblack(int bytecount, byte * inbyte, const byte kvalues[256],
+        const byte cvalues[256], const byte mvalues[256],
+        const byte yvalues[256], const int kcorrect[256],
+        word * inword)
+@@ -2288,6 +2311,7 @@
+       } else {
+ 	/* save a copy of the current color before it will be modified */
+ 	last_color_value = *inword;
++	/* ??? these NOBLACK will be NOP after one previous NOBLACK ??? it's sick! */
+   NOBLACK(cyan, magenta, yellow, black);
+ 	if ((*cyan >= *magenta)
+ 	    && (*magenta >= *yellow)
+@@ -2322,6 +2346,7 @@
+       debug_print_string(output, strlen(output));
+     }
+ #endif /* 0 */
++	  /* how BYTE can be > 255 ??? */
+ 	  if (   *cyan > 255)    *cyan = 255;
+ 	  if (*magenta > 255) *magenta = 255;
+ 	  if ( *yellow > 255)  *yellow = 255;
+@@ -2338,6 +2363,97 @@
+   return is_color;
+ }
+ 
++private int
++do_gcr_gcr(int bytecount, byte * inbyte, const byte kvalues[256],
++       const byte cvalues[256], const byte mvalues[256],
++       const byte yvalues[256], const int kcorrect[256],
++       word * inword)
++{
++  int i, ucr, kadd, is_color = 0;
++  float uca_fac;
++  byte *black, *cyan, *magenta, *yellow;
++  word last_color_value = 0;
++  word *last_color;
++  char output[255], out2[128];
++
++  /* initialise *last_color with a dummmy value */
++  last_color = &last_color_value;
++  /* Grey component replacement */
++  for (i = 0; i < bytecount; i += 4) {
++    
++    /* Assign to black the current address of  inbyte */
++    black = inbyte++;	
++    cyan = inbyte++;
++    magenta = inbyte++;
++    yellow = inbyte++;
++
++    if (*magenta + *yellow + *cyan > 0) {	/* if any color at all */
++
++#if 0
++      if ((*cyan > 0) && (*magenta > 0) && (*yellow > 0))
++      {
++        sprintf(output, "%3d %3d %3d %3d - ", *cyan, *magenta, *yellow, *black);
++        debug_print_string(output, strlen(output));
++      }
++#endif /* 0 */
++      
++      is_color = 1;
++
++      /* Test whether we 've already computet the value */
++      if (*inword == last_color_value) {
++	/* save a copy of the current color before it will be modified */
++	last_color_value = *inword;
++/*	debug_print_string("\n", 1);*/
++	/* copy the result of the old value onto the new position */
++	*inword = *last_color;
++      } else {
++	/* save a copy of the current color before it will be modified */
++	last_color_value = *inword;
++	if ((*cyan >= *magenta)
++	    && (*magenta >= *yellow)
++	    && (*yellow > 0)) {	/* if any grey component */
++	  DOGCR(cyan, magenta, yellow, black);
++	} else if ((*cyan >= *yellow)
++		   && (*yellow >= *magenta)
++		   && (*magenta > 0)) {
++	  DOGCR(cyan, yellow, magenta, black);
++	} else if ((*yellow >= *magenta)
++		   && (*magenta >= *cyan)
++		   && (*cyan > 0)) {
++	  DOGCR(yellow, magenta, cyan, black);
++	} else if ((*yellow >= *cyan)
++		   && (*cyan >= *magenta)
++		   && (*magenta > 0)) {
++	  DOGCR(yellow, cyan, magenta, black);
++	} else if ((*magenta >= *yellow)
++		   && (*yellow >= *cyan)
++		   && (*cyan > 0)) {
++	  DOGCR(magenta, yellow, cyan, black);
++	} else if ((*magenta >= *cyan)
++		   && (*cyan >= *yellow)
++		   && (*yellow > 0)) {
++	  DOGCR(magenta, cyan, yellow, black);
++	} else {		/* do gamma only if no black */
++	}
++#if 0
++	  if (ucr > 0)
++	  {
++      sprintf(output, "%3d %3d %3d %3d - %5d\n", *cyan, *magenta, *yellow, *black, ucr);
++      debug_print_string(output, strlen(output));
++    }
++#endif /* 0 */
++	  *cyan = *(cvalues + *cyan);
++	  *magenta = *(mvalues + *magenta);
++	  *yellow = *(yvalues + *yellow);
++	  last_color =  inword; /* save pointer */
++      }/* end current_color */
++    }			/* end of if c+m+y > 0 */
++    *black = *(kvalues + *black);
++    inword = inword + 1;
++  } /* end of for bytecount */
++  return is_color;
++}
++
+ /* Since resolution can be different on different planes, we need to
+    rescale the data byte by byte */
+ private int
================================================================



More information about the pld-cvs-commit mailing list