Browse Source

is trinarize ready ?

master
tonton th 2 years ago
parent
commit
11c457aa81
  1. 4
      Fonderie/Makefile
  2. 24
      Fonderie/sfx.c
  3. 21
      Fonderie/t.c

4
Fonderie/Makefile

@ -13,8 +13,8 @@ all: fonderie interpolator t @@ -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 $@
# ---------------------------------------------------------

24
Fonderie/sfx.c

@ -55,6 +55,7 @@ return 0; @@ -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,14 +72,29 @@ mBb = (mm[5] - mm[4]) * 0.66666; @@ -71,14 +72,29 @@ mBb = (mm[5] - mm[4]) * 0.66666;
size = pimg->width * pimg->height;
#define VAL (255.0)
for (foo=0; foo<size; foo++) {
; // XXX
fptr = pimg->R;
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;
fprintf(stderr, "the function '%s' is not implemented\n", __func__);
exit(2);
fptr = pimg->B;
if (fptr[foo] < mBa || fptr[foo] > mBb)
fptr[foo] = 0.0;
else
fptr[foo] = VAL;
}
return -1;
}

21
Fonderie/t.c

@ -19,6 +19,9 @@ int verbosity; @@ -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); @@ -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++) { @@ -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);

Loading…
Cancel
Save