X-Git-Url: http://git.imager.perl.org/imager.git/blobdiff_plain/efdc2568ee6be1b2922fd89f9d0d371ddcd7aec4..c4a2bc8f3300af1e525de187e18e49ed738a7cd8:/color.c diff --git a/color.c b/color.c index ab33bfc1..9c9d195b 100644 --- a/color.c +++ b/color.c @@ -1,4 +1,4 @@ -#include "image.h" +#include "imager.h" #include /* @@ -33,7 +33,7 @@ Each value is scaled into the range 0 to 1.0. =cut */ void i_rgb_to_hsvf(i_fcolor *color) { - double h, s, v; + double h = 0, s, v; double temp; double Cr, Cg, Cb; @@ -74,7 +74,7 @@ Each value is scaled into the range 0 to 255. =cut */ void i_rgb_to_hsv(i_color *color) { - double h, s, v; + double h = 0, s, v; double temp; double Cr, Cg, Cb; @@ -173,13 +173,14 @@ void i_hsv_to_rgb(i_color *color) { } else { int i; - double f, m, n, k; + double f; + int m, n, k; h = h / 255.0 * 6; i = h; f = h - i; - m = v * (255 - s) / 255; - n = v * (255 - s * f) / 255; - k = v * (255 - s * (1 - f)) / 255; + m = 0.5 + v * (255 - s) / 255; + n = 0.5 + v * (255 - s * f) / 255; + k = 0.5 + v * (255 - s * (1 - f)) / 255; switch (i) { case 0: color->rgb.r = v; color->rgb.g = k; color->rgb.b = m;