FloatImg/Fonderie/t.c

98 lines
1.7 KiB
C
Raw Normal View History

2020-11-16 07:31:02 +11:00
/*
* test des trucs
*/
#include <stdio.h>
#include <stdlib.h>
2020-11-16 21:12:29 +11:00
#include <unistd.h>
2020-11-16 07:31:02 +11:00
#include "../floatimg.h"
#include "glitches.h"
2020-12-03 05:24:54 +11:00
#include "sfx.h"
2020-12-04 07:56:45 +11:00
#include "filterstack.h"
2020-11-16 07:31:02 +11:00
/* ----------------------------------------------------------- */
int verbosity;
2020-12-04 07:56:45 +11:00
int convert_to_gray; /* WTF ? */
2020-11-16 07:31:02 +11:00
#define PNG "out.png"
2020-11-26 00:38:39 +11:00
#define W 512
2020-12-03 05:24:54 +11:00
#define H 256
#define LMAX 249.9999
2020-11-16 07:31:02 +11:00
#define TIMER 1
2020-12-04 07:56:45 +11:00
/* ----------------------------------------------------------- */
int essai_filterstack(FloatImg *pimg)
{
int foo;
foo = filterstack_init(4);
if (foo) {
fprintf(stderr, "filterstack init --> %d\n", foo);
return foo;
}
foo = filterstack_add(5, 1, 1.0);
if (foo) {
fprintf(stderr, "filterstack add 1 --> %d\n", foo);
return foo;
}
foo = filterstack_add(13, 1, 1.0);
if (foo) {
fprintf(stderr, "filterstack add 2 --> %d\n", foo);
return foo;
}
filterstack_list();
foo = filterstack_run(pimg, 0);
if (foo) {
fprintf(stderr, "filterstack run --> %d\n", foo);
return foo;
}
return 0;
}
/* ----------------------------------------------------------- */
2020-11-16 07:31:02 +11:00
int main(int argc, char *argv[])
{
2020-12-04 07:56:45 +11:00
int foo;
2020-11-16 07:31:02 +11:00
FloatImg image;
double debut, fin;
2020-11-26 00:38:39 +11:00
verbosity = 2;
2020-11-16 07:31:02 +11:00
fimg_print_version(1);
foo = fimg_create(&image, W, H, FIMG_TYPE_RGB);
if (foo) {
fprintf(stderr, "err %d create image\n", foo);
exit(1);
}
2020-12-04 07:56:45 +11:00
fimg_vdeg_a(&image, 255);
2020-11-26 00:38:39 +11:00
2020-11-16 21:12:29 +11:00
srand(getpid());
2020-11-16 07:31:02 +11:00
debut = fimg_timer_set(TIMER);
2020-12-04 07:56:45 +11:00
foo = essai_filterstack(&image);
if (foo) {
fprintf(stderr, "essai filterstack --> %d\n", foo);
}
fin = fimg_timer_set(TIMER);
2020-11-16 07:31:02 +11:00
2020-12-04 07:56:45 +11:00
foo = fimg_save_as_png(&image, "foo.png", 0);
if (foo) {
fprintf(stderr, "erreur export %d\n", foo);
2020-11-16 07:31:02 +11:00
}
fprintf(stderr, "elapsed %f\n", fin-debut);
2020-11-26 00:38:39 +11:00
fimg_destroy(&image);
2020-11-16 07:31:02 +11:00
return 0;
}
/* ----------------------------------------------------------- */