Compare commits

...

2 Commits

Author SHA1 Message Date
tth
6258bd08ed adding a few small bugs 2019-08-07 17:30:16 +02:00
tth
cdd6c30f6d clean main makefile 2019-08-07 17:14:58 +02:00
4 changed files with 30 additions and 9 deletions

View File

@ -3,22 +3,20 @@
# 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
#---------------------------------------------------------------
exemple: exemple.c libfloatimg.a floatimg.h Makefile
gcc $(COPT) $< $(LDOPT) -o $@
essai: essai.c libfloatimg.a floatimg.h Makefile
gcc $(COPT) $< $(LDOPT) -lpnglite -o $@
#---------------------------------------------------------------
TOTAR = *.[ch] Makefile *.sh *.txt doc/*.tex \
TOTAR = *.[ch] Makefile *.sh *.txt \
doc/*.tex doc/mkdoc.sh \
funcs/*.[ch] funcs/Makefile \
tools/*.[ch] tools/Makefile \
v4l2/*.[ch] v4l2/Makefile \

View File

@ -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);

View File

@ -7,7 +7,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "string.h"
#include <string.h>
#include <math.h>
#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);

View File

@ -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;
}