From a2dc982a92d8f1745831f0ded8e082c445030ff0 Mon Sep 17 00:00:00 2001 From: JozanLeClerc Date: Tue, 24 Mar 2020 00:25:18 +0100 Subject: Doesn't look too bad --- src/ft_rgb_to_hex.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/ft_rgb_to_hex.c') diff --git a/src/ft_rgb_to_hex.c b/src/ft_rgb_to_hex.c index 2b72287..2ef1862 100644 --- a/src/ft_rgb_to_hex.c +++ b/src/ft_rgb_to_hex.c @@ -29,7 +29,10 @@ uint32_t rgb.g = (rgb.g < 0) ? (0) : (rgb.g); rgb.b = (rgb.b < 0) ? (0) : (rgb.b); res = 0; - res += (((uint8_t)(rgb.r / calc) << 16) + ((uint8_t)(rgb.g / calc) << 8) - + (uint8_t)(rgb.b / calc)); + if (calc <= 1) + res += ((rgb.r << 16) + (rgb.g << 8) + rgb.b); + else + res += (((uint8_t)(rgb.r / calc) << 16) + ((uint8_t)(rgb.g / calc) << 8) + + (uint8_t)(rgb.b / calc)); return (res); } -- cgit v1.2.3