FloatImg/Fonderie/t.c

138 lines
2.7 KiB
C

/*
* test des trucs
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "../floatimg.h"
#include "glitches.h"
#include "sfx.h"
#include "filterstack.h"
#include "crapulator.h"
/* ----------------------------------------------------------- */
int verbosity;
int convert_to_gray; /* WTF ? */
#define PNG "out.png"
#define W 800
#define H 600
#define LMAX 255.0
#define TIMER 1
#define STK 6
/* ----------------------------------------------------------- */
int essai_filterstack(char *fIname, char *fOname)
{
int foo;
FloatImg image;
double debut, fin;
// filterstack_list(STK, __func__);
foo = fimg_create_from_dump(fIname, &image);
if (foo) {
fprintf(stderr, "err %d create image\n", foo);
exit(1);
}
srand(getpid()); srand48(getpid());
debut = fimg_timer_set(TIMER);
foo = filterstack_run(STK, &image, 0);
if (foo) {
fprintf(stderr, "filterstack run --> %d\n", foo);
return foo;
}
fin = fimg_timer_set(TIMER);
foo = fimg_export_picture(&image, fOname, 0);
if (foo) {
fprintf(stderr, "erreur export %d\n", foo);
}
fprintf(stderr, "elapsed %f\n", fin-debut);
fimg_destroy(&image);
return 0;
}
/* ----------------------------------------------------------- */
int help(void)
{
puts("yolo!");
exit(0);
}
/* ----------------------------------------------------------- */
void experiment(void)
{
int foo;
fprintf(stderr, "EXPERIMENT\n");
list_crapulors("experiment");
#if 0
foo = crap_number_from_name("cos01");
fprintf(stderr, "name cos01 -> %d\n", foo);
foo = crap_number_from_name("xxxxx");
fprintf(stderr, "name xxxxx -> %d\n", foo);
#endif
exit(0); /* back to real world */
}
/* ----------------------------------------------------------- */
int main(int argc, char *argv[])
{
int foo;
int opt;
char *filterchain = "0";
char *infile = "mire.fimg";
char *outfile = "out.png";
fprintf(stderr, "*** %s : compiled by tTh, %s %s\n", __FILE__,
__DATE__, __TIME__);
fimg_print_version(2);
while ((opt = getopt(argc, argv, "hF:i:o:vx")) != -1) {
switch(opt) {
case 'h': help(); break;
case 'F': filterchain = optarg; break;
case 'i': infile = optarg; break;
case 'o': outfile = optarg; break;
case 'v': verbosity++; break;
case 'x': experiment(); break;
default: exit(1);
}
}
#if DEBUG_LEVEL
fprintf(stderr, "%s : argc = %d, optind = %d\n", argv[0], argc, optind);
#endif
foo = parse_filter_chain(STK, filterchain);
if (foo) {
fprintf(stderr, "err %d in parse_filter_chain\n", foo);
exit(1);
}
foo = essai_filterstack(infile, outfile);
if (foo) {
fprintf(stderr, "err %d in essai_filterstack\n", foo);
exit(1);
}
return 0;
}
/* ----------------------------------------------------------- */