-
Notifications
You must be signed in to change notification settings - Fork 0
/
image.c
57 lines (51 loc) · 1.8 KB
/
image.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* image.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vvinogra <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/12/25 19:36:12 by vvinogra #+# #+# */
/* Updated: 2017/12/31 15:35:31 by vvinogra ### ########.fr */
/* */
/* ************************************************************************** */
#include "fractol.h"
void pixel_image_put(t_frac *frac)
{
int j;
if (frac->color_nb == 1)
color_1(frac);
if (frac->color_nb == 2)
color_2(frac);
if (frac->color_nb == 3)
color_3(frac);
if (frac->color_nb == 4)
color_4(frac);
if (frac->color_nb == 5)
color_5(frac);
if (frac->color_nb == 6)
color_6(frac);
if (frac->color_nb == 7)
color_7(frac);
if (frac->color_nb == 8)
color_8(frac);
if (frac->color_nb == 9)
color_9(frac);
j = 4 * (frac->y * WIN_WIDTH + frac->x);
frac->im->pic[j] = frac->rgb->b;
frac->im->pic[j + 1] = frac->rgb->g;
frac->im->pic[j + 2] = frac->rgb->r;
}
t_image *create_new_im(void *mlx)
{
t_image *im;
im = (t_image *)malloc(sizeof(t_image));
im->image = mlx_new_image(mlx, WIN_WIDTH, WIN_HEIGHT);
im->pic = mlx_get_data_addr(im->image, &im->bpp, &im->stride, &im->endian);
im->bpp /= 8;
return (im);
}
void image_clear(t_image *im)
{
ft_bzero(im->pic, WIN_WIDTH * WIN_HEIGHT * im->bpp);
}