Skip to content
Snippets Groups Projects
Commit 4095b411 authored by Og's avatar Og
Browse files

[fix] SDL IMAGE VIEWER FUCKKKKING WORKS git status git status

parent 18364a55
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ CC = gcc ...@@ -2,7 +2,7 @@ CC = gcc
CFLAGS = -std=gnu11 -Wall -Wextra -Wpedantic -Wwrite-strings -Walloc-zero -Wparentheses CFLAGS = -std=gnu11 -Wall -Wextra -Wpedantic -Wwrite-strings -Walloc-zero -Wparentheses
CFLAGS += -Wlarger-than=100000 -Wmissing-declarations -Wmissing-include-dirs -Wmissing-prototypes -Wformat-overflow=2 -Wunused-parameter CFLAGS += -Wlarger-than=100000 -Wmissing-declarations -Wmissing-include-dirs -Wmissing-prototypes -Wformat-overflow=2 -Wunused-parameter
CFLAGS += -g -pedantic -fsanitize=address -fsanitize=leak -fsanitize=undefined -Wdiscarded-qualifiers CFLAGS += -g -pedantic -fsanitize=address -fsanitize=leak -fsanitize=undefined -Wdiscarded-qualifiers
LDFLAGS = -lm LDFLAGS = -lm -lSDL2main -lSDL2_image -lSDL2
############# COMMAND HELP ############# ############# COMMAND HELP #############
...@@ -21,7 +21,7 @@ LDFLAGS = -lm ...@@ -21,7 +21,7 @@ LDFLAGS = -lm
PROG = Exe PROG = Exe
$(PROG): Matrix.o math_lib.o traitementPGM.o main.c $(PROG): Matrix.o math_lib.o traitementPGM.o gfx.o main.c
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS) $(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
math_lib.o: math_lib.c math_lib.o: math_lib.c
...@@ -33,6 +33,9 @@ Matrix.o: Matrix.c ...@@ -33,6 +33,9 @@ Matrix.o: Matrix.c
traitementPGM.o: traitementPGM.c traitementPGM.o: traitementPGM.c
$(CC) -c $^ $(CFLAGS) $(LDFLAGS) $(CC) -c $^ $(CFLAGS) $(LDFLAGS)
gfx.o: gfx.c
$(CC) -c $^ $(CFLAGS) $(LDFLAGS)
rapport: rapport.md rapport: rapport.md
pandoc -s $< -o $@.pdf --template eisvogel.latex --listings --pdf-engine pdflatex pandoc -s $< -o $@.pdf --template eisvogel.latex --listings --pdf-engine pdflatex
......
...@@ -45,6 +45,8 @@ void Convolution_filtrage() ...@@ -45,6 +45,8 @@ void Convolution_filtrage()
char output_image[] = "out.pgm"; char output_image[] = "out.pgm";
char output_convolve[] = "convolve.pgm"; char output_convolve[] = "convolve.pgm";
char sdl_name[] = "convolution";
pgm img; pgm img;
if (pgm_read_from_file(&img, filname) == -1) if (pgm_read_from_file(&img, filname) == -1)
{ {
...@@ -77,6 +79,8 @@ void Convolution_filtrage() ...@@ -77,6 +79,8 @@ void Convolution_filtrage()
normalise_matrix(&res.pixels, norm_min, norm_max, res.max); normalise_matrix(&res.pixels, norm_min, norm_max, res.max);
PrintImagePGM(res,sdl_name);
pgm_write_to_file(&res, output_convolve); pgm_write_to_file(&res, output_convolve);
matrix_free(&img.pixels); matrix_free(&img.pixels);
......
...@@ -48,4 +48,14 @@ void pgm_write_to_file(pgm *p, char *filename) ...@@ -48,4 +48,14 @@ void pgm_write_to_file(pgm *p, char *filename)
} }
fclose(f); fclose(f);
}
void PrintImagePGM(pgm img, char * filname)
{
printf("Image sélectionnée '%s' de taille %dx%d lumMax:%d\n", filname, img.pixels.col, img.pixels.row, img.max);
struct gfx_context_t *ImagePGM = initWindow(img.pixels.row, img.pixels.col, filname);
dessineTab2D(ImagePGM, img.pixels.data, img.pixels.col, img.pixels.row);
gfx_present(ImagePGM);
waitSpacePress();
gfx_destroy(ImagePGM);
} }
\ No newline at end of file
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "Matrix.h" #include "Matrix.h"
#include "math_lib.h" #include "math_lib.h"
#include "gfx.h"
typedef struct _pgm typedef struct _pgm
{ {
...@@ -12,5 +13,6 @@ typedef struct _pgm ...@@ -12,5 +13,6 @@ typedef struct _pgm
int32_t pgm_read_from_file(pgm *p, char *filename); int32_t pgm_read_from_file(pgm *p, char *filename);
void pgm_write_to_file(pgm *p, char *filename); void pgm_write_to_file(pgm *p, char *filename);
void PrintImagePGM(pgm img, char *filname);
#endif #endif
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment