diff --git a/libvips/colour/sRGB2HSV.c b/libvips/colour/sRGB2HSV.c index e45aa155..7a3c3b39 100644 --- a/libvips/colour/sRGB2HSV.c +++ b/libvips/colour/sRGB2HSV.c @@ -58,36 +58,36 @@ vips_sRGB2HSV_line( VipsColour *colour, VipsPel *out, VipsPel **in, int width ) float wrap_around_hue, secondary_diff; - #define RED 255.0f; - #define GREEN 85.0f; - #define BLUE 170.0f; - for( i = 0; i < width; i++ ) { if (p[1] < p[2]) { if (p[2] < p[0]) { + // Center red (at top) c_max = p[0]; c_min = p[1]; secondary_diff = p[1] - p[2]; - wrap_around_hue = RED; + wrap_around_hue = 255.0f; } else { + // Center blue c_max = p[2]; c_min = VIPS_MIN(p[1], p[0]); secondary_diff = p[0] - p[1]; - wrap_around_hue = BLUE; + wrap_around_hue = 170.0f; } } else { if (p[1] < p[0]) { + // Center red (at bottom) c_max = p[0]; c_min = p[2]; secondary_diff = p[1] - p[2]; wrap_around_hue = 0.0f; } else { + // Center green c_max = p[1]; c_min = VIPS_MIN(p[2], p[0]); secondary_diff = p[2] - p[0]; - wrap_around_hue = GREEN; + wrap_around_hue = 85.0f; } }