diff --git a/.gitignore b/.gitignore index 62cfed1..23951a4 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,8 @@ doc/*.idx doc/*.ilg doc/*.ind +funcs/t + v4l2/t v4l2/capture v4l2/grabvidseq diff --git a/funcs/Makefile b/funcs/Makefile index 40a9821..22648a9 100644 --- a/funcs/Makefile +++ b/funcs/Makefile @@ -1,8 +1,14 @@ #--------------------------------------------------------------- -COPT = -Wall -fpic -g -no-pie -DDEBUG_LEVEL=0 +COPT = -Wall -fpic -g -no-pie -DDEBUG_LEVEL=1 DEPS = ../floatimg.h Makefile -OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o +OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \ + fimg-libpnm.o + +#--------------------------------------------------------------- + +t: t.c $(DEPS) ../libfloatimg.a + gcc $(COPT) $< ../libfloatimg.a -lnetpbm -o $@ #--------------------------------------------------------------- @@ -15,6 +21,9 @@ fimg-png.o: fimg-png.c $(DEPS) fimg-tiff.o: fimg-tiff.c $(DEPS) gcc $(COPT) -c $< +fimg-libpnm.o: fimg-libpnm.c $(DEPS) + gcc $(COPT) -c $< + misc-plots.o: misc-plots.c $(DEPS) gcc $(COPT) -c $< diff --git a/funcs/fimg-libpnm.c b/funcs/fimg-libpnm.c new file mode 100644 index 0000000..decbd06 --- /dev/null +++ b/funcs/fimg-libpnm.c @@ -0,0 +1,52 @@ +/* + * interface FloatImg <-> libpnm(3) + */ + +#include +#include +#include + +#include + +#include "../floatimg.h" + +extern int verbosity; + +/* --------------------------------------------------------------------- */ +static void print_struct_pam(struct pam *ppam, char *txt) +{ + +printf("size %d\n", ppam->size); + +printf("format %d\n", ppam->format); +printf("plainformat %d\n", ppam->plainformat); +printf("width & height %d %d\n", ppam->width, ppam->height); +printf("depth %d\n", ppam->depth); +printf("maxval %lu\n", ppam->maxval); + +} +/* --------------------------------------------------------------------- */ + +int fimg_pnm_infos(char *fname) +{ +struct pam inpam; +FILE *fp; + +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( '%s' )\n", __func__, fname); +#endif + +if (NULL==(fp=fopen(fname, "r"))) { + perror(fname); + exit(1); + } + +pnm_readpaminit(fp, &inpam, sizeof(inpam)); + +print_struct_pam(&inpam, fname); + +fclose(fp); + +return 0; +} +/* --------------------------------------------------------------------- */ diff --git a/funcs/t.c b/funcs/t.c new file mode 100644 index 0000000..7c20627 --- /dev/null +++ b/funcs/t.c @@ -0,0 +1,25 @@ +/* + */ + +#include +#include +#include +#include + +#include "../floatimg.h" + +int fimg_pnm_infos(char *); + +/* --------------------------------------------------------------------- */ +int main(int argc, char *argv[]) +{ +int foo; + +pnm_init(&argc, argv); + +foo = fimg_pnm_infos("foo.pnm"); +fprintf(stderr, "got %d\n", foo); + +return 0; +} +/* --------------------------------------------------------------------- */