diff --git a/Docs/README.md b/Docs/README.md index db8a1c3..0753b3e 100644 --- a/Docs/README.md +++ b/Docs/README.md @@ -1,9 +1,28 @@ # libtthimage -Les fichiers HTML que vous avez ici sont des versions historiques, +Les fichiers [HTML](html/) que vous avez ici sont des versions historiques, qui seront peut-être mise à jour au prochain grand refactoring. Leur contenu est donc à prendre avec des pincettes, ymmv. -Ceci dit, les principes généraux sont encore bons... +Ceci dit, les principes généraux sont encore bons. Mais il y a quelques +points à préciser. +## Compilation +Certaines options de compilation sont dans le fichier de +[paramètres](../Paramakes.mk) pour les différents fichiers make. + +Le script [build.sh](../build.sh) tente d'automatiser les +compilations de la bibilothèque, des tests et des outils +en ligne de commande. + +## Installation + +Le script [install.sh](../install.sh) va installer divers fichiers +aux bonnes places là où on lui dit avec la variable `DESTDIR`. +Attention, celle-ci doit être cohérente avec les valeurs déclarée +dans le fichier Paramakes.mk ! + +## Utilisation + +??? diff --git a/Docs/html/README.md b/Docs/html/README.md new file mode 100644 index 0000000..e69de29 diff --git a/Docs/image77.html b/Docs/html/image77.html similarity index 100% rename from Docs/image77.html rename to Docs/html/image77.html diff --git a/Docs/img-alpha.html b/Docs/html/img-alpha.html similarity index 100% rename from Docs/img-alpha.html rename to Docs/html/img-alpha.html diff --git a/Docs/img-asciiart.html b/Docs/html/img-asciiart.html similarity index 100% rename from Docs/img-asciiart.html rename to Docs/html/img-asciiart.html diff --git a/Docs/img-bitplane.html b/Docs/html/img-bitplane.html similarity index 100% rename from Docs/img-bitplane.html rename to Docs/html/img-bitplane.html diff --git a/Docs/img-cadres.html b/Docs/html/img-cadres.html similarity index 100% rename from Docs/img-cadres.html rename to Docs/html/img-cadres.html diff --git a/Docs/img-calculs.html b/Docs/html/img-calculs.html similarity index 100% rename from Docs/img-calculs.html rename to Docs/html/img-calculs.html diff --git a/Docs/img-combine.html b/Docs/html/img-combine.html similarity index 100% rename from Docs/img-combine.html rename to Docs/html/img-combine.html diff --git a/Docs/img-couleurs.html b/Docs/html/img-couleurs.html similarity index 100% rename from Docs/img-couleurs.html rename to Docs/html/img-couleurs.html diff --git a/Docs/img-dessin.html b/Docs/html/img-dessin.html similarity index 100% rename from Docs/img-dessin.html rename to Docs/html/img-dessin.html diff --git a/Docs/img-detect.html b/Docs/html/img-detect.html similarity index 100% rename from Docs/img-detect.html rename to Docs/html/img-detect.html diff --git a/Docs/img-devel.html b/Docs/html/img-devel.html similarity index 100% rename from Docs/img-devel.html rename to Docs/html/img-devel.html diff --git a/Docs/img-df3.html b/Docs/html/img-df3.html similarity index 100% rename from Docs/img-df3.html rename to Docs/html/img-df3.html diff --git a/Docs/img-dither.html b/Docs/html/img-dither.html similarity index 100% rename from Docs/img-dither.html rename to Docs/html/img-dither.html diff --git a/Docs/img-effets.html b/Docs/html/img-effets.html similarity index 100% rename from Docs/img-effets.html rename to Docs/html/img-effets.html diff --git a/Docs/img-essais.html b/Docs/html/img-essais.html similarity index 100% rename from Docs/img-essais.html rename to Docs/html/img-essais.html diff --git a/Docs/img-fichiers.html b/Docs/html/img-fichiers.html similarity index 100% rename from Docs/img-fichiers.html rename to Docs/html/img-fichiers.html diff --git a/Docs/img-filtres.html b/Docs/html/img-filtres.html similarity index 100% rename from Docs/img-filtres.html rename to Docs/html/img-filtres.html diff --git a/Docs/img-marquage.html b/Docs/html/img-marquage.html similarity index 100% rename from Docs/img-marquage.html rename to Docs/html/img-marquage.html diff --git a/Docs/img-mires.html b/Docs/html/img-mires.html similarity index 100% rename from Docs/img-mires.html rename to Docs/html/img-mires.html diff --git a/Docs/img-op2x2.html b/Docs/html/img-op2x2.html similarity index 100% rename from Docs/img-op2x2.html rename to Docs/html/img-op2x2.html diff --git a/Docs/img-operat.html b/Docs/html/img-operat.html similarity index 100% rename from Docs/img-operat.html rename to Docs/html/img-operat.html diff --git a/Docs/img-patterns.html b/Docs/html/img-patterns.html similarity index 100% rename from Docs/img-patterns.html rename to Docs/html/img-patterns.html diff --git a/Docs/img-plotters.html b/Docs/html/img-plotters.html similarity index 100% rename from Docs/img-plotters.html rename to Docs/html/img-plotters.html diff --git a/Docs/img-povhf15.html b/Docs/html/img-povhf15.html similarity index 100% rename from Docs/img-povhf15.html rename to Docs/html/img-povhf15.html diff --git a/Docs/img-ptlist.html b/Docs/html/img-ptlist.html similarity index 100% rename from Docs/img-ptlist.html rename to Docs/html/img-ptlist.html diff --git a/Docs/img-showdiff.html b/Docs/html/img-showdiff.html similarity index 100% rename from Docs/img-showdiff.html rename to Docs/html/img-showdiff.html diff --git a/Docs/img-stereo.html b/Docs/html/img-stereo.html similarity index 100% rename from Docs/img-stereo.html rename to Docs/html/img-stereo.html diff --git a/Docs/img-television.html b/Docs/html/img-television.html similarity index 100% rename from Docs/img-television.html rename to Docs/html/img-television.html diff --git a/Docs/img-texte.html b/Docs/html/img-texte.html similarity index 100% rename from Docs/img-texte.html rename to Docs/html/img-texte.html diff --git a/Docs/img-warp.html b/Docs/html/img-warp.html similarity index 100% rename from Docs/img-warp.html rename to Docs/html/img-warp.html diff --git a/Docs/libimage.css b/Docs/html/libimage.css similarity index 100% rename from Docs/libimage.css rename to Docs/html/libimage.css diff --git a/Docs/libimage.html b/Docs/html/libimage.html similarity index 100% rename from Docs/libimage.html rename to Docs/html/libimage.html diff --git a/Lib/Makefile b/Lib/Makefile index 791aefc..8abf024 100644 --- a/Lib/Makefile +++ b/Lib/Makefile @@ -124,6 +124,7 @@ text1.o: text1.c $(DEPS) text16x24.o: text16x24.c $(DEPS) tga.o: tga.c $(DEPS) tools.o: tools.c $(DEPS) +trigo.o: trigo.c $(DEPS) turtle.o: turtle.c $(DEPS) vignetize.o: vignetize.c $(DEPS) @@ -172,7 +173,7 @@ OBJECTS = 7seg.o \ scale.o sobel4.o stereo.o \ tamppool.o tele_2.o television.o \ text0.o text1.o text16x24.o \ - tga.o tools.o turtle.o \ + tga.o tools.o trigo.o turtle.o \ vignetize.o \ warp0.o warp1.o warp2.o warp3.o \ zoom.o diff --git a/Lib/combine.c b/Lib/combine.c index 40d429c..3b05314 100644 --- a/Lib/combine.c +++ b/Lib/combine.c @@ -23,8 +23,7 @@ /* * le paramètre 'zak' n'est pas utilisé et doit être mis à 0 */ -int -Image_combine_lines(Image_Desc *s1, Image_Desc *s2, Image_Desc *d, +int Image_combine_lines(Image_Desc *s1, Image_Desc *s2, Image_Desc *d, int sy, int oy, int zak) { int foo, x, y, my, r, g, b; @@ -67,8 +66,7 @@ return OLL_KORRECT; /* * le paramètre 'zak' n'est pas utilisé et doit être mis à 0 */ -int -Image_combine_columns(Image_Desc *s1, Image_Desc *s2, Image_Desc *d, +int Image_combine_columns(Image_Desc *s1, Image_Desc *s2, Image_Desc *d, int sx, int ox, int zak) { int foo, x, y, mx, r, g, b; @@ -116,8 +114,7 @@ return OLL_KORRECT; * * 'zak' parameter is not used, and must be 0. */ -int -Image_combine_checker(Image_Desc *s1, Image_Desc *s2, Image_Desc *d, +int Image_combine_checker(Image_Desc *s1, Image_Desc *s2, Image_Desc *d, int sx, int sy, int ox, int oy, int zak) { int foo, r, g, b; @@ -176,8 +173,7 @@ return 0; * * Tiens, le parametre 'yo' ne sert a rien ? */ -int -Image_combine_cercle_flou(Image_Desc *s1, Image_Desc *s2, Image_Desc *d, int yo) +int Image_combine_cercle_flou(Image_Desc *s1, Image_Desc *s2, Image_Desc *d, int yo) { int foo; int xcenter, ycenter; @@ -243,8 +239,7 @@ return OLL_KORRECT; * le flag 'yo' decide quelle image sera en haut à droite. * les paramètres p1 & p2 ne sont pas utilisés. */ -int -Image_combine_diagonale(Image_Desc *s1, Image_Desc *s2, Image_Desc *d, +int Image_combine_diagonale(Image_Desc *s1, Image_Desc *s2, Image_Desc *d, int yo, int p1, int p2) { int foo; @@ -305,8 +300,7 @@ return OLL_KORRECT; we put in the destination image the min/max value of the RGB componants. */ -int -Image_combine_minmax(Image_Desc *s1, Image_Desc *s2, Image_Desc *d, int flg) +int Image_combine_minmax(Image_Desc *s1, Image_Desc *s2, Image_Desc *d, int flg) { int foo, x, y, r, g, b; int r1, r2, g1, g2, b1, b2; @@ -352,8 +346,7 @@ return OLL_KORRECT; * 6 oct 2001: une version qui permettrait de spécifier les * seuils en r,g et b serait assez pratique aussi. */ -int -Image_combine_if_not_black(Image_Desc *s1, Image_Desc *s2, Image_Desc *d) +int Image_combine_if_not_black(Image_Desc *s1, Image_Desc *s2, Image_Desc *d) { int foo, x, y, r, g, b; @@ -389,10 +382,9 @@ return FUNC_IS_BETA; /* XXX c'est pas du OLL_KORRECT ? */ /* * gni ? */ -int -Image_poke_2zones(Image_Desc *src, Image_Desc *ia, Image_Desc *ib, +int Image_poke_2zones(Image_Desc *src, Image_Desc *ia, Image_Desc *ib, Image_Rect *za, Image_Rect *zb, - Image_Desc *dst) + Image_Desc *dst) { int foo; /* Image_Rect rect; */ diff --git a/Lib/effects.c b/Lib/effects.c index 2b8beee..573c6a9 100644 --- a/Lib/effects.c +++ b/Lib/effects.c @@ -32,20 +32,17 @@ int x, y, nx, ny, r, g, b, foo; int retry; #endif -if ( (foo=Image_compare_desc(source, but)) ) - { +if ( (foo=Image_compare_desc(source, but)) ) { fprintf(stderr, "%s : images are differents %d\n", __func__, foo); return foo; } -if (intensite < 1) - { +if (intensite < 1) { fprintf(stderr, "%s : bad intensity %d\n", __func__, intensite); intensite = 1; } -if (source == but) - { +if (source == but) { fprintf(stderr, "%s : Source & Target are the same image, bad effect expected...\n", __func__ ); } @@ -53,13 +50,10 @@ if (source == but) retry = 0; #endif -for (x=0; xwidth; x++) - { - for (y=0; yheight; y++) - { +for (x=0; xwidth; x++) { + for (y=0; yheight; y++) { foo = -1; - do - { + do { nx = x+(rand()%intensite)-(intensite/2); ny = y+(rand()%intensite)-(intensite/2); foo++; @@ -135,54 +129,46 @@ return OLL_KORRECT; j'ai rapidement besoin de cette fonction alors je code a la rache :-[ (on appelle aussi c,a le codage 123momo) */ -int -Image_mirror(Image_Desc *src, Image_Desc *dst, int reserved) +int Image_mirror(Image_Desc *src, Image_Desc *dst, int reserved) { register int x; uint8_t *buffer; int foo, largeur, y; if (reserved != 0) - fprintf(stderr, "Image_Mirror: reserved must be zero !\n"); + fprintf(stderr, "%s: reserved must be zero !\n", __func__); -if ( (foo=Image_compare_desc(src, dst)) ) - { - fprintf(stderr, "Image_Mirror: images are differents %d\n", foo); +if ( (foo=Image_compare_desc(src, dst)) ) { + fprintf(stderr, "%s: images are differents %d\n", __func__, foo); return foo; } largeur = src->width; -if ((buffer = (uint8_t *)malloc(largeur)) == NULL) - { - fprintf(stderr, "Image_Mirror: no memory for buffer"); +if ((buffer = (uint8_t *)malloc(largeur)) == NULL) { + fprintf(stderr, "%s: no memory for buffer\n", __func__); return BUFFER_NO_MEM; } -for (y=0; yheight; y++) - { - if (src->Rpix != NULL) - { +for (y=0; yheight; y++) { + if (src->Rpix != NULL) { for (x=0; xRpix[y])[x]; for (x=0; xRpix[y])[x] = buffer[largeur-x-1]; } - if (src->Gpix != NULL) - { + if (src->Gpix != NULL) { for (x=0; xGpix[y])[x]; for (x=0; xGpix[y])[x] = buffer[largeur-x-1]; } - if (src->Bpix != NULL) - { + if (src->Bpix != NULL) { for (x=0; xBpix[y])[x]; for (x=0; xBpix[y])[x] = buffer[largeur-x-1]; } - if (src->Apix != NULL) - { + if (src->Apix != NULL) { for (x=0; xApix[y])[x]; for (x=0; xheight; y++) - { +for (y=0; yheight; y++) { memcpy(dst->Rpix[y], src->Rpix[src->height-(y+1)], src->width); memcpy(dst->Gpix[y], src->Gpix[src->height-(y+1)], src->width); memcpy(dst->Bpix[y], src->Bpix[src->height-(y+1)], src->width); @@ -240,8 +223,7 @@ fprintf(stderr, "Scratching %ld times %p to %p\n", nombre, source, but); Image_copy(source, but); -while (nombre--) - { +while (nombre--) { xs = rand() % source->width; ys = rand() % source->height; xd = rand() % source->width; @@ -261,21 +243,18 @@ Image_swap_lines( Image_Desc *src, Image_Desc * dst ) { int foo, line; -if (src == dst) - { - fprintf(stderr, "Image swap lines: SRC & DST must be different\n"); +if (src == dst) { + fprintf(stderr, "%s: SRC & DST must be different\n", __func__); return IMG_OVERWRITE; } -if ( (foo=Image_compare_desc(src, dst)) ) - { - fprintf(stderr, "Image swap lines: images have differents sizes. %d\n", - foo); +if ( (foo=Image_compare_desc(src, dst)) ) { + fprintf(stderr, "%s: images have differents sizes. %d\n", + __func__, foo); return foo; } -for (line=0; line<(src->height-1); line+=2) - { +for (line=0; line<(src->height-1); line+=2) { memcpy(dst->Rpix[line+1], src->Rpix[line], src->width); memcpy(dst->Rpix[line], src->Rpix[line+1], src->width); memcpy(dst->Gpix[line+1], src->Gpix[line], src->width); @@ -294,15 +273,13 @@ Image_swap_cols( Image_Desc *src, Image_Desc * dst ) { int foo, line, col, tmp, wmax; -if (src == dst) - { - fprintf(stderr, "Image_SwapCols: SRC & DST must be different\n"); +if (src == dst) { + fprintf(stderr, "%s: SRC & DST must be different\n", __func__); return IMG_OVERWRITE; } -if ( (foo=Image_compare_desc(src, dst)) ) - { - fprintf(stderr, "Image_SwapCols: images are differents %d\n", foo); +if ( (foo=Image_compare_desc(src, dst)) ) { + fprintf(stderr, "%s: images are differents %d\n", __func__, foo); return foo; } @@ -312,10 +289,8 @@ else wmax = src->width; fprintf(stderr, "swap cols %d %d\n", src->width, wmax); -for (line=0; lineheight; line++) - { - for (col=0; colheight; line++) { + for (col=0; colRpix[line][col]; dst->Rpix[line][col] = src->Rpix[line][col+1]; dst->Rpix[line][col+1] = tmp; @@ -343,16 +318,13 @@ Image_swap_nibbles( Image_Desc *src, Image_Desc * dst ) int foo; int x, y; -if ( (foo=Image_compare_desc(src, dst)) ) - { +if ( (foo=Image_compare_desc(src, dst)) ) { fprintf(stderr, "%s: images are differents %d\n", __func__, foo); return foo; } -for (x=0; xwidth; x++) - { - for (y=0; yheight; y++) - { +for (x=0; xwidth; x++) { + for (y=0; yheight; y++) { dst->Rpix[y][x] = ((src->Rpix[y][x] & 0xf0) >> 4) | ((src->Rpix[y][x] & 0x0f) << 4); diff --git a/Lib/effects2.c b/Lib/effects2.c index d132bb9..7030ada 100644 --- a/Lib/effects2.c +++ b/Lib/effects2.c @@ -19,8 +19,7 @@ * la parametre 'table' est un tableau de 6 double. d'accord, * mais quel est donc son contenu ? */ -int -Image_sinwave_0( Image_Desc *source, Image_Desc * but, double *table ) +int Image_sinwave_0( Image_Desc *source, Image_Desc * but, double *table ) { #if DEBUG_LEVEL > 1 int foo; @@ -41,18 +40,15 @@ for (foo=0; foo<6; foo++) cx = (2.0 * M_PI) / (double)source->width; cy = (2.0 * M_PI) / (double)source->height; -for (x=0; xwidth; x++) - { +for (x=0; xwidth; x++) { fx = (double)x + (table[1] * sin(table[4] + (cx * table[0] * (double)x))); xb = floor(fx + 0.5); - for (y=0; yheight; y++) - { + for (y=0; yheight; y++) { fy = (double)y + (table[3] * sin(table[5] + cy * table[2] * (double)y)); yb = floor(fy + 0.5); - if ( xb>0 && yb>0 && xbwidth && ybheight ) - { + if ( xb>0 && yb>0 && xbwidth && ybheight ) { r = (source->Rpix[yb])[xb]; g = (source->Gpix[yb])[xb]; b = (source->Bpix[yb])[xb]; @@ -61,11 +57,7 @@ for (x=0; xwidth; x++) (but->Gpix[y])[x] = g; (but->Bpix[y])[x] = b; } - else - { - outside++; - /* ??? foo = Image_plotRGB(but, x, y, 0, 0, 0); */ - } + else { outside++; } } } @@ -85,8 +77,7 @@ return OLL_KORRECT; * Les parametres sont en deux groupes de 3 dans la table. * mais franchement, j'arrive plus a savoir a quoi ils servent. */ -int -Image_sinwave_1( Image_Desc *source, Image_Desc * but, double *table ) +int Image_sinwave_1( Image_Desc *source, Image_Desc * but, double *table ) { int foo, x, y, xb, yb, r, g, b; long outside = 0; @@ -197,7 +188,7 @@ fprintf(stderr, ">> %s ( %p %p %d %d )\n", __func__, source, but, k1, k2); fprintf(stderr, "Degouline %d %d\n", k1, k2); if ( (foo=Image_compare_desc(source, but)) ) { - fprintf(stderr, "Image Degouline 2: images are differents %d\n", foo); + fprintf(stderr, "%s: images are differents %d\n", __func__, foo); return foo; } diff --git a/Lib/effects3.c b/Lib/effects3.c index 6859bad..582f689 100644 --- a/Lib/effects3.c +++ b/Lib/effects3.c @@ -20,8 +20,7 @@ * 11 Fev 2003: que vais-je mettre ici ? * 5 avr 2007: je commence a en avoir une idee plus precise. */ -int -Image_effect_x_0(Image_Desc *src, Image_Desc *dst, int kr, int kg, int kb) +int Image_effect_x_0(Image_Desc *src, Image_Desc *dst, int kr, int kg, int kb) { int foo, x, y, r, g, b; int cr, cg, cb; @@ -30,9 +29,8 @@ int cr, cg, cb; fprintf(stderr, "*** Effect X_0: coeffs: %d %d %d\n", kr, kg, kb); #endif -if ( (foo=Image_compare_desc(src, dst)) ) - { - fprintf(stderr, "Image effect x 0: images are differents %d\n", foo); +if ( (foo=Image_compare_desc(src, dst)) ) { + fprintf(stderr, "%s: images are differents %d\n", __func__, foo); return foo; } @@ -40,7 +38,10 @@ cr = cg = cb = 0; /* raz des compteurs */ for (y=0; yheight; y++) { for (x=0; xwidth; x++) { - Image_getRGB(src, x, y, &r, &g, &b); + /* Image_getRGB(src, x, y, &r, &g, &b); */ + r = src->Rpix[y][x]; + g = src->Gpix[y][x]; + b = src->Bpix[y][x]; if (r > kr) { foo = g; g = b; b = foo; cr ++; @@ -53,11 +54,14 @@ for (y=0; yheight; y++) { foo = g; g = r; r = foo; cb ++; } - Image_plotRGB(dst, x, y, r, g, b); + /* Image_plotRGB(dst, x, y, r, g, b); */ + dst->Rpix[y][x] = r; + dst->Gpix[y][x] = g; + dst->Bpix[y][x] = b; } } -fprintf(stderr, "* %s : counts: %d %d %d\n", __func__, cr, cg, cb); +/* fprintf(stderr, "* %s : counts: %d %d %d\n", __func__, cr, cg, cb); */ return FUNC_IS_BETA; } @@ -71,16 +75,13 @@ Image_effect_x_1(Image_Desc *src, Image_Desc *dst) { int foo, x, y, r, g, b; -if ( (foo=Image_compare_desc(src, dst)) ) - { - fprintf(stderr, "Image effect x 1: images are differents %d\n", foo); +if ( (foo=Image_compare_desc(src, dst)) ) { + fprintf(stderr, "I%s: images are differents %d\n", __func__, foo); return foo; } -for (y=0; yheight; y++) - { - for (x=0; xwidth; x++) - { +for (y=0; yheight; y++) { + for (x=0; xwidth; x++) { r = src->Rpix[y][x]; g = src->Gpix[y][x]; b = src->Bpix[y][x]; @@ -105,9 +106,8 @@ Image_effect_x_2(Image_Desc *src, Image_Desc *dst, int kx, int ky, int kv) int foo, x, y, r, g, b; double dr, dg, db, ar, ag, ab; -if ( (foo=Image_compare_desc(src, dst)) ) - { - fprintf(stderr, "Image effect x 2: images are differents %d\n", foo); +if ( (foo=Image_compare_desc(src, dst)) ) { + fprintf(stderr, "%s: images are differents %d\n", __func__, foo); return foo; } @@ -252,7 +252,7 @@ fprintf(stderr, "*** effect x4 is not ready for prime time ***\n"); #endif if ( (foo=Image_compare_desc(src, dst)) ) { - fprintf(stderr, "Image effect x 4: images are differents %d\n", foo); + fprintf(stderr, "%s: images are differents %d\n", __func__, foo); return foo; } @@ -299,16 +299,13 @@ fprintf(stderr, ">>> %s ( %p %p %d %d %d )\n", __func__, src, dst, kx, ky, kz); #endif -if ( (foo=Image_compare_desc(src, dst)) ) - { +if ( (foo=Image_compare_desc(src, dst)) ) { fprintf(stderr, "Image effect x 5: images are differents %d\n", foo); return foo; } -for (y=0; yheight; y++) - { - for (x=0; xwidth; x++) - { +for (y=0; yheight; y++) { + for (x=0; xwidth; x++) { r = src->Rpix[y][x]; g = src->Gpix[y][x]; b = src->Bpix[y][x]; @@ -322,8 +319,7 @@ for (y=0; yheight; y++) g2 = (int)(dg2 * 255.0); b2 = (int)(db2 * 255.0); #if DEBUG_LEVEL - if (x==42 && y==42) - { + if (x==42 && y==42) { printf("{{{ pixels %3d %3d %3d }}}\n", r, g, b); printf("{{{ result %3d %3d %3d }}}\n", r2, g2, b2); } diff --git a/Lib/filtres.c b/Lib/filtres.c index 50af572..4587349 100644 --- a/Lib/filtres.c +++ b/Lib/filtres.c @@ -28,8 +28,7 @@ fprintf(ou, "\t+--------------------+------------------+\n"); fflush(ou); } /*::------------------------------------------------------------------::*/ -void -Image_rotate_filtre(int *m) +void Image_rotate_filtre(int *m) { register int foo; @@ -44,8 +43,7 @@ m[2] = m[1]; m[1] = foo; } /*::------------------------------------------------------------------::*/ -int -Image_convolueur3(Image_Desc *in, Image_Desc *out, int *mat) +int Image_convolueur3(Image_Desc *in, Image_Desc *out, int *mat) { int foo; @@ -57,22 +55,19 @@ foo = Image_convolueur_2(in, out, mat, "rgb"); return foo; } /*::------------------------------------------------------------------::*/ -int -Image_convolueur_2(Image_Desc *in, Image_Desc *out, int *mat, char *planes) +int Image_convolueur_2(Image_Desc *in, Image_Desc *out, int *mat, char *planes) { int foo, x, y; long lval; int masque = 0; -if (in == out) - { - fprintf(stderr, "convolueur 2: out overwrite in.\n"); +if (in == out) { + fprintf(stderr, "%s: out overwrite in.\n", __func__); return IMG_OVERWRITE; } -if ( (foo=Image_compare_desc(in, out)) ) - { - fprintf(stderr, "Convolueur: images are differents %d\n", foo); +if ( (foo=Image_compare_desc(in, out)) ) { + fprintf(stderr, "%s: images are differents %d\n", __func__, foo); return foo; } @@ -85,9 +80,8 @@ Image_dump_descriptor(out, "image de sortie convolueur"); Image_filtre_display(stdout, mat); #endif -if (mat[9] == 0) - { - fprintf(stderr, "Convolueur: fuck, divisor is ZERO !\n"); +if (mat[9] == 0) { + fprintf(stderr, "%s: fsck, divisor is ZERO !\n", __func__); /* ! c'est sur, avec un message comme c,a je vais pas ! pouvoir transmettre mon code aux australiens @@ -99,10 +93,8 @@ if (mat[9] == 0) /* * preparation of the binary mask from the parameter string */ -for (foo=0; foo<(int)strlen(planes); foo++) - { - switch (planes[foo]) - { +for (foo=0; foo<(int)strlen(planes); foo++) { + switch (planes[foo]) { case 'r': case 'R': masque |= 8; break; @@ -122,18 +114,14 @@ for (foo=0; foo<(int)strlen(planes); foo++) printf("masque convolueur = %02x\n", masque); #endif -if ( (masque & 1) && (in->Apix == NULL) ) - { - fprintf(stderr, "Convolueur2: filtering NULL alpha plane is _bad_\n"); +if ( (masque & 1) && (in->Apix == NULL) ) { + fprintf(stderr, "%s: filtering NULL alpha plane is _bad_\n", __func__); return WRONG_CHANNEL; } -for (y=1; y<((in->height)-1); y++) - { - for (x=1; x<((in->width)-1); x++) - { - if (masque & 8) - { +for (y=1; y<((in->height)-1); y++) { + for (x=1; x<((in->width)-1); x++) { + if (masque & 8) { lval = mat[0] * in->Rpix[y-1][x-1] + mat[1] * in->Rpix[y-1][x] + mat[2] * in->Rpix[y-1][x+1] + @@ -150,8 +138,7 @@ for (y=1; y<((in->height)-1); y++) out->Rpix[y][x] = (uint8_t)lval; } - if (masque & 4) - { + if (masque & 4) { lval = mat[0] * in->Gpix[y-1][x-1] + mat[1] * in->Gpix[y-1][x] + mat[2] * in->Gpix[y-1][x+1] + @@ -168,8 +155,7 @@ for (y=1; y<((in->height)-1); y++) out->Gpix[y][x] = (uint8_t)lval; } - if (masque & 2) - { + if (masque & 2) { lval = mat[0] * in->Bpix[y-1][x-1] + mat[1] * in->Bpix[y-1][x] + mat[2] * in->Bpix[y-1][x+1] + @@ -186,8 +172,7 @@ for (y=1; y<((in->height)-1); y++) out->Bpix[y][x] = (uint8_t)lval; } - if (masque & 1) - { + if (masque & 1) { lval = mat[0] * in->Apix[y-1][x-1] + mat[1] * in->Apix[y-1][x] + mat[2] * in->Apix[y-1][x+1] + @@ -211,13 +196,11 @@ out->modified = 1; return OLL_KORRECT; } /*::------------------------------------------------------------------::*/ -int -Image_raz_sides(Image_Desc *im) +int Image_raz_sides(Image_Desc *im) { int foo; -for (foo=0; foowidth; foo++) - { +for (foo=0; foowidth; foo++) { (im->Rpix[0])[foo] = 0; (im->Gpix[0])[foo] = 0; (im->Bpix[0])[foo] = 0; @@ -226,8 +209,7 @@ for (foo=0; foowidth; foo++) (im->Bpix[im->height-1])[foo] = 0; } -for (foo=0; fooheight; foo++) - { +for (foo=0; fooheight; foo++) { (im->Rpix[foo])[0] = 0; (im->Gpix[foo])[0] = 0; (im->Bpix[foo])[0] = 0; @@ -243,27 +225,22 @@ return OLL_KORRECT; /* * Arf, le grand classique :) */ -int -Image_lissage_3x3(Image_Desc *in, Image_Desc *out) +int Image_lissage_3x3(Image_Desc *in, Image_Desc *out) { int foo, x, y; -if (in == out) - { - fprintf(stderr, "Lissage 3x3: out overwrite in\n"); +if (in == out) { + fprintf(stderr, "%s: out overwrite in\n", __func__); return IMG_OVERWRITE; } -if ( (foo=Image_compare_desc(in, out)) ) - { - fprintf(stderr, "Lissage 3x3: images have differents size, %d\n", foo); +if ( (foo=Image_compare_desc(in, out)) ) { + fprintf(stderr, "%s: images have differents size, %d\n", __func__, foo); return foo; } -for (y=1; y<((in->height)-1); y++) - { - for (x=1; x<((in->width)-1); x++) - { +for (y=1; y<((in->height)-1); y++) { + for (x=1; x<((in->width)-1); x++) { foo = in->Rpix[y-1][x-1] + in->Rpix[y-1][x] + in->Rpix[y-1][x+1] + in->Rpix[y] [x-1] + in->Rpix[y] [x] + in->Rpix[y] [x+1] + @@ -292,11 +269,9 @@ return OLL_KORRECT; /* * new 14 Jan 2000 */ -int -Image_filtre_Prewitt(Image_Desc *src, Image_Desc *dst, int rotation) +int Image_filtre_Prewitt(Image_Desc *src, Image_Desc *dst, int rotation) { -static int Prewitt[] = - { +static int Prewitt[] = { 1, 1, 1, 0, 0, 0, -1, -1, -1, @@ -318,11 +293,9 @@ return OLL_KORRECT; /* * XXX cette fonction est incorrecte XXX */ -int -Image_filtre_Sobel(Image_Desc *src, Image_Desc *dst, int rotation) +int Image_filtre_Sobel(Image_Desc *src, Image_Desc *dst, int rotation) { -static int Sobel[] = - { +static int Sobel[] = { 1, 2, 1, 0, 0, 0, -1, -2, -1, @@ -343,13 +316,11 @@ return OLL_KORRECT; * Voir aussi 'sobel4.c' */ /*::------------------------------------------------------------------::*/ /* new 15 Jan 2000 */ -int -Image_filtre_passe_bas(Image_Desc *src, Image_Desc *dst) +int Image_filtre_passe_bas(Image_Desc *src, Image_Desc *dst) { int foo; -static int PasseBas[] = - { +static int PasseBas[] = { 1, 2, 1, 2, 4, 2, 1, 2, 1, @@ -363,14 +334,12 @@ return foo; /*::------------------------------------------------------------------::*/ /* nouveau: 18 Janvier 2001 moral à zéro, il faut que je fasse pédaler le 486 ! */ -int -Image_filtre_random(Image_Desc *src, Image_Desc *dst, int p1, int p2) +int Image_filtre_random(Image_Desc *src, Image_Desc *dst, int p1, int p2) { int filtre[11]; int foo, somme, v, delta; -if (p1 == p2) - { +if (p1 == p2) { fprintf(stderr, "%s: p1=%d must be different from p2=%d\n", __func__, p1, p2); return INVALID_PARAM; @@ -383,8 +352,7 @@ delta = abs(p2 - p1); fprintf(stderr, "%s: delta is %d\n", __func__, delta); #endif -for (foo=0; foo<9; foo++) - { +for (foo=0; foo<9; foo++) { v = (rand()%delta)+p1; filtre[foo] = v; somme += v; @@ -405,15 +373,14 @@ return FUNC_IS_BETA; /* nouveau: 3 Fevrier 2001 on s'inspire de la precedente. */ -int -Image_filtre_random_2(Image_Desc *src, Image_Desc *dst, +int Image_filtre_random_2(Image_Desc *src, Image_Desc *dst, int p1, int p2, int p3, int p4) { int filtre[11]; int foo, somme, v, delta, deltb; #if DEBUG_LEVEL -fprintf(stderr, "Filtre Random 2: %d %d / %d %d\n", p1, p2, p3, p4); +fprintf(stderr, "%s: %d %d / %d %d\n", __func__, p1, p2, p3, p4); #endif delta = abs(p2 - p1); @@ -423,22 +390,18 @@ fprintf(stderr, "Filtre Random 2: delta are %d %d\n", delta, deltb); #endif somme = 0; -for (foo=0; foo<9; foo++) - { - if (foo != 4) - { +for (foo=0; foo<9; foo++) { + if (foo != 4) { v = (rand()%delta)+p1; } - else - { + else { v = (rand()%deltb)+p3; } filtre[foo] = v; - somme += v; } -filtre[9] = somme; +filtre[9] = somme; filtre[10] = 0; /* XXX calcul automatique a faire ! */ Image_filtre_display(stdout, filtre); @@ -448,12 +411,10 @@ foo = Image_convolueur_2(src, dst, filtre, "rgb"); return FUNC_IS_BETA; } /*::------------------------------------------------------------------::*/ -int -Image_filtre_passe_haut(Image_Desc *src, Image_Desc *dst) +int Image_filtre_passe_haut(Image_Desc *src, Image_Desc *dst) { int foo; -static int PasseHaut[] = - { +static int PasseHaut[] = { -1, -1, -1, -1, 8, -1, -1, -1, -1, diff --git a/Lib/glitch.c b/Lib/glitch.c index 2b3da18..e598e71 100644 --- a/Lib/glitch.c +++ b/Lib/glitch.c @@ -124,6 +124,9 @@ for (nbre=0; nbreheight; v++) Image_plotRGB(dst, x, v, r, g, b); break; + default: + fprintf(stderr, "blurg in %s\n", __func__); + return PASTIS; } } diff --git a/Lib/image.c b/Lib/image.c index f0a3b4a..3f6d600 100644 --- a/Lib/image.c +++ b/Lib/image.c @@ -487,19 +487,16 @@ return (int)((img->Apix[y])[x]); cette fonction ne marche que si les deux images sont allouees et de meme dimensions. */ -int -Image_copy(Image_Desc *src, Image_Desc *dst) +int Image_copy(Image_Desc *src, Image_Desc *dst) { int foo; -if ( (foo=Image_compare_desc(src, dst)) ) - { - fprintf(stderr, "Image_Copy: images are differents %d\n", foo); +if ( (foo=Image_compare_desc(src, dst)) ) { + fprintf(stderr, "%s: images are differents %d\n", __func__, foo); return foo; } -for (foo=0; fooheight; foo++) - { +for (foo=0; fooheight; foo++) { memcpy(dst->Rpix[foo], src->Rpix[foo], src->width); memcpy(dst->Gpix[foo], src->Gpix[foo], src->width); memcpy(dst->Bpix[foo], src->Bpix[foo], src->width); @@ -523,8 +520,7 @@ return 0; /* * no boundary control ? */ -int -Image_pixel_copy(Image_Desc *s, int x, int y, Image_Desc *d, int i, int j) +int Image_pixel_copy(Image_Desc *s, int x, int y, Image_Desc *d, int i, int j) { (d->Rpix[j])[i] = (s->Rpix[y])[x]; @@ -538,8 +534,7 @@ return OLL_KORRECT; * Le nom de cette fonction n'a pas trop de rapport avec ce qu'elle fait, * mais elle permet de faire reculer Crash Coredump. */ -int -Image_compare_desc(Image_Desc *a, Image_Desc *b) +int Image_compare_desc(Image_Desc *a, Image_Desc *b) { char *fmt = "Image at %p have no 'Dead Beef' in it\n"; diff --git a/Lib/msglib.c b/Lib/msglib.c index 96fe4e7..c5054d8 100644 --- a/Lib/msglib.c +++ b/Lib/msglib.c @@ -9,13 +9,11 @@ #include "../tthimage.h" /*::------------------------------------------------------------------::*/ -char * -Image_type2str(int type) +char * Image_type2str(int type) { char *pstr; -switch (type) - { +switch (type) { case IMAGE_RGB: pstr = "RGB"; break; case IMAGE_RGBA: pstr = "RGBA"; break; case IMAGE_GRAY: pstr = "Gray"; break; @@ -29,14 +27,12 @@ switch (type) return pstr; } /*::------------------------------------------------------------------::*/ -char * -Image_err2str(int codeerr) +char * Image_err2str(int codeerr) { char *pstr; static char chaine[100]; -switch (codeerr) - { +switch (codeerr) { case -1: pstr = "error: invalid error"; break; case OLL_KORRECT: pstr = "no error"; break; case 42: pstr = "Universal answer"; break; @@ -114,7 +110,8 @@ switch (codeerr) sprintf(chaine, "error code %d is unknow", codeerr); pstr = chaine; #if DEBUG_LEVEL - fprintf(stderr, "* WTF ? Error %d unknow ?\n", codeerr); + fprintf(stderr, "%s: WTF ? Error %d unknow ?\n", + __func__, codeerr); #if FORCE_ABORT abort(); #endif @@ -125,8 +122,7 @@ return pstr; } /*::------------------------------------------------------------------::*/ /* new 14 Feb 2000 */ -void -Image_print_error(char * texte, int err) +void Image_print_error(char * texte, int err) { FILE *fp; char *errtxt; @@ -145,4 +141,3 @@ fprintf(fp, "%s '%s': %d, %s\n", err ? "Error :" : "Waouh !", fflush(fp); } /*::------------------------------------------------------------------::*/ - diff --git a/Lib/op2x2.c b/Lib/op2x2.c index 38ce690..139a315 100644 --- a/Lib/op2x2.c +++ b/Lib/op2x2.c @@ -13,12 +13,10 @@ * 6 Fev 2001: on aimerait bien avoir la doc de cette fonction * 27 Juillet 2008: on attend toujours... */ -int -Image_2x2_contours_0(Image_Desc *im) +int Image_2x2_contours_0(Image_Desc *im) { int x, y, q; -int tbl[] = - { +int tbl[] = { 0, 1, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, @@ -29,10 +27,8 @@ int tbl[] = fprintf(stderr, "%s : w=%d h=%d\n", __func__, im->width, im->height); #endif -for (x=0; x<(im->width-1); x++) - { - for (y=0; y<(im->height-1); y++) - { +for (x=0; x<(im->width-1); x++) { + for (y=0; y<(im->height-1); y++) { q = ((im->Rpix[y] [x] ? 0 : 1) << 3 ) | ((im->Rpix[y] [x+1] ? 0 : 1) << 2 ) | ((im->Rpix[y+1][x] ? 0 : 1) << 1 ) | @@ -58,14 +54,13 @@ return OLL_KORRECT; /*::------------------------------------------------------------------::*/ /* updated 31 august 2008 */ /* le seul bit utilise dans l'image source est le bit 7 */ -int -Image_2x2_contours_1(Image_Desc *src, Image_Desc *dst) +int Image_2x2_contours_1(Image_Desc *src, Image_Desc *dst) { int foo; int x, y, q; -if ( (foo=Image_compare_desc(src, dst)) ) - { +if ( (foo=Image_compare_desc(src, dst)) ) { + fprintf(stderr, "%s: err compare %d\n", __func__, foo); return foo; } #if DEBUG_LEVEL @@ -73,10 +68,8 @@ fprintf(stderr, "*** %s *** catastrophic function :)\n", __func__); #endif Image_clear(dst, 0, 0, 0); -for (x=0; x<(src->width-1); x++) - { - for (y=0; y<(src->height-1); y++) - { +for (x=0; x<(src->width-1); x++) { + for (y=0; y<(src->height-1); y++) { q = ((0x80 & (src->Rpix[y] [x] ) ? 0 : 1) << 3 ) | ((0x80 & (src->Rpix[y] [x+1]) ? 0 : 1) << 2 ) | ((0x80 & (src->Rpix[y+1][x] ) ? 0 : 1) << 1 ) | @@ -101,8 +94,7 @@ return FUNC_IS_BETA; /* * 6 Fev 2001: on aimerait bien avoir la doc de cette fonction */ -int -Image_2x2_contrast(Image_Desc *src, Image_Desc *dst) +int Image_2x2_contrast(Image_Desc *src, Image_Desc *dst) { int foo, x, y, r, g, b; int mir, mig, mib, mar, mag, mab; @@ -110,19 +102,16 @@ int mir, mig, mib, mar, mag, mab; int dx[4] = { 0, 1, 0, 1 }; int dy[4] = { 0, 0, 1, 1 }; -if ( (foo=Image_compare_desc(src, dst)) ) - { +if ( (foo=Image_compare_desc(src, dst)) ) { + fprintf(stderr, "%s: err compare %d\n", __func__, foo); return foo; } -for (y=0; yheight-1; y++) - { - for (x=0; xwidth-1; x++) - { +for (y=0; yheight-1; y++) { + for (x=0; xwidth-1; x++) { mir = mig = mib = 342; mar = mag = mab = -42; - for (foo=0; foo<4; foo++) - { + for (foo=0; foo<4; foo++) { r = (src->Rpix[y+dy[foo]])[x+dx[foo]]; g = (src->Gpix[y+dy[foo]])[x+dx[foo]]; b = (src->Bpix[y+dy[foo]])[x+dx[foo]]; @@ -148,8 +137,7 @@ return FUNC_IS_BETA; /* * 6 Fev 2001: on aimerait bien avoir la doc de cette fonction */ -int -Image_2x2_lissage(Image_Desc *src, Image_Desc *dst) +int Image_2x2_lissage(Image_Desc *src, Image_Desc *dst) { int foo, x, y; int tir, tig, tib; @@ -157,8 +145,8 @@ int tir, tig, tib; int dx[4] = { 0, 1, 0, 1 }; int dy[4] = { 0, 0, 1, 1 }; -if ( (foo=Image_compare_desc(src, dst)) ) - { +if ( (foo=Image_compare_desc(src, dst)) ) { + fprintf(stderr, "%s: err compare %d\n", __func__, foo); return foo; } @@ -166,13 +154,10 @@ if ( (foo=Image_compare_desc(src, dst)) ) * attention, il faut bien reflechir avant de tenter d'inverser l'ordre * de parcours en ligne & colonne ! */ -for (y=0; yheight-1; y++) - { - for (x=0; xwidth-1; x++) - { +for (y=0; yheight-1; y++) { + for (x=0; xwidth-1; x++) { tir = tig = tib = 0; - for (foo=0; foo<4; foo++) - { + for (foo=0; foo<4; foo++) { tir += (src->Rpix[y+dy[foo]])[x+dx[foo]]; tig += (src->Gpix[y+dy[foo]])[x+dx[foo]]; tib += (src->Bpix[y+dy[foo]])[x+dx[foo]]; @@ -189,20 +174,16 @@ return OLL_KORRECT; /* * 8 Feb 2001: another kludge (without doc) */ -int -Image_2x2_rot4pix(Image_Desc *src, Image_Desc *dst, int rot) +int Image_2x2_rot4pix(Image_Desc *src, Image_Desc *dst, int rot) { int x, y, foo, bar, r, g, b; int dx[4] = { 0, 1, 0, 1 }; int dy[4] = { 0, 0, 1, 1 }; -for (y=0; yheight-1; y+=2) - { - for (x=0; xwidth-1; x+=2) - { - for (foo=0; foo<4; foo++) - { +for (y=0; yheight-1; y+=2) { + for (x=0; xwidth-1; x+=2) { + for (foo=0; foo<4; foo++) { bar = (foo+rot)%4; r = (src->Rpix[y+dy[foo]])[x+dx[foo]]; g = (src->Gpix[y+dy[foo]])[x+dx[foo]]; @@ -225,8 +206,8 @@ int foo; fprintf(stderr, "this func (%s) is a kluge\n", __func__); #endif -if ( (foo=Image_compare_desc(src, dst)) ) - { +if ( (foo=Image_compare_desc(src, dst)) ) { + fprintf(stderr, "%s: err compare %d\n", __func__, foo); return foo; } diff --git a/Lib/operat.c b/Lib/operat.c index ebd6926..73f5ef6 100644 --- a/Lib/operat.c +++ b/Lib/operat.c @@ -26,8 +26,7 @@ /* * XXX il y a un "Zero Divide" cache dans cette fonction ! */ -int -Image_adjust_minmax_0(Image_Desc *src, Image_Desc *dst, int yo, +int Image_adjust_minmax_0(Image_Desc *src, Image_Desc *dst, int yo, int minstone, int maxstone) { long histR[256], histG[256], histB[256]; @@ -36,8 +35,7 @@ int foo; long mini, maxi, kmini, kmaxi, delta; int idxmini, idxmaxi, val, lut[256], level; -if (yo != 0) - { +if (yo != 0) { fprintf(stderr, "Yo is %d\n", yo); } @@ -58,11 +56,9 @@ fprintf(stderr, " K maxi = %ld\n", kmaxi); mini = 0; idxmini = 0; -for (foo=0; foo<256; foo++) - { +for (foo=0; foo<256; foo++) { mini += (histR[foo] + histG[foo] + histB[foo]); - if (mini > kmini) - { + if (mini > kmini) { fprintf(stderr, "MINI %3d %ld\n", foo, mini); idxmini = foo; break; @@ -71,11 +67,9 @@ for (foo=0; foo<256; foo++) maxi = 0; idxmaxi = 255; -for (foo=255; foo>=0; foo--) - { +for (foo=255; foo>=0; foo--) { maxi += (histR[foo] + histG[foo] + histB[foo]); - if (maxi > kmaxi) - { + if (maxi > kmaxi) { fprintf(stderr, "MAXI %3d %ld\n", foo, maxi); idxmaxi = foo; break; @@ -87,8 +81,7 @@ fprintf(stderr, "idxmini=%d idxmaxi=%d delta=%ld\n", idxmini, idxmaxi, delta); for (foo=0; foo 1 -fprintf(stderr, "%s ( %p %p %d )\n", __func__, src, dst, factor); +fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, dst, factor); #endif fprintf(stderr, "luminance factor: %d %f\n", factor, (float)factor / 256.0); if ( (foo=Image_compare_desc(src, dst)) ) { - fprintf(stderr, "Image Luminance: images are differents %d\n", foo); + fprintf(stderr, "%s: images are differents %d\n", __func__, foo); return foo; } -for (y=0; yheight; y++) - { - for (x=0; xwidth; x++) - { +for (y=0; yheight; y++) { + for (x=0; xwidth; x++) { dst->Rpix[y][x] = (src->Rpix[y][x] * factor) / 256; dst->Gpix[y][x] = (src->Gpix[y][x] * factor) / 256; dst->Bpix[y][x] = (src->Bpix[y][x] * factor) / 256; @@ -156,8 +146,7 @@ return FUNC_IS_BETA; + + + + + + + + + + + + + + + + + + + + + + + + + + + + le parametre 'yoyo' n'est pas utilise actuellement. */ -int -Image_egalise_RGB(Image_Desc *src, Image_Desc *dst, int yoyo) +int Image_egalise_RGB(Image_Desc *src, Image_Desc *dst, int yoyo) { int foo; long *histr, *histg, *histb; @@ -201,8 +190,7 @@ for (foo=0; foo<256; foo++) { #if DEBUG_LEVEL > 1 fprintf(stderr, "* histo RGB: cumuls: %d %d %d surface: %ld\n", cumlr[255], cumlg[255], cumlb[255], s); -for (foo=0; foo<256; foo++) - { +for (foo=0; foo<256; foo++) { fprintf(stderr, "%3d | %7ld %7ld %7ld | %7d %7d %7d\n", foo, histr[foo], histg[foo], histb[foo], @@ -223,17 +211,15 @@ return 0; le parametre 'yoyo' n'est pas utilise actuellement. */ -int -Image_egalise_mono_0(Image_Desc *src, Image_Desc *dst, int yoyo) +int Image_egalise_mono_0(Image_Desc *src, Image_Desc *dst, int yoyo) { int foo; long c, cc, s3; long *histr, *histg, *histb; int cumul[256]; -if ( (foo=Image_compare_desc(src, dst)) ) - { - fprintf(stderr, "Image_Egalise_Mono_0: images are differents %d\n", foo); +if ( (foo=Image_compare_desc(src, dst)) ) { + fprintf(stderr, "%s: images are differents %d\n", __func__, foo); return foo; } @@ -252,8 +238,7 @@ Image_histo_RGB(src, histr, histg, histb); s3 = (3 * src->width * src->height); cc = 0L; -for (foo=0; foo<256; foo++) - { +for (foo=0; foo<256; foo++) { c = histr[foo] + histg[foo] + histb[foo]; cc += c; cumul[foo] = (int)((cc*255) / s3); @@ -268,17 +253,13 @@ return 0; complement d'une image complete (c.a.d tous les canaux contenus dans cette image) */ -int -Image_negate(Image_Desc *image, Image_Desc *resultat) +int Image_negate(Image_Desc *image, Image_Desc *resultat) { int x, y; -if (image->type == 3) - { - for (y=0; yheight; y++) - { - for (x=0; xwidth; x++) - { +if (image->type == 3) { + for (y=0; yheight; y++) { + for (x=0; xwidth; x++) { resultat->Rpix[y][x] = image->Rpix[y][x] ^ 0xff; resultat->Gpix[y][x] = image->Gpix[y][x] ^ 0xff; resultat->Bpix[y][x] = image->Bpix[y][x] ^ 0xff; @@ -287,8 +268,9 @@ if (image->type == 3) return 0; } -fprintf(stderr, "Image Negate: unknow image type %d, %s\n", - image->type, Image_type2str(image->type)); +fprintf(stderr, "%s: unknow image type %d, %s\n", + __func__, image->type, Image_type2str(image->type)); + return IMAGE_BAD_TYPE; } @@ -568,27 +550,22 @@ return retval; } /*::------------------------------------------------------------------::*/ -int -Image_seuil_RGB(Image_Desc *s, Image_Desc *d, int r, int g, int b) +int Image_seuil_RGB(Image_Desc *s, Image_Desc *d, int r, int g, int b) { int foo, x, y; -if ( (s->type != 3) || (d->type != 3) ) - { +if ( (s->type != 3) || (d->type != 3) ) { fprintf(stderr, "Image Seuil RGB: an image is not of type 3\n"); return IMAGE_BAD_TYPE; } -if ( (foo=Image_compare_desc(s, d)) != 0 ) - { +if ( (foo=Image_compare_desc(s, d)) != 0 ) { fprintf(stderr, "Image Seuil RGB: images are differents %d\n", foo); return foo; } -for (y=0; yheight; y++) - { - for (x=0; xwidth; x++) - { +for (y=0; yheight; y++) { + for (x=0; xwidth; x++) { if(s->Rpix[y][x] > r) d->Rpix[y][x] = 255; else d->Rpix[y][x] = 0; if(s->Gpix[y][x] > g) d->Gpix[y][x] = 255; diff --git a/Lib/recurse.c b/Lib/recurse.c index 25b2701..516a74d 100644 --- a/Lib/recurse.c +++ b/Lib/recurse.c @@ -19,12 +19,10 @@ static Image_Desc *S, *D; static int seuil; static int level, maxlevel; -static int -recursion(Image_Rect *pRect) +static int recursion(Image_Rect *pRect) { Image_Rect rect; int h1, h2, w1, w2, xx, yy, foo; - int mr, mg, mb, dr, dg, db, s; level++; @@ -43,13 +41,11 @@ printf(" %7d V %3d %3d %3d D %3d %3d %3d S %3d (%d)\n", pRect->w*pRect->h, mr, mg, mb, dr, dg, db, s, foo); #endif -if ( (s < seuil) || (pRect->w < 6) || (pRect->h < 6) ) - { +if ( (s < seuil) || (pRect->w < 6) || (pRect->h < 6) ) { Image_paint_rect(D, pRect, mr, mg, mb); /* printf(" paint %d %d %d\n", mr, mg, mb); */ } -else - { +else { Image_paint_rect(D, pRect, 255, 0, 0); /* Image_dump_rect(pRect, "R", 0); */ @@ -113,10 +109,9 @@ return 0; } /*::------------------------------------------------------------------::*/ /* - * a quoi peut bien servir le parametre ? + * a quoi peut bien servir le parametre ? */ -int -Image_call_recursion_0(Image_Desc *image, Image_Desc *dest, int param) +int Image_call_recursion_0(Image_Desc *image, Image_Desc *dest, int param) { Image_Rect rect; int foo; diff --git a/Lib/text0.c b/Lib/text0.c index db610ee..e040fcc 100644 --- a/Lib/text0.c +++ b/Lib/text0.c @@ -30,13 +30,12 @@ static uint8_t priv_fonte[T_FONTE]; /* * for now, parameter *ou must be NULL */ -int -Image_load_fnt8x8(char *nomfnt, uint8_t *ou, int flags) +int Image_load_fnt8x8(char *nomfnt, uint8_t *ou, int flags) { int fd, foo; -#if DEBUG_LEVEL > 1 -fprintf(stderr, "%s: %s %p %d\n", __func__, nomfnt, ou, flags); +#if DEBUG_LEVEL > -1 +fprintf(stderr, ">>> %s ( '%s' %p %d )\n", __func__, nomfnt, ou, flags); #endif if (NULL != ou) @@ -51,15 +50,13 @@ if (NULL == nomfnt) { } /* on pourrait aussi mettre la fonte par ddefaut dans l'environ */ -if ( (fd=Image_must_open(nomfnt, O_RDONLY, 0)) < 0 ) - { +if ( (fd=Image_must_open(nomfnt, O_RDONLY, 0)) < 0 ) { perror (nomfnt); exit(5); } foo = read(fd, priv_fonte, T_FONTE); -if ( foo != T_FONTE ) - { +if ( foo != T_FONTE ) { fprintf(stderr, "%s: error when reading font datas\n", __func__); exit(5); } @@ -75,8 +72,7 @@ return OLL_KORRECT; /* * XXX nasty bug in the alpha channel gestion XXX */ -int -Image_trace_caractere_2(Image_Desc *im, uint8_t *fnt, int x, int y, int code, +int Image_trace_caractere_2(Image_Desc *im, uint8_t *fnt, int x, int y, int code, RGBA *paper, RGBA *ink) { int foo, bar, xi, yi; @@ -88,17 +84,14 @@ fprintf(stderr, "trace car 2: xy= %4d %4d c= %c\n", x, y, isprint(code) ? code : ' '); #endif -if (NULL==fnt) - { +if (NULL==fnt) { fnt = priv_fonte; /* use local static storage */ } -for (foo=0; foo<8; foo++) - { +for (foo=0; foo<8; foo++) { yi = y+foo; octet = fnt[(code*8)+foo]; - for (bar=0; bar<8; bar++) - { + for (bar=0; bar<8; bar++) { xi = x+7-bar; /* lecture contenu image */ @@ -106,14 +99,12 @@ for (foo=0; foo<8; foo++) gs = (im->Gpix[yi])[xi]; bs = (im->Bpix[yi])[xi]; - if (octet & 1) /* ENCRE */ - { + if (octet & 1) { /* ENCRE */ rp = ((rs*(255-ink->a))+(ink->r*ink->a)) / 255; gp = ((gs*(255-ink->a))+(ink->g*ink->a)) / 255; bp = ((bs*(255-ink->a))+(ink->b*ink->a)) / 255; } - else /* PAPIER */ - { + else { /* PAPIER */ rp = ((rs*(255-paper->a))+(paper->r*paper->a)) / 255; gp = ((gs*(255-paper->a))+(paper->g*paper->a)) / 255; bp = ((bs*(255-paper->a))+(paper->b*paper->a)) / 255; @@ -131,17 +122,14 @@ return 42; /* * fonction très primitive... */ -int -Image_trace_caractere(Image_Desc *im, int x, int y, int code) +int Image_trace_caractere(Image_Desc *im, int x, int y, int code) { int foo, bar; uint8_t octet; -for (foo=0; foo<8; foo++) - { +for (foo=0; foo<8; foo++) { octet = priv_fonte[(code*8)+foo]; - for (bar=0; bar<8; bar++) - { + for (bar=0; bar<8; bar++) { if (octet & 1) Image_plotRGB(im, x+8-bar, y+foo, 255, 255, 255); else @@ -214,11 +202,9 @@ fprintf(stderr, "encre %3d %3d %3d %3d\n", ink->r, ink->g, ink->b, ink->a); #endif posx = x; posy = y; -for (foo=0; foo (im->width-8)) - { + if (posx > (im->width-8)) { fprintf(stderr, "can't plot char '%c' at x=%d\n", octet, posx); break; } diff --git a/Lib/text16x24.c b/Lib/text16x24.c index 9e61a52..3c32124 100644 --- a/Lib/text16x24.c +++ b/Lib/text16x24.c @@ -213,11 +213,12 @@ int Image_t16x24_pltstr_1(Image_Desc *img, char *str, int x, int y, { int len, foo; -len = strlen(str); #if DEBUG_LEVEL -fprintf(stderr, "%s: '%s' at %d,%d\n", __func__, str, x, y); +fprintf(stderr, ">>> %s: '%s' at %d,%d\n", __func__, str, x, y); #endif +len = strlen(str); + for (foo=0; foo 1 fprintf(stderr, "%4d %c\n", foo, str[foo]); @@ -225,7 +226,8 @@ for (foo=0; foo +#include +#include + +#ifdef NEED_ALLOCA_H +#include +#endif + +#include "../tthimage.h" + +/*::------------------------------------------------------------------::*/ +Image_cos010(Image_Desc *src, Image_Desc *dst) +{ +int foo; + +if ( (foo=Image_compare_desc(src, dst)) ) { + fprintf(stderr, "%s: images not compatible, %d\n", __func__, foo); + return foo; + } + +return FULL_NUCKED; +} +/*::------------------------------------------------------------------::*/ +/*::------------------------------------------------------------------::*/ diff --git a/Paramakes.mk b/Paramakes.mk index 686c883..f63ea15 100644 --- a/Paramakes.mk +++ b/Paramakes.mk @@ -22,7 +22,7 @@ HTML_DIR=$(DESTDIR)/html # use -Wmissing-prototypes ? LIBIMG_OPT=-DFORCE_ABORT=1 -DDEBUG_LEVEL=0 -DIMGCOMMENT=0 -CC_OPTS=-Wall -W -g -ansi -O3 -fPIC -no-pie +CC_OPTS=-Wall -W -g -pg -ansi -O3 -fPIC -no-pie CC_HACKS=-DNEED_ALLOCA_H CFLAGS= $(CC_OPTS) \ $(LIBIMG_OPT) \ diff --git a/tthimage.h b/tthimage.h index 606654e..2b1c2fb 100644 --- a/tthimage.h +++ b/tthimage.h @@ -4,7 +4,7 @@ http:///la.buvette.org/devel/libimage/ */ #ifndef IMAGE_VERSION_STRING - #define IMAGE_VERSION_STRING "0.4.51 pl 21" + #define IMAGE_VERSION_STRING "0.4.51 pl 28" /*::------------------------------------------------------------------::*/ /*