From c59eedd33c50f0d9fe4cca51b1460282ce63946e Mon Sep 17 00:00:00 2001 From: tth Date: Tue, 4 May 2021 10:29:02 +0200 Subject: [PATCH] better args parsing in mkfimg --- doc/the_floatimg_hack.tex | 5 ++++- tools/mkfimg.c | 30 +++++++++++++++++++++--------- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/doc/the_floatimg_hack.tex b/doc/the_floatimg_hack.tex index 2afbddb5..fdfa2076 100644 --- a/doc/the_floatimg_hack.tex +++ b/doc/the_floatimg_hack.tex @@ -926,13 +926,16 @@ Usage: mkfimg [options] quux.fimg width height -v increase verbosity \end{verbatim} +Il y a deux syntaxes possibles pour les dimensions de l'image générée~: +deux nombres séparés ou la notation \texttt{WIDTHxHEIGHT}. + La plupart des types d'image générée prennent un paramètre flottant qui devra être donné avec l'option \texttt{-k F.F} avec une valeur par défaut à $1.0$, ce qui n'est pas toujours une bonne valeur. \begin{description} \index{XXX} \item [black/gray/grey:] efface avec 0.0 (black) ou avec la valeur - \texttt{-k} (gray). + \texttt{-k} (niveau de gris). \item [drand48:] beaucoup de bruit dans chacun des canaux. \item [hdeg/vdeg:] dégradé du noir au blanc (relatif à \texttt{-k}). \end{description} diff --git a/tools/mkfimg.c b/tools/mkfimg.c index 09dcae59..e418fcdd 100644 --- a/tools/mkfimg.c +++ b/tools/mkfimg.c @@ -63,7 +63,7 @@ int foo; puts("Usage:\tmkfimg [options] quux.fimg width height"); puts("\t-k N.N\tgive a float parameter"); -fputs("\t-t bla\thowto make the pic\n\t\t", stdout); +fputs("\t-t bla\thowto make the pic :\n\t\t", stdout); for (foo=0; types[foo].code; foo++) { printf("%s ", types[foo].name); } @@ -79,7 +79,7 @@ exit(0); /* --------------------------------------------------------------------- */ int main(int argc, char *argv[]) { -int foo, opt; +int foo, opt, nbargs; int width, height; char *fname; float fvalue = 1.0; @@ -103,21 +103,33 @@ for (foo=0; foo1) fprintf(stderr, "*** mkfimg *** %s %s\n", __DATE__, __TIME__); -if (verbosity) fprintf(stderr, "making '%s' %d x %d, type %d\n", +if (verbosity) fprintf(stderr, "making '%s' %dx%d, type %d\n", fname, width, height, type); srand48(getpid() ^ time(NULL));