Re: [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 ]


-   if (s == 0.0f) {
-      *r = *g = *b = (int)v;
+   if (s < FLT_EPSILON) {
+      *r = *g = *b = (int)(v+0.5f);

Strictly speaking, I think the threshold should be something like 1.0f/512.0f rather than FLT_EPSILON. The reason is, if saturation is smaller than 1/512, the difference between the greatest and smallest of the r,g,b components will be less than 0.5, i.e., less than the accuracy of the resulting int. Not that it matters in practice, of course, it will only improve speed (slightly) in 1/512 of the cases...

Sven





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