chiark / gitweb /
fixes to find_aa_density: MUST failures print p, deal with rounding problems in alpha...
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 5 Jul 2009 18:10:50 +0000 (19:10 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 5 Jul 2009 18:10:50 +0000 (19:10 +0100)
pctb/structure.c

index 1391808..c54f89a 100644 (file)
@@ -486,11 +486,16 @@ static double find_aa_density(const RgbImage *ri, Point p, long background,
   double alpha_max= alpha_mean + thresh;
   for (i=0; i<3; i++)
     MUST( alpha_min <= alpha[i] && alpha[i] <= alpha_max,
+         MP(p);
          MRGB(here);MRGB(background);MRGB(foreground);MI(fg_extra);
          MF(alpha_min); MI(i);MF(alpha[i]);MF(alpha_max) );
 
+  if (   -1e-5 <  alpha_mean && alpha_mean <= 0.0     ) alpha_mean= 0.0;
+  if (1.0      <= alpha_mean && alpha_mean <= 1.0+1e-5) alpha_mean= 1.0;
+
   MUST( 0 <= alpha_mean &&
-       (fg_extra ? alpha_mean < 0.999 : alpha_mean >= 1.0),
+       (fg_extra ? (alpha_mean < 0.999) : (alpha_mean <= 1.0)),
+       MP(p);
        MRGB(here);MRGB(background);MRGB(foreground);MI(fg_extra);
        MF(alpha_mean); MF(alpha[0]);MF(alpha[1]);MF(alpha[2]); );