From e7c726320a73afe72c0422d1d60fdf4affdd9842 Mon Sep 17 00:00:00 2001 From: le vieux Date: Tue, 10 Nov 2020 03:58:18 +0100 Subject: [PATCH] tryng to really glitch my picz --- Fonderie/Makefile | 13 ++++++++--- Fonderie/fonderie.c | 2 +- Fonderie/glitches.c | 51 +++++++++++++++++++++++++++++++++++++++++ Fonderie/glitches.h | 9 ++++++++ Fonderie/interpolator.c | 32 +++++++++++++++++++++----- Fonderie/metriques.c | 2 ++ 6 files changed, 99 insertions(+), 10 deletions(-) create mode 100644 Fonderie/glitches.c create mode 100644 Fonderie/glitches.h diff --git a/Fonderie/Makefile b/Fonderie/Makefile index a6079de..5ac2f87 100644 --- a/Fonderie/Makefile +++ b/Fonderie/Makefile @@ -4,8 +4,9 @@ COPT = -g -no-pie -Wall -DDEBUG_LEVEL=0 -Werror=parentheses LIBS = -lfloatimg -lpnglite -lm -OBJS = fonctions.o sfx.o crapulator.o -DEPS = fonctions.h crapulator.h + +OBJS = fonctions.o sfx.o crapulator.o glitches.o metriques.o +DEPS = fonctions.h crapulator.h metriques.h glitches.h all: fonderie interpolator @@ -29,7 +30,13 @@ sfx.o: sfx.c ${DEPS} Makefile # another way to brotch some pics... # -interpolator: interpolator.c ${OBJS} Makefile +metriques.o: metriques.[hc] Makefile + gcc ${COPT} -c $< + +glitches.o: glitches.[hc] Makefile + gcc ${COPT} -c $< + +interpolator: interpolator.c ${OBJS} Makefile gcc ${COPT} $< ${OBJS} ${LIBS} -lz -o $@ # --------------------------------------------------------- diff --git a/Fonderie/fonderie.c b/Fonderie/fonderie.c index fb316e0..4debfee 100644 --- a/Fonderie/fonderie.c +++ b/Fonderie/fonderie.c @@ -155,7 +155,7 @@ else { fprintf(stderr, "\nelapsed %.2f seconds\n", fin); } -return 8; +return 8; /* why 9 ? */ } /* -------------------------------------------------------------- */ void help(void) diff --git a/Fonderie/glitches.c b/Fonderie/glitches.c new file mode 100644 index 0000000..a99d18d --- /dev/null +++ b/Fonderie/glitches.c @@ -0,0 +1,51 @@ +/* + * glitches.c + */ + +#include +#include + +#include "../floatimg.h" + +extern int verbosity; + +/* -------------------------------------------------------------- */ +int kill_a_random_line(FloatImg *pvictime, float fval, int notused) +{ +int line, xpos, offset; + +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( %p %d )\n", __func__, pvictime, notused); +#endif + +line = rand() % pvictime->height; + +if (verbosity > 1) { + fprintf(stderr, "%s: try to kill line %d\n", __func__, line); + } + +offset = pvictime->width * line; + +for (xpos=offset; xposwidth; xpos++) { + pvictime->R[offset] = fval; + pvictime->G[offset] = 0.0; + pvictime->B[offset] = fval; + } + +return 0; +} +/* -------------------------------------------------------------- */ +int kill_a_few_lines(FloatImg *who, float fval, int number) +{ +int idx, foo; + +/* Frag the pixels */ +for (idx=0; idx %d\n", idx, foo); @@ -68,7 +67,7 @@ for (idx=0; idx \n"); exit(1); @@ -124,7 +144,7 @@ nbrsteps = atoi(argv[3]); foo = interpolator(argv[1], argv[2], nbrsteps); -fprintf(stderr, "interpolator -> %d\n", foo); +fprintf(stderr, "interpolator give a %d score\n", foo); return 0; } diff --git a/Fonderie/metriques.c b/Fonderie/metriques.c index d878b0c..df03ae4 100644 --- a/Fonderie/metriques.c +++ b/Fonderie/metriques.c @@ -4,6 +4,8 @@ #include +#include "../floatimg.h" + extern int verbosity; /* -------------------------------------------------------------- */