[AD] Small bugfix in hsv_to_rgb() and smaller fix in rgb_to_hsv()

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


Here is a patch for colour.c that fixes a small bug I discovered in
hsv_to_rgb(). This bug existed before I submitied the changes to
hsv_to_rgb() but propagated it's way into my optimised code I submitted.
When rounding values of V to the nearest 1/255, the patch makes the V value
round to the nearest whole fraction instead of truncating to the lower
fraction like it used to. The patched code will return the same value for
HSV values that have come straight from rgb_to_hsv(), but when V is a
computed value, it will better make use of the numerical range 0-255
(before, when a colour-value was set to be equal to V*255.0f, the value 255
would only result if V was 1.0. Now, 255 results if V>=509/510).

The patch is against the version of colour.c that was in the
allegro_20030531.zip snapshot on CVS.

Also, this patch replaces all occurences in hsv_to_rgb() and rgb_to_hsv() of
"== 0.0f" with "<FLT_EPSILON" (this requires float.h to be #included).

BTW, Was the improved exrgbhsv.c I submitted a month or so ago approved? I
still see the old version in the latest snapshot.

AE.

Attachment: color.c.diff
Description: Binary data



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