diff options
author | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-24 00:25:18 +0100 |
---|---|---|
committer | JozanLeClerc <bousset.rudy@gmail.com> | 2020-03-24 00:25:18 +0100 |
commit | a2dc982a92d8f1745831f0ded8e082c445030ff0 (patch) | |
tree | e1e79ff1bfb45959701f4ba548a8b5a988bd4f11 /src/ft_rgb_to_hex.c | |
parent | got work to do (diff) | |
download | 42-cub3d-a2dc982a92d8f1745831f0ded8e082c445030ff0.tar.gz 42-cub3d-a2dc982a92d8f1745831f0ded8e082c445030ff0.tar.bz2 42-cub3d-a2dc982a92d8f1745831f0ded8e082c445030ff0.tar.xz 42-cub3d-a2dc982a92d8f1745831f0ded8e082c445030ff0.tar.zst 42-cub3d-a2dc982a92d8f1745831f0ded8e082c445030ff0.zip |
Doesn't look too bad
Diffstat (limited to '')
-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); } |