[AD] bug in create_trans_table()

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


I committed the attached patch, fixing a bug that I introduced when I supposedly improved accuracy in create_trans_table() the other month.

The function has to interpolate between two colors, e.g.,

  r = (a*r0 + (1-a)*r1) / max

The problem was that the two terms were calculated separately as a*r0/max and (1-a)*r1/max, and then added. When I made the division be rounded, both terms were sometimes rounded upwards so summing them caused overflow. The new version is more robust because it postpones the division until after summing a*r0 and (1-a)*r1.

Sven



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/