aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ft_draw_scene.c5
-rw-r--r--src/ft_init_bmp.c46
-rw-r--r--src/ft_save_to_bmp.c9
3 files changed, 31 insertions, 29 deletions
diff --git a/src/ft_draw_scene.c b/src/ft_draw_scene.c
index 846c2fb..cbe002f 100644
--- a/src/ft_draw_scene.c
+++ b/src/ft_draw_scene.c
@@ -33,15 +33,12 @@ void
void
ft_draw_scene_bmp(t_cub *clist)
{
- t_bmp_file bmp_file;
-
clist->img.img = mlx_new_image(clist->wlist.wlx,
clist->wlist.x_size, clist->wlist.y_size);
clist->img.ptr = mlx_get_data_addr(clist->img.img, &clist->img.bpp,
&clist->img.sizeline, &clist->img.endian);
ft_castray(clist);
- ft_init_bmp(&bmp_file);
- if (ft_save_to_bmp(&bmp_file, clist->img.img, clist) < 0)
+ if (ft_save_to_bmp(clist->img.img, clist) < 0)
ft_error(FT_RET_BMP_ERR, FT_ERR_WR_BMP, clist);
mlx_destroy_image(clist->wlist.wlx, clist->img.img);
}
diff --git a/src/ft_init_bmp.c b/src/ft_init_bmp.c
index b123e52..e3fab01 100644
--- a/src/ft_init_bmp.c
+++ b/src/ft_init_bmp.c
@@ -14,8 +14,8 @@
#include <cub3d.h>
#include <stdint.h>
-static void
- ft_init_bmp_colors(t_bmp_colors *bmp_colors)
+t_bmp_colors
+ ft_init_bmp_colors(void)
{
bmp_colors->red_mask = 0x00ff0000;
bmp_colors->green_mask = 0x0000ff00;
@@ -25,30 +25,28 @@ static void
ft_bzero(bmp_colors, 16);
}
-static void
- ft_init_bmp_info(t_bmp_info *bmp_info)
+t_bmp_info
+ ft_init_bmp_info(void)
{
- bmp_info->size = 0;
- bmp_info->width = 0;
- bmp_info->height = 0;
- bmp_info->planes = 1;
- bmp_info->bit_count = 0;
- bmp_info->compression = 0;
- bmp_info->size_image = 0;
- bmp_info->x_pixels_per_meter = 0;
- bmp_info->y_pixels_per_meter = 0;
- bmp_info->colors_used = 0;
- bmp_info->colors_important = 0;
+ bmp_info.size = 0;
+ bmp_info.width = 0;
+ bmp_info.height = 0;
+ bmp_info.planes = 1;
+ bmp_info.bit_count = 0;
+ bmp_info.compression = 0;
+ bmp_info.size_image = 0;
+ bmp_info.x_pixels_per_meter = 0;
+ bmp_info.y_pixels_per_meter = 0;
+ bmp_info.colors_used = 0;
+ bmp_info.colors_important = 0;
}
-void
- ft_init_bmp(t_bmp_file *bmp_file)
+t_bmp_file
+ ft_init_bmp(void)
{
- bmp_file->file_type = 0x4d42;
- bmp_file->file_size = 0;
- bmp_file->reserv_one = 0;
- bmp_file->reserv_two = 0;
- bmp_file->offset_data = 0;
- ft_init_bmp_info(&bmp_file->bmp_info);
- ft_init_bmp_colors(&bmp_file->bmp_colors);
+ bmp_file.file_type = 0x4d42;
+ bmp_file.file_size = 0;
+ bmp_file.reserv_one = 0;
+ bmp_file.reserv_two = 0;
+ bmp_file.offset_data = 0;
}
diff --git a/src/ft_save_to_bmp.c b/src/ft_save_to_bmp.c
index 4bfaace..cb3fa9b 100644
--- a/src/ft_save_to_bmp.c
+++ b/src/ft_save_to_bmp.c
@@ -31,8 +31,15 @@ static int8_t
}
int8_t
- ft_save_to_bmp(t_bmp_file *bmp_file, void *img, t_cub *cl)
+ ft_save_to_bmp(void *img, t_cub *cl)
{
+ t_bmp_file bmp_file;
+ t_bmp_info bmp_info;
+ t_bmp_colors bmp_colors;
+
+ bmp_file = ft_init_bmp();
+ bmp_info = ft_init_bmp_info();
+ bmp_colors = ft_init_bmp_colors();
if (ft_convert_image_to_bmp(bmp_file, img, cl) < 0)
return (-1);
return (0);