From 530d2755d3d4f467449a2ebab3cc4f89ef7f8fce Mon Sep 17 00:00:00 2001 From: tTh Date: Mon, 22 Aug 2022 17:53:30 +0200 Subject: [PATCH] more clean... --- Lib/cadres84.c | 12 +++++++ Lib/effects2.c | 7 ++-- Lib/effects3.c | 17 ++++----- Lib/palettes.c | 87 ++++++++++++++++------------------------------ Lib/pixeliz.c | 4 +-- Lib/tools.c | 5 ++- Tools/tga_dither.c | 2 -- Tools/tga_tools.c | 4 +++ tthimage.h | 2 +- 9 files changed, 65 insertions(+), 75 deletions(-) diff --git a/Lib/cadres84.c b/Lib/cadres84.c index 73bd511..db4aa4c 100644 --- a/Lib/cadres84.c +++ b/Lib/cadres84.c @@ -3,6 +3,7 @@ */ #include +#include #include #include "../tthimage.h" @@ -17,6 +18,10 @@ h = img->height; w = img->width; fprintf(stderr, "%s: %p px=%d py=%d k=%d\n", __func__, img, parX, parY, k); #endif +if (k) { + fprintf(stderr, "%s: k (%d) muste be 0\n", __func__, k); + } + for (y=0; ywidth; x++) { for (foo=0; foo> %s ( %p %p %d %d )\n", __func__, source, but, k1, k2); +#endif fprintf(stderr, "Degouline %d %d\n", k1, k2); if ( (foo=Image_compare_desc(source, but)) ) { @@ -198,10 +201,6 @@ if ( (foo=Image_compare_desc(source, but)) ) { return foo; } -#if DEBUG_LEVEL -fprintf(stderr, "%s ( %p %p %d %d )\n", __func__, source, but, k1, k2); -#endif - for (x=0; xwidth; x++) { diff --git a/Lib/effects3.c b/Lib/effects3.c index 71f541c..6245243 100644 --- a/Lib/effects3.c +++ b/Lib/effects3.c @@ -26,16 +26,16 @@ 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; +#if DEBUG_LEVEL +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); return foo; } -#if DEBUG_LEVEL -fprintf(stderr, "*** Effect X_0: coeffs: %d %d %d\n", kr, kg, kb); -#endif - cr = cg = cb = 0; for (y=0; yheight; y++) @@ -159,6 +159,7 @@ return FUNC_IS_BETA; * 27 Oct 2003: je debugge pendant que le thé infuse :) * 16 Mai 2005: je commence a ecrire la documentation. * 29 sept 2015: je devrais finir la doc d'ici 2 ans. + * 19 aout 2022: je comprend pas ce que c'est censé faire :) * */ int @@ -168,16 +169,16 @@ int foo, sx, sy; int x, y, r, g, b; int cx, cy, dx, dy; +#if DEBUG_LEVEL +fprintf(stderr, "%s : kx %d ky %d comp '%s'\n", __func__, kx, ky, comp); +#endif + if ( (foo=Image_compare_desc(src, dst)) ) { fprintf(stderr, "%s: images are differents %d\n", __func__, foo); return foo; } -#if DEBUG_LEVEL -fprintf(stderr, "%s : kx %d ky %d comp '%s'\n", __func__, kx, ky, comp); -#endif - if (strlen(comp) != 2) { fprintf(stderr, "eff x3: bad comp parameter '%s'\n", comp); diff --git a/Lib/palettes.c b/Lib/palettes.c index d1daca5..21414f1 100644 --- a/Lib/palettes.c +++ b/Lib/palettes.c @@ -24,23 +24,19 @@ Image_save_color_Map(char *file, char *name, RGB_map *map) int foo; FILE *fp; -if ( (fp=fopen(file, "w")) == NULL ) - { +if ( (fp=fopen(file, "w")) == NULL ) { fprintf(stderr, "Save Color Map: err fopen\n"); return FILE_CREATE_ERR; } -if ( map->nbre == 0 ) - { +if ( map->nbre == 0 ) { fprintf(stderr, "Save Color Map: empty map\n"); } -for (foo=0; foonbre; foo++) - { +for (foo=0; foonbre; foo++) { fprintf(fp, "%3d %3d %3d", map->red[foo], map->green[foo], map->blue[foo]); - switch (foo) - { + switch (foo) { case 0: if (name != NULL) fprintf(fp, " Name: %s", name); @@ -85,20 +81,17 @@ FILE *fp; int nbre, r, g, b, foo, errcode; char buffer[256]; -if ( name != NULL ) - { - if (strlen(name)>IMG_OBJNAME_LEN) - return STRING_TOO_LONG; +if ( name != NULL ) { + if (strlen(name)>IMG_OBJNAME_LEN) return STRING_TOO_LONG; strcpy(where->name, name); } else strcpy(where->name, "no name"); /* * patch du 11 Décembre 2001: on utilise une fonction qui recherche le - * fichier dans differents endroits. Cf 'musopen.c' pour + de détails. + * fichier dans differents endroits. Cf 'mustopen.c' pour + de détails. */ -if ((fp=Image_must_fopen(file, "r", 0)) == NULL) - { +if ((fp=Image_must_fopen(file, "r", 0)) == NULL) { /* safety poke */ where->nbre = 0; fprintf(stderr, "Load color MAP: %s not found\n", file); @@ -108,11 +101,9 @@ if ((fp=Image_must_fopen(file, "r", 0)) == NULL) nbre = 0; errcode = 0; where->nbre = 0; /* kill bad value */ -while ( fgets(buffer, 250, fp) != NULL ) - { +while ( fgets(buffer, 250, fp) != NULL ) { foo = sscanf(buffer, "%d %d %d", &r, &g, &b); - if (foo != 3) - { + if (foo != 3) { fprintf(stderr, "line %d: [%s]\n", nbre, buffer); errcode = BAD_COLOR_NUMBER; break; } @@ -120,8 +111,7 @@ while ( fgets(buffer, 250, fp) != NULL ) where->green[nbre] = g; where->blue[nbre] = b; nbre++; - if (nbre > 256) - { + if (nbre > 256) { fprintf(stderr, "load color map: nbre = %d\n", nbre); errcode = MAP_TOO_BIG; break; } @@ -146,8 +136,7 @@ int foo; fprintf(stderr, "Image attach Map: cette fonction n'est pas finie\n"); foo = Image_load_color_Map(nom_map, "", &map); -if (foo == 0) - { +if (foo == 0) { fprintf(stderr, "Attach Map: foo is zero ?\n"); } @@ -163,15 +152,13 @@ int foo; fprintf(stderr, "making a random map named '%s'\n", nom); -if (nbre < 0 || nbre > 255) - { +if (nbre < 0 || nbre > 255) { fprintf(stderr, "make random map: nbre = %d\n", map->nbre); return BAD_COLOR_NUMBER; } map->nbre = nbre; -for (foo=0; foored[foo] = rand() & 0xff; map->green[foo] = rand() & 0xff; map->blue[foo] = rand() & 0xff; @@ -196,8 +183,7 @@ strcpy(map->name, "* FMBL roulaize *"); map->nbre = 64; -for (foo=0; foo<64; foo++) - { +for (foo=0; foo<64; foo++) { r = ((foo >> 0) & 0x03) * 85; g = ((foo >> 2) & 0x03) * 85; b = ((foo >> 4) & 0x03) * 85; @@ -232,8 +218,7 @@ for (foo=0; foo<8; foo++) fprintf(stderr, " %3d %g\n", foo, pars[foo]); #endif -for (foo=0; foo<256; foo++) - { +for (foo=0; foo<256; foo++) { dfoo = (double)foo / 255.0 * M_PI * 2; dra = sin((pars[0] * dfoo) + pars[3]); dga = sin((pars[1] * dfoo) + pars[4]); @@ -262,27 +247,23 @@ fprintf(stderr, "Image mix palette: work in progress...\n"); k2 = 10000 - k; -for (idx=0; idx<256; idx++) - { +for (idx=0; idx<256; idx++) { if (idx < p1->nbre) { r1 = p1->red[idx]; g1 = p1->green[idx]; b1 = p1->blue[idx]; } - else - { + else { r1 = g1 = b1 = 0; } - if (idx < p2->nbre) - { + if (idx < p2->nbre) { r2 = p2->red[idx]; g2 = p2->green[idx]; b2 = p2->blue[idx]; } - else - { + else { r2 = g2 = b2 = 0; } @@ -315,19 +296,16 @@ int foo; int maxval = -99999; #endif -if (p->nbre < 1 || p->nbre > 256) - { +if (p->nbre < 1 || p->nbre > 256) { fprintf(stderr, "%s: RGB_map %p has %d entries ?\n", __func__, p, p->nbre); } -for (foo=0; foonbre; foo++) - { +for (foo=0; foonbre; foo++) { p->red[foo] = round((double)p->red[foo] * v); p->green[foo] = round((double)p->green[foo] * v); p->blue[foo] = round((double)p->blue[foo] * v); - if (clip_it) - { + if (clip_it) { if (p->red[foo] < 0) p->red[foo] = 0; if (p->red[foo] > 255) p->red[foo] = 255; if (p->green[foo] < 0) p->green[foo] = 0; @@ -356,19 +334,16 @@ int Image_scale3_palette(RGB_map *p, double rk, double gk, double bk, { int foo; -if (p->nbre < 1 || p->nbre > 256) - { +if (p->nbre < 1 || p->nbre > 256) { fprintf(stderr, "%s: RGB_map %p has %d entries ?\n", __func__, p, p->nbre); } -for (foo=0; foonbre; foo++) - { +for (foo=0; foonbre; foo++) { p->red[foo] = round((double)p->red[foo] * rk); p->green[foo] = round((double)p->green[foo] * gk); p->blue[foo] = round((double)p->blue[foo] * bk); - if (clip_it) - { + if (clip_it) { if (p->red[foo] < 0) p->red[foo] = 0; if (p->red[foo] > 255) p->red[foo] = 255; if (p->green[foo] < 0) p->green[foo] = 0; @@ -395,8 +370,7 @@ int foo; fprintf(stderr, "%s (( %p '%s' '%s' ))\n", __func__, p, fname, comment); #endif -if (NULL==p) - { +if (NULL == p) { fprintf(stderr, "in %s, can't gruik au nill map\n", __func__); abort(); } @@ -405,8 +379,7 @@ if (NULL==p) fprintf(stderr, "we have %d colors in palette at %p\n", p->nbre, p); #endif -if ( (fp=fopen(fname, "w")) == NULL ) - { +if ( (fp=fopen(fname, "w")) == NULL ) { fprintf(stderr, "%s: err fopen %s\n", __func__, fname); return FILE_CREATE_ERR; } @@ -414,8 +387,8 @@ fprintf(fp, "P3\n%d 1\n255\n", p->nbre); if (NULL != comment) { fprintf(fp, "# %s\n", comment); } -for (foo=0; foonbre; foo++) - { + +for (foo=0; foonbre; foo++) { fprintf(fp, "%3d %3d %3d\n", p->red[foo], p->green[foo], p->blue[foo]); } diff --git a/Lib/pixeliz.c b/Lib/pixeliz.c index d4f7bde..05fee43 100644 --- a/Lib/pixeliz.c +++ b/Lib/pixeliz.c @@ -62,7 +62,7 @@ int foo; fprintf(stderr, "Pixeliz X: appel de test, pas finalise.\n"); #endif -foo = Image_pixeliz_0(src, dst, 5, 15); +foo = Image_pixeliz_0(src, dst, 5, 16); #if DEBUG_LEVEL fprintf(stderr, "Pixeliz X: valeur obtenue: %d\n", foo); @@ -83,7 +83,7 @@ int foo; fprintf(stderr, "Pixeliz Y: appel de test, pas finalise.\n"); #endif -foo = Image_pixeliz_0(src, dst, 15, 5); +foo = Image_pixeliz_0(src, dst, 16, 5); #if DEBUG_LEVEL fprintf(stderr, "Pixeliz Y: valeur obtenue: %d\n", foo); diff --git a/Lib/tools.c b/Lib/tools.c index 95ec4ba..08d3147 100644 --- a/Lib/tools.c +++ b/Lib/tools.c @@ -174,7 +174,7 @@ int len1, len2, len, foo; len1 = len2 = 0; if (NULL != lig1) len1 = strlen(lig1); -if (NULL != lig2) len2 - strlen(lig2); +if (NULL != lig2) len2 = strlen(lig2); if (len2 > len1) len = len2; else len = len1; @@ -364,6 +364,9 @@ int res[8], foo; printf(" R G B A\n"); foo = Image_minmax_RGB(img, res); +if (foo) { + fprintf(stderr, "in %s, minmax rgb -> %d\n", __func__, foo); + } printf("min %4d %4d %4d %4d\n", res[0], res[2], res[4], res[6]); printf("max %4d %4d %4d %4d\n", res[1], res[3], res[5], res[7]); return OLL_KORRECT; diff --git a/Tools/tga_dither.c b/Tools/tga_dither.c index d1450c5..a37c89f 100644 --- a/Tools/tga_dither.c +++ b/Tools/tga_dither.c @@ -132,11 +132,9 @@ switch (commande) break; } -#if DEBUG_LEVEL if (foo) fprintf(stderr, "dither %d retour = %d, %s\n", commande, foo, Image_err2str(foo)); -#endif foo = Image_TGA_save(argv[3], dst, 0); diff --git a/Tools/tga_tools.c b/Tools/tga_tools.c index f45eb5d..979cb88 100644 --- a/Tools/tga_tools.c +++ b/Tools/tga_tools.c @@ -399,6 +399,10 @@ switch(mode) fprintf(stderr, "Hu ho %d ?\n", mode); break; } + +if (foo) { + fprintf(stderr, "at end of %s, foo was %d\n", __func__, foo); + } return 0; } /*::------------------------------------------------------------------::*/ diff --git a/tthimage.h b/tthimage.h index bd38e0b..717ac93 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 16" + #define IMAGE_VERSION_STRING "0.4.51 pl 18" /*::------------------------------------------------------------------::*/ /*