summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Johnston <ray.johnston@artifex.com>2007-05-04 00:15:08 +0000
committerRay Johnston <ray.johnston@artifex.com>2007-05-04 00:15:08 +0000
commitbec365c371db175b341fa54afca01808d7ffd894 (patch)
tree30eda6cce3edb563e52bf1e471b9133c5581b79b
parent27a89c3da0b505ce4230f76e4fba53ccd4d366db (diff)
downloadghostpdl-bec365c371db175b341fa54afca01808d7ffd894.tar.gz
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). git-svn-id: http://svn.ghostscript.com/ghostscript/trunk@7897 a1074d23-0009-0410-80fe-cf8c14f379e6
-rw-r--r--gs/src/gxiscale.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/gs/src/gxiscale.c b/gs/src/gxiscale.c
index d0c554b29..66e4a280d 100644
--- a/gs/src/gxiscale.c
+++ b/gs/src/gxiscale.c
@@ -123,18 +123,25 @@ gs_image_class_0_interpolate(gx_image_enum * penum)
#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 */