aboutsummaryrefslogtreecommitdiffstats
path: root/src/ft_rgb_to_hex.c
diff options
context:
space:
mode:
authorRudy Bousset <rbousset@z2r5p6.le-101.fr>2020-03-07 20:30:07 +0100
committerRudy Bousset <rbousset@z2r5p6.le-101.fr>2020-03-07 20:30:07 +0100
commitced2be0469537a5d21043325c9bc54762197ec30 (patch)
tree0147b95e157bec2b301e82badc1532d40335201b /src/ft_rgb_to_hex.c
parentThe sky is nice (diff)
download42-cub3d-ced2be0469537a5d21043325c9bc54762197ec30.tar.gz
42-cub3d-ced2be0469537a5d21043325c9bc54762197ec30.tar.bz2
42-cub3d-ced2be0469537a5d21043325c9bc54762197ec30.tar.xz
42-cub3d-ced2be0469537a5d21043325c9bc54762197ec30.tar.zst
42-cub3d-ced2be0469537a5d21043325c9bc54762197ec30.zip
qwe
Diffstat (limited to '')
-rw-r--r--src/ft_rgb_to_hex.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/ft_rgb_to_hex.c b/src/ft_rgb_to_hex.c
index a25d3e0..e101dcf 100644
--- a/src/ft_rgb_to_hex.c
+++ b/src/ft_rgb_to_hex.c
@@ -18,6 +18,12 @@ uint32_t
{
uint32_t res;
+ rgb.r = (rgb.r > 255) ? (255) : (rgb.r);
+ rgb.g = (rgb.g > 255) ? (255) : (rgb.g);
+ rgb.b = (rgb.b > 255) ? (255) : (rgb.b);
+ rgb.r = (rgb.r < 0) ? (0) : (rgb.r);
+ rgb.g = (rgb.g < 0) ? (0) : (rgb.g);
+ rgb.b = (rgb.b < 0) ? (0) : (rgb.b);
res = 0;
res += ((rgb.r << 16) + (rgb.g << 8) + rgb.b);
return (res);