Vergelijk commits

...

6 Commits

Auteur SHA1 Bericht Datum
tth
e410b64514 more cleanup 2021-03-17 11:34:11 +01:00
tth
13cb77496d run a few tests 2021-03-17 11:18:26 +01:00
tth
7cb660c8c7 cleanup 2021-03-17 11:13:29 +01:00
tth
30de864c4d bla 2021-03-17 10:55:34 +01:00
tth
5f4e6e8fa8 error checking 2021-03-11 18:32:42 +01:00
tth
cd1f278d45 fix a memory leak 2021-03-10 05:51:48 +01:00
8 gewijzigde bestanden met toevoegingen van 104 en 25 verwijderingen

Bestand weergeven

@ -51,7 +51,7 @@ float means[4]; /* four values : R G B A */
int foo; int foo;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %f %d )\n", __func__, pimg, where, whot); fprintf(stderr, ">>> %s ( %p %p )\n", __func__, pimg, where);
#endif #endif
foo = fimg_meanvalues(pimg, means); foo = fimg_meanvalues(pimg, means);

Bestand weergeven

@ -71,7 +71,7 @@ if (0 == globbuf.gl_pathc) {
for (idx=0; idx<globbuf.gl_pathc; idx++) { for (idx=0; idx<globbuf.gl_pathc; idx++) {
fname = globbuf.gl_pathv[idx]; /* alias of filename */ fname = globbuf.gl_pathv[idx]; /* alias of filename */
fprintf(stderr, " %6d %s\r", globbuf.gl_pathc-idx, fname); fprintf(stderr, " %6ld %s\r", (long)globbuf.gl_pathc-idx, fname);
if (0==image.width && 0==image.height) { if (0==image.width && 0==image.height) {
foo = fimg_create_from_dump(fname, &image); foo = fimg_create_from_dump(fname, &image);
@ -104,9 +104,9 @@ fimg_destroy(&image);
single_print_state("end of run :)", 0); single_print_state("end of run :)", 0);
elapsed = fimg_timer_get(0); elapsed = fimg_timer_get(0);
fprintf(stderr, "%s: %d frames, elapsed %.3f s, %.3f fps\n", fprintf(stderr, "%s: %ld frames, elapsed %.3f s, %.3f fps\n",
__func__, __func__,
globbuf.gl_pathc, elapsed, (long)globbuf.gl_pathc, elapsed,
(double)globbuf.gl_pathc/elapsed); (double)globbuf.gl_pathc/elapsed);
return 0; return 0;
@ -156,6 +156,9 @@ while ((opt = getopt(argc, argv, "hF:g:LO:svx")) != -1) {
case 'x': do_xper = 1; break; case 'x': do_xper = 1; break;
default:
fprintf(stderr, "%s ABEND\n", argv[0]);
exit(1);
} }
} }

Bestand weergeven

@ -299,7 +299,7 @@ Les deux premiers champs sont \textsl{obvious}.
Le troisième est le type d'image : pour le moment, il y en a % trois Le troisième est le type d'image : pour le moment, il y en a % trois
un certain nombre un certain nombre
qui sont définis\footnote{et plus ou moins bien gérés\dots} : qui sont définis\footnote{et plus ou moins bien gérés\dots} :
gris, rgb et rgba\index{rgba}. gris, rgb et rgba/rgbz\index{rgba}\index{rgbz}.
Les constantes adéquates sont dans \texttt{floatimg.h} Les constantes adéquates sont dans \texttt{floatimg.h}
\begin{lstlisting} \begin{lstlisting}
@ -443,7 +443,7 @@ $x$ et $y$ de la demande.
Quand au canal \textsl{alpha}\index{alpha}, il est pour le moment Quand au canal \textsl{alpha}\index{alpha}, il est pour le moment
superbement ignoré. Ceci dit, on vient de me faire remarquer qu'il superbement ignoré. Ceci dit, on vient de me faire remarquer qu'il
peut être utilisable aussi pour faire du peut être utilisable aussi pour faire du
\textsl{z-buffer}\index{z-buffer} \dots \textsl{z-buffer}\index{z-buffer}\index{rgbz} \dots
% ---------------------------------- % ----------------------------------
@ -477,7 +477,7 @@ int fimg_cos_010(FloatImg *s, FloatImg *d, double maxval);
Si vous souhaitez rajouter votre propre méthode de modification Si vous souhaitez rajouter votre propre méthode de modification
de contraste, il y a quelques explication en page \pageref{exemplefunc}. de contraste, il y a quelques explication en page \pageref{exemplefunc}.
Mais rien ne vous oblige à le faire. Mais rien ne vous oblige à le faire. Sauf vos envies.
\begin{figure}[h] \begin{figure}[h]
@ -627,6 +627,9 @@ int fimg_save_as_png(FloatImg *src, char *outname, int flags);
\end{lstlisting} \end{lstlisting}
Tous les flags doivent être à zéro. Sinon, ça foire parfois. Tous les flags doivent être à zéro. Sinon, ça foire parfois.
Et en fait (mars 2021) je ne suis pas très content de
\texttt{pnglite}, donc un de ces jours\footnote{Rendez-nous notre
Mixou !}, je prendrais cinq jours pour régler le souci.
\subsubsection{Vers TIFF}\index{TIFF} \subsubsection{Vers TIFF}\index{TIFF}

33
funcs/alltests.sh Executable file
Bestand weergeven

@ -0,0 +1,33 @@
#!/bin/bash
#
# trying to run a maximum of ugly code
#
for trial in $(./t -l)
do
printf "============ %-10s ============\n" $trial
make t
error=$?
if [ 0 -ne $error ]
then
echo "make error is " $error
exit 1
fi
./t -v $trial
error=$?
if [ 0 -ne $error ]
then
echo "run error is " $error
exit 1
fi
printf "\t=== return code %d\n" $error
echo
sleep 10
done

Bestand weergeven

@ -61,6 +61,16 @@ while (pcmd->name) {
return -1; return -1;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
void list_tests(void)
{
Command *pcmd = commands;
while (pcmd->name) {
printf("%s\n", pcmd->name);
pcmd++;
}
exit(0);
}
/* --------------------------------------------------------------------- */
void help(int k) void help(int k)
{ {
Command *pcmd; Command *pcmd;
@ -68,7 +78,9 @@ Command *pcmd;
fprintf(stderr, "usage:\n\t./t [options] command [filename]\n"); fprintf(stderr, "usage:\n\t./t [options] command [filename]\n");
fprintf(stderr, "options:\n"); fprintf(stderr, "options:\n");
fprintf(stderr, "\t-o outfile\n"); fprintf(stderr, "\t-k 1.414\tset float value\n");
fprintf(stderr, "\t-l\t\tlist tests\n");
fprintf(stderr, "\t-o \t\toutfile\n");
fprintf(stderr, "commands:\n"); fprintf(stderr, "commands:\n");
pcmd = commands; pcmd = commands;
@ -94,10 +106,12 @@ outfile = "out.pnm";
command = "none"; command = "none";
filename = "in.fimg"; filename = "in.fimg";
while ((opt = getopt(argc, argv, "hk:o:p:v")) != -1) { while ((opt = getopt(argc, argv, "hk:lo:p:v")) != -1) {
// fprintf(stderr, "opt = %c\n", opt);
switch(opt) { switch(opt) {
case 'h': help(0); break; case 'h': help(0); break;
case 'k': global_fvalue = atof(optarg); break; case 'k': global_fvalue = atof(optarg); break;
case 'l': list_tests(); break;
case 'o': outfile = optarg; break; case 'o': outfile = optarg; break;
case 'v': verbosity++; break; case 'v': verbosity++; break;
} }
@ -141,19 +155,21 @@ switch(opt) {
foo = essai_mire(filename, 0); foo = essai_mire(filename, 0);
break; break;
case Wfits: case Wfits:
foo = essai_ecriture_fits(filename); foo = essai_ecriture_fits("out.fits");
break; break;
case Wpng: case Wpng:
foo = essai_ecriture_png(filename); foo = essai_ecriture_png("out.png");
break; break;
case Wtiff: case Wtiff:
foo = essai_ecriture_tiff(filename); foo = essai_ecriture_tiff("out.tiff");
break; break;
case Histo: case Histo:
foo = essai_histogramme(filename, 98765); foo = essai_histogramme(filename, 98765);
break; break;
case Hsv: case Hsv:
foo = fimg_essai_hsv(filename); // not ready for primtime
// foo = fimg_essai_hsv(filename);
foo = 0;
break; break;
case Classif: case Classif:
foo = essai_classif(filename, outfile, global_fvalue); foo = essai_classif(filename, outfile, global_fvalue);
@ -168,23 +184,29 @@ switch(opt) {
foo = essai_displacement(filename, outfile); foo = essai_displacement(filename, outfile);
break; break;
case ReadPNG: case ReadPNG:
foo = essai_lecture_png(filename, outfile, 0); // not ready for primetime
// foo = essai_lecture_png("in.png", outfile, 0);
foo = 0;
break; break;
case Plasmas: case Plasmas:
foo = essai_plasma(filename, outfile, 1, global_fvalue); foo = essai_plasma(filename, outfile, 1, global_fvalue);
fprintf(stderr, "we are all plasmafields\n"); fprintf(stderr, "we are all plasmafields\n");
break; break;
case Rotate:
fprintf(stderr, "rotate not implemented (%d)\n", rand());
foo = 0;
break;
default: default:
fprintf(stderr, "%s : bad command\n", command); fprintf(stderr, "'%s' is a bad command\n", command);
exit(1); exit(1);
} }
if (foo) { if (foo) {
fprintf(stderr, "Essai ====> %d\n", foo); fprintf(stderr, "******* Essai --> %d\n", foo);
} }
fprintf(stderr, "+++++ end of %s pid %d\n", command, getpid()); fprintf(stderr, "++++++++++++ end of '%s' pid %d\n", command, getpid());
return 0; return 0;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */

Bestand weergeven

@ -231,7 +231,7 @@ if (foo) {
return foo; return foo;
} }
return -7; return 0;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
/* essai de fichiers FITS (astronomie) */ /* essai de fichiers FITS (astronomie) */
@ -278,7 +278,7 @@ fprintf(stderr, "equalize compute --> %d\n", foo);
fimg_destroy(&src); fimg_destroy(&src);
return -1; return 0;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
int essai_rotate(char *infile) int essai_rotate(char *infile)
@ -510,6 +510,7 @@ if (foo) {
return -6; return -6;
} }
fimg_destroy(&fimg);
return 0; return 0;
} }
@ -588,16 +589,26 @@ int foo;
fimg_create(&fimg, 640, 480, FIMG_TYPE_RGB); fimg_create(&fimg, 640, 480, FIMG_TYPE_RGB);
foo = fimg_hdeg_a(&fimg, (double)3.141592654); #define V ((double)3.141592654)
foo = fimg_hdeg_a(&fimg, V);
fprintf(stderr, "make h deg -> %d\n", foo); fprintf(stderr, "make h deg -> %d\n", foo);
foo = fimg_save_as_pnm(&fimg, "hdeg.pnm", 0); foo = fimg_save_as_pnm(&fimg, "hdeg.pnm", 0);
fprintf(stderr, "%s: save as pnm -> %d\n", __func__, foo); fprintf(stderr, "%s: save as pnm -> %d\n", __func__, foo);
foo = fimg_vdeg_a(&fimg, (double)3.141592654);
foo = fimg_vdeg_a(&fimg, V);
fprintf(stderr, "make h deg -> %d\n", foo); fprintf(stderr, "make h deg -> %d\n", foo);
foo = fimg_save_as_pnm(&fimg, "vdeg.pnm", 0); foo = fimg_save_as_pnm(&fimg, "vdeg_a.pnm", 0);
fprintf(stderr, "%s: save as pnm -> %d\n", __func__, foo); fprintf(stderr, "%s: save as pnm -> %d\n", __func__, foo);
foo = fimg_vdeg_a(&fimg, -V);
fprintf(stderr, "make h deg -> %d\n", foo);
foo = fimg_save_as_pnm(&fimg, "vdeg_b.pnm", 0);
fprintf(stderr, "%s: save as pnm -> %d\n", __func__, foo);
#undef V
return 0; return 0;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */
@ -636,12 +647,14 @@ fimg_draw_something(&fimg);
if (verbosity) { if (verbosity) {
foo = fimg_save_as_pnm(&fimg, "quux.pnm", 0); foo = fimg_save_as_pnm(&fimg, "quux.pnm", 0);
fprintf(stderr, "%s: save as pnm -> %d\n", __func__, foo); fprintf(stderr, "%s: saved as pnm -> %d\n", __func__, foo);
} }
foo = fimg_save_as_png(&fimg, fname, 0); foo = fimg_save_as_png(&fimg, fname, 0);
fprintf(stderr, "save as png -> %d\n", foo); fprintf(stderr, "save as png -> %d\n", foo);
fimg_destroy(&fimg);
return 0; return 0;
} }
/* --------------------------------------------------------------------- */ /* --------------------------------------------------------------------- */

Bestand weergeven

@ -167,6 +167,10 @@ if (NULL == fimg->R) {
free(fimg->R); free(fimg->R);
if (FIMG_TYPE_RGB==fimg->type) {
free(fimg->G);
free(fimg->B);
}
memset(fimg, 0, sizeof(FloatImg)); memset(fimg, 0, sizeof(FloatImg));
return 0; return 0;

Bestand weergeven

@ -35,7 +35,6 @@ else {
fp = stdout; /* XXX */ fp = stdout; /* XXX */
for (y=0; y<src->height; y+=steps) { for (y=0; y<src->height; y+=steps) {
for (x=0; x<src->width; x+=steps) { for (x=0; x<src->width; x+=steps) {
fimg_get_rgb(src, x, y, rgb); fimg_get_rgb(src, x, y, rgb);
fprintf(fp, "%d %d ", x, y); fprintf(fp, "%d %d ", x, y);
fprintf(fp, "%f %f %f\n", rgb[0], rgb[1], rgb[2]); fprintf(fp, "%f %f %f\n", rgb[0], rgb[1], rgb[2]);
@ -120,7 +119,9 @@ if (norm > 0.0) {
} }
foo = export_as_machinable(&fimg, dstname, steps, 0); foo = export_as_machinable(&fimg, dstname, steps, 0);
if (foo) {
fprintf(stderr,"%s: err %d on export\n", __func__, foo);
}
fimg_destroy(&fimg); fimg_destroy(&fimg);
return 0; return 0;