-
Notifications
You must be signed in to change notification settings - Fork 0
/
draw.c
34 lines (31 loc) · 1.43 KB
/
draw.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* draw.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mlegendr <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/11/24 14:48:54 by mlegendr #+# #+# */
/* Updated: 2015/11/24 14:49:42 by mlegendr ### ########.fr */
/* */
/* ************************************************************************** */
#include <mlx.h>
#include "rt.h"
void adapt_pixel_in_image(t_win *win, int color, int x, int y)
{
unsigned int stock;
unsigned char red;
unsigned char green;
unsigned char blue;
int value;
value = y * win->img.sl + x * (win->img.bpp >> 3);
if (y < 0 || x < 0 || y >= win->height || x >= win->width)
return ;
stock = mlx_get_color_value(win->mlx, color);
red = ((stock & 0xFF0000) >> 16);
green = ((stock & 0xFF00) >> 8);
blue = (stock & 0xFF);
(win->img.data)[value] = blue;
(win->img.data)[value + 1] = green;
(win->img.data)[value + 2] = red;
}