From 11c457aa81eada1b45c52f9870b2cb02f0296e6c Mon Sep 17 00:00:00 2001 From: tonton th Date: Tue, 1 Dec 2020 13:10:27 +0100 Subject: [PATCH] is trinarize ready ? --- Fonderie/Makefile | 4 ++-- Fonderie/sfx.c | 24 ++++++++++++++++++++---- Fonderie/t.c | 21 +++++++++++++++++---- 3 files changed, 39 insertions(+), 10 deletions(-) diff --git a/Fonderie/Makefile b/Fonderie/Makefile index a28bfb8..652da51 100644 --- a/Fonderie/Makefile +++ b/Fonderie/Makefile @@ -13,8 +13,8 @@ all: fonderie interpolator t # --------------------------------------------------------- -t: t.c Makefile glitches.o - gcc ${COPT} $< glitches.o ${LIBS} -lz -o $@ +t: t.c Makefile glitches.o sfx.o + gcc ${COPT} $< glitches.o sfx.o ${LIBS} -lz -o $@ # --------------------------------------------------------- diff --git a/Fonderie/sfx.c b/Fonderie/sfx.c index 90e8a7c..274fd98 100644 --- a/Fonderie/sfx.c +++ b/Fonderie/sfx.c @@ -55,6 +55,7 @@ return 0; int trinarize(FloatImg *pimg, int notused) { float mm[6], mRa, mGa, mBa, mRb, mGb, mBb; +float val, *fptr; int foo, size; #if DEBUG_LEVEL @@ -71,15 +72,30 @@ mBb = (mm[5] - mm[4]) * 0.66666; size = pimg->width * pimg->height; +#define VAL (255.0) + for (foo=0; fooR; + if (fptr[foo] < mRa || fptr[foo] > mRb) + fptr[foo] = 0.0; + else + fptr[foo] = VAL; + + fptr = pimg->G; + if (fptr[foo] < mGa || fptr[foo] > mGb) + fptr[foo] = 0.0; + else + fptr[foo] = VAL; + + fptr = pimg->B; + if (fptr[foo] < mBa || fptr[foo] > mBb) + fptr[foo] = 0.0; + else + fptr[foo] = VAL; } -fprintf(stderr, "the function '%s' is not implemented\n", __func__); -exit(2); - return -1; } /* -------------------------------------------------------------- */ diff --git a/Fonderie/t.c b/Fonderie/t.c index 6f1f9e4..6305381 100644 --- a/Fonderie/t.c +++ b/Fonderie/t.c @@ -19,6 +19,9 @@ int verbosity; #define LMAX 233.333 #define TIMER 1 + +int trinarize(FloatImg *pimg, int notused); // in sfx.c + int main(int argc, char *argv[]) { int foo, iter, xloc, bloub; @@ -42,11 +45,11 @@ fimg_printhead(&image); srand(getpid()); debut = fimg_timer_set(TIMER); -for (iter=0; iter<127; iter++) { +for (iter=0; iter<16; iter++) { fimg_vdeg_a(&image, LMAX); - for (bloub=0; bloub<7; bloub++) { + for (bloub=0; bloub<16; bloub++) { xloc = rand() % W; omega = (float)(0.1 + drand48()*0.6) * 0.4; foo = vertical_singlitch(&image, xloc, LMAX, @@ -54,12 +57,22 @@ for (iter=0; iter<127; iter++) { if (foo) abort(); } - sprintf(buff, "/tmp/out%03d.png", iter); + sprintf(buff, "/tmp/out_a%03d.png", iter); foo = fimg_save_as_png(&image, buff, 0); if (foo) { - fprintf(stderr, "err %d saving to '%s'\n", foo, PNG); + fprintf(stderr, "err %d saving to '%s'\n", foo, buff); exit(1); } + + foo = trinarize(&image, 0); /* XXX */ + + sprintf(buff, "/tmp/out_b%03d.png", iter); + foo = fimg_save_as_png(&image, buff, 0); + if (foo) { + fprintf(stderr, "err %d saving to '%s'\n", foo, buff); + exit(1); + } + } fin = fimg_timer_set(TIMER);