From 268a73ceb5cfed455f932a80502811569d7d5967 Mon Sep 17 00:00:00 2001 From: le vieux Date: Sat, 27 Feb 2021 10:56:42 +0100 Subject: [PATCH] enhancing the new tool --- install.sh | 2 +- tools/fimg2png.c | 3 ++- tools/fimg2text.c | 21 ++++++++++++--------- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/install.sh b/install.sh index 32c19a30..fbcaa142 100755 --- a/install.sh +++ b/install.sh @@ -6,7 +6,7 @@ cp floatimg.h /usr/local/include cp tools/mkfimg tools/fimg2pnm tools/fimgops \ tools/fimg2png tools/fimg2tiff tools/fimg2fits \ tools/png2fimg tools/fimgstats tools/fimgfx \ - tools/cumulfimgs \ + tools/cumulfimgs tools/fimg2text \ /usr/local/bin cp v4l2/grabvidseq v4l2/video-infos \ diff --git a/tools/fimg2png.c b/tools/fimg2png.c index 154fe537..d38a9aa1 100644 --- a/tools/fimg2png.c +++ b/tools/fimg2png.c @@ -88,8 +88,9 @@ if (2 != argc-optind) { } foo = convertir_fimg_en_PNG(argv[optind], argv[optind+1], to_gray); -if (foo) +if (foo) { fprintf(stderr, "%s : got a %d from convertor\n", argv[0], foo); + } return 0; } diff --git a/tools/fimg2text.c b/tools/fimg2text.c index 7108d8f4..18f1e1c8 100644 --- a/tools/fimg2text.c +++ b/tools/fimg2text.c @@ -12,7 +12,7 @@ int verbosity; /* ------------------------------------------------------------------------- */ -int export_as_machinable(FloatImg *src, char *fname, int flags) +int export_as_machinable(FloatImg *src, char *fname, int steps, int flags) { FILE *fp; int x, y, idx; @@ -32,11 +32,12 @@ if (strcmp("-", fname)) { /* real file */ idx = 0; fp = stdout; /* XXX */ -for (y=0; yheight; y++) { - for (x=0; xwidth; x++) { +for (y=0; yheight; y+=steps) { + for (x=0; xwidth; x+=steps) { - fprintf(fp, "%d %d %d ", x, y, idx); - fprintf(fp, " %f %f %f\n", src->R[idx], src->G[idx], src->B[idx]); + fprintf(fp, "%d %d ", x, y); + fprintf(fp, " %f %f %f\n", + src->R[idx], src->G[idx], src->B[idx]); idx++; } @@ -45,7 +46,7 @@ for (y=0; yheight; y++) { return 0; } /* ------------------------------------------------------------------------- */ -int convertir_fimg_en_machinable(char *srcname, char *dstname, int grisaille) +int convertir_fimg_en_machinable(char *srcname, char *dstname, int steps) { int foo, infos[3]; FloatImg fimg; @@ -78,7 +79,7 @@ if (verbosity) { fimg_describe(&fimg, srcname); } -foo = export_as_machinable(&fimg, dstname, 0); +foo = export_as_machinable(&fimg, dstname, steps, 0); fimg_destroy(&fimg); @@ -100,11 +101,13 @@ exit(0); int main(int argc, char *argv[]) { int foo, opt; +int steps = 16; -while ((opt = getopt(argc, argv, "ghv")) != -1) { +while ((opt = getopt(argc, argv, "hs:v")) != -1) { switch(opt) { case 'v': verbosity++; break; case 'h': help(1); exit(1); + case 's': steps = atoi(optarg); break; } } @@ -113,7 +116,7 @@ if (1 != argc-optind) { exit(1); } -foo = convertir_fimg_en_machinable(argv[optind], "-", 0); +foo = convertir_fimg_en_machinable(argv[optind], "-", steps); if (foo) fprintf(stderr, "%s : got a %d from convertor\n", argv[0], foo);