From f0a433874109e0e3ed308f567cf05bd3bb585950 Mon Sep 17 00:00:00 2001 From: tth Date: Mon, 5 Apr 2021 19:20:36 +0200 Subject: [PATCH] + halfsize --- .gitignore | 1 + tools/Makefile | 6 +++- tools/fimghalfsize.c | 77 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 tools/fimghalfsize.c diff --git a/.gitignore b/.gitignore index a7aefbda..7a5b7cb1 100644 --- a/.gitignore +++ b/.gitignore @@ -55,6 +55,7 @@ tools/fimg2tiff tools/fimg2fits tools/fimg2text tools/fimgstats +tools/fimghalfsize tools/mkfimg tools/png2fimg tools/addtga2fimg diff --git a/tools/Makefile b/tools/Makefile index b0870678..53b2985d 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -10,7 +10,8 @@ DEPS = ../floatimg.h ../libfloatimg.a Makefile all: fimg2pnm mkfimg png2fimg fimgstats fimg2png \ fimg2tiff fimg2text fimg2fits \ - addpnm2fimg cumulfimgs fimgops fimgfx + addpnm2fimg cumulfimgs fimgops fimgfx \ + fimghalfsize fimgstats: fimgstats.c $(DEPS) gcc $(COPT) $< ../libfloatimg.a -o $@ @@ -27,6 +28,9 @@ fimgops: fimgops.c $(DEPS) fimgfx: fimgfx.c $(DEPS) gcc $(COPT) $< ../libfloatimg.a -o $@ +fimghalfsize: fimghalfsize.c $(DEPS) + gcc $(COPT) $< ../libfloatimg.a -o $@ + fimg2pnm: fimg2pnm.c $(DEPS) gcc $(COPT) $< ../libfloatimg.a -o $@ diff --git a/tools/fimghalfsize.c b/tools/fimghalfsize.c new file mode 100644 index 00000000..b522778c --- /dev/null +++ b/tools/fimghalfsize.c @@ -0,0 +1,77 @@ +/* +*/ + +#include +#include /* pour getopt */ +#include + +#include "../floatimg.h" + +int verbosity; + +/* ------------------------------------------------------------- */ +int faire_un_halfsize(char *iname, char *oname, int notused) +{ +FloatImg src, dst; +int foo; + +foo = fimg_create_from_dump(iname, &src); +if (foo) { + fprintf(stderr, "create fimg from '%s' -> %d\n", iname, foo); + return -1; + } + +memset(&dst, 0, sizeof(FloatImg)); +foo = fimg_halfsize_0(&src, &dst, 0); +if (foo) { + fprintf(stderr, "halfize fail -> %d\n", foo); + return -1; + } + +foo = fimg_dump_to_file(&dst, oname, 0); +if (foo) { + fprintf(stderr, "save to '%s' -> %d\n", oname, foo); + return -1; + } + +return -1; +} + +/* ------------------------------------------------------------- */ +void help(int u) +{ + +} +/* ------------------------------------------------------------- */ + +int main(int argc, char *argv[]) +{ +int foo, opt, action; + +char *srcname = ""; +char *dstname = "out.fimg"; + +while ((opt = getopt(argc, argv, "hv")) != -1) { + switch(opt) { + case 'h': help(0); break; + case 'v': verbosity++; break; + } + } + +if (2 != argc-optind) { + fprintf(stderr, "error: %s need two filenames\n", argv[0]); + exit(1); + } + +srcname = argv[optind]; +dstname = argv[optind+1]; + +fprintf(stderr, "%s: optind: %d src: %s dst: %s\n", argv[0], optind, + srcname, dstname); + +foo = faire_un_halfsize(srcname, dstname, 0); + + +return 0; +} +/* ------------------------------------------------------------- */