tryng to really glitch my picz

This commit is contained in:
le vieux 2020-11-10 03:58:18 +01:00
parent 905c61628f
commit e7c726320a
6 changed files with 99 additions and 10 deletions

View File

@ -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 $@
# ---------------------------------------------------------

View File

@ -155,7 +155,7 @@ else {
fprintf(stderr, "\nelapsed %.2f seconds\n", fin);
}
return 8;
return 8; /* why 9 ? */
}
/* -------------------------------------------------------------- */
void help(void)

51
Fonderie/glitches.c Normal file
View File

@ -0,0 +1,51 @@
/*
* glitches.c
*/
#include <stdio.h>
#include <stdlib.h>
#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; xpos<pvictime->width; 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<number; idx++) {
foo = kill_a_random_line(who, fval, 0);
if (foo) abort();
}
return foo;
}
/* -------------------------------------------------------------- */

9
Fonderie/glitches.h Normal file
View File

@ -0,0 +1,9 @@
/*
* glitches.h
*/
int kill_a_random_line(FloatImg *pvictime, float level, int notused);
int kill_a_few_lines(FloatImg *who, float fval, int number);
/* this is a wtf file */

View File

@ -14,6 +14,7 @@
#include "../floatimg.h"
#include "glitches.h"
#include "crapulator.h"
// XXX #include "fonctions.h"
@ -24,7 +25,7 @@ int convert_to_gray; /* needed by fonctions.c */
/* -------------------------------------------------------------- */
int interpolator(char *pattern, char *outdir, int Nsteps)
{
FloatImg A, B, Out, *pFirst, *pSecond, *pTmp;
FloatImg A, B, Out, *pFirst, *pSecond;
glob_t globbuf;
int foo, idx, ipng, w, h, step;
int iarray[3];
@ -51,15 +52,13 @@ fimg_create(&A, w, h, 3); pFirst = &A;
fimg_create(&B, w, h, 3); pSecond = &B;
fimg_create(&Out, w, h, 3);
pTmp = NULL;
ipng = 0;
for (idx=0; idx<globbuf.gl_pathc; idx++) {
cptr = globbuf.gl_pathv[idx];
/* read the next file in B */
fprintf(stderr, "loading %s\n", cptr);
fprintf(stderr, "loading %s\r", cptr);
foo = fimg_load_from_dump(cptr, &B);
if (foo) {
fprintf(stderr, "load #%d from dump -> %d\n", idx, foo);
@ -68,7 +67,7 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
/* here, we can insert the input filter */
/* OK try it ... */
foo = crapulator(&B, 8, 1.0);
foo = crapulator(&B, 0, 256.7);
if (foo) {
fprintf(stderr, "crapulator failure %d\n", foo);
exit(1);
@ -79,6 +78,7 @@ for (idx=0; idx<globbuf.gl_pathc; idx++) {
fimg_interpolate(pSecond, pFirst, &Out, coef);
/* here we can insert the output filter */
kill_a_few_lines(&Out, 3.14159, 500);
sprintf(line, "%s/%05d.png", outdir, ipng);
foo = fimg_save_as_png(&Out, line, 0);
@ -106,15 +106,35 @@ fprintf(stderr, "generated %d png files\n", ipng);
return 0;
}
/* -------------------------------------------------------------- */
void help(void)
{
puts("\tINTERPOLATOR\noptions:");
/* may be we can make options incoherent, like
* the options of 'fonderie' software ?
*/
exit(0);
}
/* -------------------------------------------------------------- */
int main (int argc, char *argv[])
{
int foo;
int nbrsteps = 9;
int opt;
fprintf(stderr, "*** %s : compiled by tTh, %s %s\n", __FILE__,
__DATE__, __TIME__);
fimg_print_version(2);
while ((opt = getopt(argc, argv, "v")) != -1) {
switch(opt) {
case 'v': verbosity++; break;
}
}
/* TO BE CONTINUED *****/
if (4 != argc) {
fprintf(stderr, "args: <in globpattern> <out dir> <nbrsteep>\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;
}

View File

@ -4,6 +4,8 @@
#include <stdio.h>
#include "../floatimg.h"
extern int verbosity;
/* -------------------------------------------------------------- */