adding a few small bugs

This commit is contained in:
tth 2019-08-07 17:30:16 +02:00
parent cdd6c30f6d
commit 6258bd08ed
4 changed files with 28 additions and 5 deletions

View File

@ -3,7 +3,7 @@
# a look to the 'build.sh' script ! # # 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 LDOPT = libfloatimg.a -pg -lm
all: essai all: essai

View File

@ -136,7 +136,8 @@ if (foo) {
return 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); fclose(fp);

View File

@ -7,7 +7,8 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include "string.h" #include <string.h>
#include <math.h>
#include "../floatimg.h" #include "../floatimg.h"
@ -19,6 +20,12 @@ float fimg_get_maxvalue(FloatImg *head)
float maxval; float maxval;
int foo; 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 */ maxval = 0.0; /* no negative values allowed */
for (foo=0; foo<(head->width*head->height); foo++) { for (foo=0; foo<(head->width*head->height); foo++) {
@ -57,6 +64,12 @@ int fimg_to_gray(FloatImg *head)
float add; float add;
int foo; 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++) { for (foo=0; foo<(head->width*head->height); foo++) {
add = head->R[foo]; add = head->R[foo];
add += head->G[foo]; add += head->G[foo];
@ -70,6 +83,12 @@ void fimg_add_cste(FloatImg *fi, float value)
{ {
int nbre, idx; 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; nbre = fi->width * fi->height * fi->type;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s, nbre is %d\n", __func__, nbre); fprintf(stderr, "%s, nbre is %d\n", __func__, nbre);

View File

@ -13,7 +13,7 @@ int main(int argc, char *argv[])
int foo; int foo;
FloatImg fimg; FloatImg fimg;
int datas[3]; int datas[3];
char *fname = "foo.fimg";
verbosity = 1; verbosity = 1;
fimg_print_version(0); fimg_print_version(0);
@ -25,9 +25,12 @@ fimg_printhead(&fimg);
fimg_describe(&fimg, "vroum"); fimg_describe(&fimg, "vroum");
// fimg_save_as_pnm(&fimg, "foo.pnm", 0); // 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); foo = fimg_fileinfos("foo.fimg", datas);
printf("%s : largeur %d hauteur %d type %d\n",
fname, datas[0], datas[1], datas[2]);
return 0; return 0;
} }