From c7d7c8b2ddb9a7d9d767835e95e689982f03f2a0 Mon Sep 17 00:00:00 2001 From: Tonton Th Date: Sat, 29 Jun 2019 23:50:03 +0200 Subject: [PATCH] tryint that thing for the ravebish --- .gitignore | 1 + lib/t.c | 27 +++++++++++++ tools/Makefile | 7 +++- tools/addpnm2fimg.c | 94 +++++++++++++++++++++++++++++++++++++++++++++ tools/png2fimg.c | 2 + 5 files changed, 130 insertions(+), 1 deletion(-) create mode 100644 lib/t.c create mode 100644 tools/addpnm2fimg.c diff --git a/.gitignore b/.gitignore index c3133b6..bd98bfa 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ lib/*.o +lib/t funcs/*.o *.a diff --git a/lib/t.c b/lib/t.c new file mode 100644 index 0000000..d573950 --- /dev/null +++ b/lib/t.c @@ -0,0 +1,27 @@ +#include +#include +#include +#include "string.h" + +#include "../floatimg.h" + +int verbosity; + + +int main(int argc, char *argv[]) +{ +int foo; +FloatImg fimg; + +verbosity = 1; + +foo = fimg_load_from_pnm("/tmp/00000.ppm", &fimg, 0); + +printf("retour du truc %d\n", foo); + +fimg_printhead(&fimg); + +fimg_save_as_pnm(&fimg, "foo.pnm", 0); + +return 0; +} \ No newline at end of file diff --git a/tools/Makefile b/tools/Makefile index 63cb07c..5b94864 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -8,7 +8,8 @@ DEPS = ../floatimg.h ../libfloatimg.a Makefile # ---------- -all: fimg2pnm addtga2fimg mkfimg png2fimg fimgstats fimg2png +all: fimg2pnm addtga2fimg mkfimg png2fimg fimgstats fimg2png \ + addpnm2fimg fimgstats: fimgstats.c $(DEPS) gcc -g $< ../libfloatimg.a -o $@ @@ -25,6 +26,10 @@ fimg2png: fimg2png.c $(DEPS) addtga2fimg: addtga2fimg.c $(DEPS) gcc -g $< ../libfloatimg.a -limageSO -lm -o $@ +addpnm2fimg: addpnm2fimg.c $(DEPS) + gcc -g $< ../libfloatimg.a -limageSO -lm -o $@ + + # if "undefined reference to crc32" then "use -lz" png2fimg: png2fimg.c $(DEPS) gcc -g $< ../libfloatimg.a -lpnglite -o $@ diff --git a/tools/addpnm2fimg.c b/tools/addpnm2fimg.c new file mode 100644 index 0000000..bf328d4 --- /dev/null +++ b/tools/addpnm2fimg.c @@ -0,0 +1,94 @@ +/* + * ADDPNM + */ + +#include +#include +#include + +#include "../floatimg.h" + +int verbosity; + +/* --------------------------------------------------------------------- */ +int add_pnm_to_fimg(char *srcname, char *dstname, int notused) +{ +FloatImg dst, src; +int foo, x, y, idx; + +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( '%s' %s' )\n", __func__, srcname, dstname); +#endif + +foo = fimg_create_from_dump(dstname, &dst); +if (foo) fprintf(stderr, "create dst fimg from '%s' -> %d\n", dstname, foo); +#if DEBUG_LEVEL +fimg_describe(&dst, "created fimg from dump"); +#endif + +foo = fimg_load_from_pnm(srcname, &src, 0); +if (foo) fprintf(stderr, "create src fimg from '%s' -> %d\n", dstname, foo); +#if DEBUG_LEVEL +fimg_describe(&qrc, "created fimg from PNM"); +#endif + +idx = 0; +for (y=0; y %d\n", foo); } + +return 0; +} +/* --------------------------------------------------------------------- */ +int main(int argc, char *argv[]) +{ +int foo; +// int srcW, srcH; +int infos[3]; + +if (3 != argc) { + fimg_print_version(1); + fprintf(stderr, "usage:\n\t%s img.fimg cumul.fimg\n", argv[0]); + exit(1); + } + +if ( 0==access(argv[2], R_OK|W_OK) ) { /* fimg is readable */ + fprintf(stderr, "%s exist\n", argv[2]); + } +/* +else { + fprintf(stderr, "*** must create '%s' %dx%d first !!!\n", + argv[2], tgaW, tgaH); + exit(1); + } */ + +foo = fimg_fileinfos(argv[2], infos); +// fprintf(stderr, "get dims of '%s' -> %d\n", argv[2], foo); +if (foo) { + fprintf(stderr, "*** %s is badly broken\n", argv[2]); + exit(2); + } + +/* +if ( (tgaW != infos[0]) || (tgaW != infos[0]) ) { + fprintf(stderr, " TGA %5d %5d\n", tgaW, tgaH); + fprintf(stderr, " FIMG %5d %5d\n", infos[0], infos[1]); + fprintf(stderr, " No dimension match.\n"); + exit(3); + } +*/ + +foo = add_pnm_to_fimg(argv[1], argv[2], 0); + +return 0; +} +/* --------------------------------------------------------------------- */ + + diff --git a/tools/png2fimg.c b/tools/png2fimg.c index dbfa39a..c96c605 100644 --- a/tools/png2fimg.c +++ b/tools/png2fimg.c @@ -9,6 +9,8 @@ #include "../floatimg.h" +int verbosity = 0; + /* --------------------------------------------------------------------- */ int main(int argc, char *argv[]) {