[gs-commits] rev 11859 - trunk/gs/base

robin at ghostscript.com robin at ghostscript.com
Tue Oct 26 23:54:13 UTC 2010


Author: robin
Date: 2010-10-26 23:54:13 +0000 (Tue, 26 Oct 2010)
New Revision: 11859

Modified:
   trunk/gs/base/gxclimag.c
Log:
Fix bug reported by Norbert Janssen. Inaccuracies in the floating point maths
can cause 'no-scales' to look like 'downscales', and so high level images are
skipped.

This shouldn't actually matter in most cases as the two rendering paths should
give the same results, but when people hook the clist for their own purposes
this can cause problems. The workaround is to introduce a fudge factor and to
accept very slight downscales.

Thanks to Norbert for the first version of this patch.

Minimal differences in cluster testing due to bug 691697.




Modified: trunk/gs/base/gxclimag.c
===================================================================
--- trunk/gs/base/gxclimag.c	2010-10-26 20:30:32 UTC (rev 11858)
+++ trunk/gs/base/gxclimag.c	2010-10-26 23:54:13 UTC (rev 11859)
@@ -295,19 +295,24 @@
 image_matrix_ok_to_band(const gs_matrix * pmat)
 {
     double t;
+    /* Detecting a downscale when it's really noscale upsets some
+     * customers code, so we add a fudge factor in here. This may
+     * cause us to allow the use of high level images for some downscales
+     * that are *nearly* noscales, but our code will cope with that. */
+    float one = (float)(1.0 - 1e-5);
 
     /* Don't band if the matrix is (nearly) singular. */
     if (fabs(pmat->xx * pmat->yy - pmat->xy * pmat->yx) < 0.001)
         return false;
     /* If it's portrait, then we encode it if not a downscale */
     if (is_xxyy(pmat))
-        return (fabs(pmat->xx) >= 1) && (fabs(pmat->yy) >= 1);
+        return (fabs(pmat->xx) >= one) && (fabs(pmat->yy) >= one);
     /* If it's landscape, then we encode it if not a downscale */
     if (is_xyyx(pmat))
-        return (fabs(pmat->xy) >= 1) && (fabs(pmat->yx) >= 1);
+        return (fabs(pmat->xy) >= one) && (fabs(pmat->yx) >= one);
     /* Skewed, so do more expensive downscale test */
-    if ((pmat->xx * pmat->xx + pmat->xy * pmat->xy < 1.0) ||
-        (pmat->yx * pmat->yx + pmat->yy * pmat->yy < 1.0))
+    if ((pmat->xx * pmat->xx + pmat->xy * pmat->xy < one) ||
+        (pmat->yx * pmat->yx + pmat->yy * pmat->yy < one))
         return false;
     /* Otherwise only encode it if it doesn't rotate too much */
     t = (fabs(pmat->xx) + fabs(pmat->yy)) /



More information about the gs-commits mailing list