X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~yarrgweb/git?a=blobdiff_plain;ds=sidebyside;f=pctb%2Fstructure.c;h=f10addc56eed9c65f77ede4809407333a4ca780a;hb=9d525e44bd9642a72eb7acd81bd9956b014e3872;hp=e86f2c51d5bd92b067b62fb5c3ebda85141b61ef;hpb=c34d22ecb14a4436fa1e85394ec6f48a69c4a7a2;p=ypp-sc-tools.web-live.git diff --git a/pctb/structure.c b/pctb/structure.c index e86f2c5..f10addc 100644 --- a/pctb/structure.c +++ b/pctb/structure.c @@ -565,7 +565,7 @@ static inline Fixpt int2fixpt(int x) { return x<> 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; }