diff --git a/Makefile b/Makefile index e16f5c5..3d629b1 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ # a look to the 'build.sh' script ! # #################################################### -COPT = -Wall -fpic -g -pg -DDEBUG_LEVEL=0 +COPT = -Wall -fpic -g -pg -no-pie -DDEBUG_LEVEL=0 LDOPT = libfloatimg.a -pg -lm all: essai diff --git a/lib/fimg-file.c b/lib/fimg-file.c index 8446270..14b6e11 100644 --- a/lib/fimg-file.c +++ b/lib/fimg-file.c @@ -136,7 +136,8 @@ if (foo) { return foo; } -foo = fread(head->R, sizeof(float), filehead.w*filehead.h*3, fp); +foo = fread(head->R, sizeof(float), + filehead.w*filehead.h*filehead.t, fp); fclose(fp); diff --git a/lib/fimg-math.c b/lib/fimg-math.c index d73c2bc..2f4be78 100644 --- a/lib/fimg-math.c +++ b/lib/fimg-math.c @@ -7,7 +7,8 @@ #include #include #include -#include "string.h" +#include +#include #include "../floatimg.h" @@ -19,6 +20,12 @@ float fimg_get_maxvalue(FloatImg *head) float maxval; int foo; +if (head->type != FIMG_TYPE_RGB) { + fprintf(stderr, "%s : type %d invalide\n", + __func__, head->type); + return nanf("wtf ?"); + } + maxval = 0.0; /* no negative values allowed */ for (foo=0; foo<(head->width*head->height); foo++) { @@ -57,6 +64,12 @@ int fimg_to_gray(FloatImg *head) float add; int foo; +if (head->type != FIMG_TYPE_RGB) { + fprintf(stderr, "%s : type %d invalide\n", + __func__, head->type); + return -3; + } + for (foo=0; foo<(head->width*head->height); foo++) { add = head->R[foo]; add += head->G[foo]; @@ -70,6 +83,12 @@ void fimg_add_cste(FloatImg *fi, float value) { int nbre, idx; +if (fi->type != FIMG_TYPE_RGB) { + fprintf(stderr, "%s : type %d invalide\n", + __func__, fi->type); + return; + } + nbre = fi->width * fi->height * fi->type; #if DEBUG_LEVEL fprintf(stderr, "%s, nbre is %d\n", __func__, nbre); diff --git a/lib/t.c b/lib/t.c index 1a4a8ce..ebb7040 100644 --- a/lib/t.c +++ b/lib/t.c @@ -13,7 +13,7 @@ int main(int argc, char *argv[]) int foo; FloatImg fimg; int datas[3]; - +char *fname = "foo.fimg"; verbosity = 1; fimg_print_version(0); @@ -25,9 +25,12 @@ fimg_printhead(&fimg); fimg_describe(&fimg, "vroum"); // fimg_save_as_pnm(&fimg, "foo.pnm", 0); -foo = fimg_dump_to_file(&fimg, "foo.fimg", 0); +foo = fimg_dump_to_file(&fimg, fname, 0); foo = fimg_fileinfos("foo.fimg", datas); +printf("%s : largeur %d hauteur %d type %d\n", + fname, datas[0], datas[1], datas[2]); + return 0; }