[gs-cvs] rev 8379 - trunk/gs/src

alexcher at ghostscript.com alexcher at ghostscript.com
Sun Nov 18 14:50:37 PST 2007


Author: alexcher
Date: 2007-11-18 14:50:36 -0800 (Sun, 18 Nov 2007)
New Revision: 8379

Modified:
   trunk/gs/src/siscale.c
Log:
Normalize weigts in the Mitchell filter and use proper rounding to ensure
that the constant value is not changed by the filter.
Bug 689556, customer 581.

DIFFERENCES:
Interpolated images in 148-11.ps shows slight difference in density.
On halftone devices this results in different transition from black to
white for some pixels.


Modified: trunk/gs/src/siscale.c
===================================================================
--- trunk/gs/src/siscale.c	2007-11-18 16:48:41 UTC (rev 8378)
+++ trunk/gs/src/siscale.c	2007-11-18 22:50:36 UTC (rev 8379)
@@ -66,7 +66,7 @@
 #define num_weight_bits 0		/* Not used for floating point */
 #define fixedScaleFactor 1		/* Straight scaling for floating point */
 #define scale_PixelWeight(factor) (factor)
-#define unscale_AccumTmp(atemp, fraction_bits) ((int)(atemp))
+#define unscale_AccumTmp(atemp, fraction_bits) ((int)(atemp + 0.5))
 /*#undef NEED_FRACTION_BITS*/
 
 #endif /* USE_FPU */
@@ -265,18 +265,24 @@
 	for (j = 0; j < npixels; ++j)
 	    p[j].weight = 0;
 	if (squeeze) {
+            double sum = 0;
+	    for (j = left; j <= right; ++j)
+		sum += fproc((center - j) / fscale) / fscale;
 	    for (j = left; j <= right; ++j) {
-		double weight =
-		fproc((center - j) / fscale) / fscale;
+		double weight = fproc((center - j) / fscale) / fscale / sum;
 		int n = clamp_pixel(j);
 		int k = n - first_pixel;
 
-		p[k].weight +=
+                p[k].weight +=
 		    (PixelWeight) (weight * scaled_factor);
 	    }
+
 	} else {
+            double sum = 0;
+	    for (j = left; j <= right; ++j)
+		sum += fproc(center - j);
 	    for (j = left; j <= right; ++j) {
-		double weight = fproc(center - j);
+		double weight = fproc(center - j) / sum;
 		int n = clamp_pixel(j);
 		int k = n - first_pixel;
 



More information about the gs-cvs mailing list