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

ray at ghostscript.com ray at ghostscript.com
Thu May 3 17:15:09 PDT 2007


Author: ray
Date: 2007-05-03 17:15:08 -0700 (Thu, 03 May 2007)
New Revision: 7897

Modified:
   trunk/gs/src/gxiscale.c
Log:
Previous version was too aggresive with image interpolation to
1-bit per component (bpc) devices. Now we downsample using the
'special' image filter that prevents dropout on 1bpc devices and
use the "Mitchell" image filter for upscaling to those devices
when the scale factor (in X and Y) is at least 4:1. This prevents
upscaling on 1:1 images as well as near 1:1 where the results
would probably be poor quality.

EXPECTED DIFFERENCES:

148-11.ps	(baseline at thia time does not interpolate even
		 though the upscale factor is large and the image
		 from this update is closer to Adobe).


Modified: trunk/gs/src/gxiscale.c
===================================================================
--- trunk/gs/src/gxiscale.c	2007-05-03 15:13:26 UTC (rev 7896)
+++ trunk/gs/src/gxiscale.c	2007-05-04 00:15:08 UTC (rev 7897)
@@ -123,18 +123,25 @@
 #else
     template = &s_IIEncode_template;
 #endif
-    /* Special case handling for when we are downsampling to a dithered device	*/
-    /* The point of this non-linear downsampling is to preserve dark pixels	*/
-    /* from the source image to avoid dropout. The color polarity must be used	*/
-    if (((iss.WidthOut < iss.WidthIn) && (iss.HeightOut < iss.HeightIn)) &&
-	((penum->dev->color_info.num_components == 1 &&
+    if (((penum->dev->color_info.num_components == 1 &&
 	  penum->dev->color_info.max_gray < 15) ||
 	 (penum->dev->color_info.num_components > 1 &&
 	  penum->dev->color_info.max_color < 15))
 	) {
-	if (penum->dev->color_info.polarity == GX_CINFO_POLARITY_UNKNOWN)
-	    return 0;	/* can't do special downsampling to this color space */
-	template = &s_ISpecialDownScale_template;
+	/* halftone device -- restrict interpolation */
+	if ((iss.WidthOut < iss.WidthIn * 4) && (iss.HeightOut < iss.HeightIn * 4)) {
+	    if ((iss.WidthOut < iss.WidthIn) && (iss.HeightOut < iss.HeightIn) &&	/* downsampling */
+		(penum->dev->color_info.polarity != GX_CINFO_POLARITY_UNKNOWN)) {	/* colorspace OK */
+		/* Special case handling for when we are downsampling to a dithered device	*/
+		/* The point of this non-linear downsampling is to preserve dark pixels		*/
+		/* from the source image to avoid dropout. The color polarity is used for this	*/
+		template = &s_ISpecialDownScale_template;
+	    } else {
+		penum->interpolate = false;
+		return 0;	/* no interpolation / downsampling */
+	    }
+	}
+	/* else, continue with the Mitchell filter (for upscaling of at least 4:1) */
     }
     /* The SpecialDownScale filter needs polarity, either ADDITIVE or SUBTRACTIVE */
     /* UNKNOWN case (such as for palette colors) has been handled above */



More information about the gs-cvs mailing list