chiark / gitweb /
Laxer identification for subpixel antialiasing
authorIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 19 Jul 2009 15:54:32 +0000 (16:54 +0100)
committerIan Jackson <ian@liberator.relativity.greenend.org.uk>
Sun, 19 Jul 2009 16:33:50 +0000 (17:33 +0100)
pctb/structure.c
pctb/x.gdb

index e86f2c51d5bd92b067b62fb5c3ebda85141b61ef..f10addc56eed9c65f77ede4809407333a4ca780a 100644 (file)
@@ -565,7 +565,7 @@ static inline Fixpt int2fixpt(int x) { return x<<FIXPT_SHIFT; }
 static inline Fixpt dbl2fixpt(double x) { return x * int2fixpt(1); }
 static inline double fixpt2dbl(Fixpt x) { return x / (1.0*int2fixpt(1)); }
 static inline Fixpt fixpt_mul(Fixpt a, Fixpt b) {
-  return (a*b + dbl2fixpt(0.5)) >> FIXPT_SHIFT;
+  return (a*b + dbl2fixpt(0.5)) / int2fixpt(1);
 }
 #define MFP(v) fprintf(stderr," %s=%lx=%f", #v,(v),fixpt2dbl((v)))
 
@@ -609,22 +609,25 @@ static inline Fixpt find_aa_density(const RgbImage *ri, Point p) {
   Fixpt alpha_mean= fixpt_mul(alpha_total, one_third);
   
   Fixpt thresh= dbl2fixpt(1.5/AAMAXVAL);
-  Fixpt alpha_min= alpha_mean - thresh;
-  Fixpt alpha_max= alpha_mean + thresh;
+  Fixpt alpha_min= alpha_mean - thresh*2;
+  Fixpt alpha_max= alpha_mean + thresh*2;
 
   for (i=0; i<3; i++)
     MUST( alpha_min <= alpha[i] && alpha[i] <= alpha_max,
          MP(p);
          MRGB(here);MRGB(aa_background);MRGB(aa_foreground);
-         MFP(aa_alpha_mean_max);
-         MFP(alpha_min); MI(i);MFP(alpha[i]);MFP(alpha_max) );
+         MFP(aa_alpha_mean_max);MFP(thresh);MFP(alpha_mean);
+         MFP(alpha_min);MI(i);MFP(alpha[i]);MFP(alpha_max) );
 
-  MUST( 0 <= alpha_mean && alpha_mean <= aa_alpha_mean_max,
+  MUST( -thresh <= alpha_mean && alpha_mean <= aa_alpha_mean_max + thresh,
        MP(p);
        MRGB(here);MRGB(aa_background);MRGB(aa_foreground);
-       MFP(aa_alpha_mean_max);
+       MFP(aa_alpha_mean_max);MFP(thresh);
        MFP(alpha_mean); MFP(alpha[0]);MFP(alpha[1]);MFP(alpha[2]); );
 
+  if (alpha_mean < 0)                 alpha_mean= 0;
+  if (alpha_mean > aa_alpha_mean_max) alpha_mean= aa_alpha_mean_max;
+
   return alpha_mean;
 }
 
index 371162ba3712803b0d072b6a8ffa3f91b7ddd3c8..1133843a7d3d2b81a8b57e3565ca97b8a3364695 100644 (file)
@@ -1,5 +1,5 @@
 file ypp-commodities
-set args -Drect 2>u --edit-charset --raw-tsv --same >raw.tsv
-break structure.c:596 if here!=aa_background
+set args -Drect 2>u --edit-charset --find-island --ocean sage
+#break structure.c:596 if here!=aa_background
 break mustfail2
 run