From 4095b41164aebea3c07e57b0c1fb38ec03b5b3d6 Mon Sep 17 00:00:00 2001 From: Og <og@pop-os.localdomain> Date: Tue, 26 Apr 2022 23:08:04 +0200 Subject: [PATCH] [fix] SDL IMAGE VIEWER FUCKKKKING WORKS git status git status --- Makefile | 7 +++++-- main.c | 4 ++++ traitementPGM.c | 10 ++++++++++ traitementPGM.h | 2 ++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f566606..fbc3a24 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ CC = gcc 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 += -g -pedantic -fsanitize=address -fsanitize=leak -fsanitize=undefined -Wdiscarded-qualifiers -LDFLAGS = -lm +LDFLAGS = -lm -lSDL2main -lSDL2_image -lSDL2 ############# COMMAND HELP ############# @@ -21,7 +21,7 @@ LDFLAGS = -lm 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) math_lib.o: math_lib.c @@ -33,6 +33,9 @@ Matrix.o: Matrix.c traitementPGM.o: traitementPGM.c $(CC) -c $^ $(CFLAGS) $(LDFLAGS) +gfx.o: gfx.c + $(CC) -c $^ $(CFLAGS) $(LDFLAGS) + rapport: rapport.md pandoc -s $< -o $@.pdf --template eisvogel.latex --listings --pdf-engine pdflatex diff --git a/main.c b/main.c index 4164534..23bf911 100644 --- a/main.c +++ b/main.c @@ -45,6 +45,8 @@ void Convolution_filtrage() char output_image[] = "out.pgm"; char output_convolve[] = "convolve.pgm"; + char sdl_name[] = "convolution"; + pgm img; if (pgm_read_from_file(&img, filname) == -1) { @@ -77,6 +79,8 @@ void Convolution_filtrage() normalise_matrix(&res.pixels, norm_min, norm_max, res.max); + PrintImagePGM(res,sdl_name); + pgm_write_to_file(&res, output_convolve); matrix_free(&img.pixels); diff --git a/traitementPGM.c b/traitementPGM.c index f51db13..1c967b9 100755 --- a/traitementPGM.c +++ b/traitementPGM.c @@ -48,4 +48,14 @@ void pgm_write_to_file(pgm *p, char *filename) } 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 diff --git a/traitementPGM.h b/traitementPGM.h index 3cacb34..ff6c99c 100755 --- a/traitementPGM.h +++ b/traitementPGM.h @@ -3,6 +3,7 @@ #include "Matrix.h" #include "math_lib.h" +#include "gfx.h" typedef struct _pgm { @@ -12,5 +13,6 @@ typedef struct _pgm int32_t pgm_read_from_file(pgm *p, char *filename); void pgm_write_to_file(pgm *p, char *filename); +void PrintImagePGM(pgm img, char *filname); #endif \ No newline at end of file -- GitLab