diff options
Diffstat (limited to 'src/ft_rgb_to_hex.c')
-rw-r--r-- | src/ft_rgb_to_hex.c | 7 |
1 files changed, 5 insertions, 2 deletions
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); } |