From ac35780f4791c9188528ba61fa0b3f4b08bcb086 Mon Sep 17 00:00:00 2001 From: tth Date: Tue, 22 Sep 2020 00:43:21 +0200 Subject: [PATCH] first working version of "cumulfimgs" --- tools/cumulfimgs.c | 47 +++++++++++++++++++++++++++------------------- tools/essai.sh | 12 +++++++++++- 2 files changed, 39 insertions(+), 20 deletions(-) diff --git a/tools/cumulfimgs.c b/tools/cumulfimgs.c index 500dce6f..c89cd84f 100644 --- a/tools/cumulfimgs.c +++ b/tools/cumulfimgs.c @@ -1,3 +1,6 @@ +/* + * This thing is just a mess ! + */ #include #include #include @@ -21,58 +24,51 @@ if (foo) { return foo; } -fprintf(stderr, "\t\t%d x %d\n",numbers[0], numbers[1]); +fprintf(stderr, "%s \t%d x %d\n",path, numbers[0], numbers[1]); -if (3 != numbers[2]) { +if (FIMG_TYPE_RGB != numbers[2]) { fprintf(stderr, "file %s, %d : bad type\n", path, numbers[2]); return -7; } - - -return foo; +return 0; } /* --------------------------------------------------------------------- */ void help(int v) { -puts("options :"); +puts("cumulator options :"); puts("\t-v\tincrease verbosity"); puts("\t-o\tname of output file"); -puts("\t-s\tname of source file"); if (verbosity) { puts(""); fimg_print_version(1); } +exit(0); } /* --------------------------------------------------------------------- */ int main(int argc, char *argv[]) { int foo, idx; int opt; -char *output_file = "noname.fimg"; -char *source_file = "noname.fimg"; - +char *output_file = "out.fimg"; +FloatImg accu, temp; +int src_loaded = 0; g_width = g_height = 0; -while ((opt = getopt(argc, argv, "ho:s:v")) != -1) { +while ((opt = getopt(argc, argv, "ho:v")) != -1) { switch(opt) { case 'h': help(0); break; case 'o': output_file = optarg; break; - case 's': source_file = optarg; break; case 'v': verbosity++; break; } } +if (verbosity) fprintf(stderr, "------ cumulfimgs ------\n"); #if DEBUG_LEVEL fprintf(stderr, "argc = %d, optind = %d\n", argc, optind); #endif - -foo = testfile(source_file); -fprintf(stderr, "Source %s -> %d\n", source_file, foo); - -foo = testfile(output_file); -fprintf(stderr, "Output %s -> %d\n", output_file, foo); - +// foo = testfile(output_file); +// fprintf(stderr, "Output %s -> %d\n", output_file, foo); for (idx=optind; idx %d\n", argv[idx],foo); + if ( ! src_loaded ) { + foo = fimg_create_from_dump(argv[idx], &accu); + fimg_clone(&accu, &temp, 0); + src_loaded = 1; + } + else { + foo = fimg_load_from_dump(argv[idx], &temp); + fimg_add_2(&temp, &accu); + } + + } +foo = fimg_dump_to_file(&accu, output_file, 0); + return 0; } /* --------------------------------------------------------------------- */ diff --git a/tools/essai.sh b/tools/essai.sh index 3599b3a5..acd7d69f 100755 --- a/tools/essai.sh +++ b/tools/essai.sh @@ -30,7 +30,17 @@ function essai_cmixa } # ----------------------------------------------------- +function essai_cumulator +{ +D=" 800 600 " +./mkfimg -v -t hdeg hdeg.fimg $D +./mkfimg -v -t vdeg vdeg.fimg $D +./mkfimg -v -t drand48 rand.fimg $D -essai_cmixa +./cumulfimgs -vv -o foo.fimg hdeg.fimg rand.fimg vdeg.fimg +} +# ----------------------------------------------------- + +essai_cumulator # -----------------------------------------------------