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 139180878012d92ae6b0589c19d262c370a02a21..c54f89a13c35aa3a4b8bc7ef4dda73b1bc665fb3 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,
   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) );
 
          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 &&
   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]); );
 
        MRGB(here);MRGB(background);MRGB(foreground);MI(fg_extra);
        MF(alpha_mean); MF(alpha[0]);MF(alpha[1]);MF(alpha[2]); );