more clean...

This commit is contained in:
tTh 2022-08-22 17:53:30 +02:00
parent ce49cc7a08
commit 530d2755d3
9 changed files with 65 additions and 75 deletions

View File

@ -3,6 +3,7 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <math.h> #include <math.h>
#include "../tthimage.h" #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); fprintf(stderr, "%s: %p px=%d py=%d k=%d\n", __func__, img, parX, parY, k);
#endif #endif
if (k) {
fprintf(stderr, "%s: k (%d) muste be 0\n", __func__, k);
}
for (y=0; y<h; y++) for (y=0; y<h; y++)
{ {
for (foo=0; foo<parX; foo++) for (foo=0; foo<parX; foo++)
@ -41,6 +46,13 @@ int foo;
fprintf(stderr, "%s ( %p %d %d )\n", __func__, img, k0, k1); fprintf(stderr, "%s ( %p %d %d )\n", __func__, img, k0, k1);
#endif #endif
if (k0) {
fprintf(stderr, "%s: k0 (%d) muste be 0\n", __func__, k0);
}
if (k1) {
fprintf(stderr, "%s: k1 (%d) muste be 0\n", __func__, k1);
}
for (x=0; x<img->width; x++) for (x=0; x<img->width; x++)
{ {
for (foo=0; foo<k1; foo++) for (foo=0; foo<k1; foo++)

View File

@ -191,6 +191,9 @@ int Image_degouline_0(Image_Desc *source, Image_Desc *but, int k1, int k2)
int x, y; int x, y;
int foo; int foo;
#if DEBUG_LEVEL
fprintf(stderr, ">> %s ( %p %p %d %d )\n", __func__, source, but, k1, k2);
#endif
fprintf(stderr, "Degouline %d %d\n", k1, k2); fprintf(stderr, "Degouline %d %d\n", k1, k2);
if ( (foo=Image_compare_desc(source, but)) ) { if ( (foo=Image_compare_desc(source, but)) ) {
@ -198,10 +201,6 @@ if ( (foo=Image_compare_desc(source, but)) ) {
return foo; return foo;
} }
#if DEBUG_LEVEL
fprintf(stderr, "%s ( %p %p %d %d )\n", __func__, source, but, k1, k2);
#endif
for (x=0; x<source->width; x++) for (x=0; x<source->width; x++)
{ {

View File

@ -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 foo, x, y, r, g, b;
int cr, cg, cb; 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)) ) if ( (foo=Image_compare_desc(src, dst)) )
{ {
fprintf(stderr, "Image effect x 0: images are differents %d\n", foo); fprintf(stderr, "Image effect x 0: images are differents %d\n", foo);
return foo; return foo;
} }
#if DEBUG_LEVEL
fprintf(stderr, "*** Effect X_0: coeffs: %d %d %d\n", kr, kg, kb);
#endif
cr = cg = cb = 0; cr = cg = cb = 0;
for (y=0; y<dst->height; y++) for (y=0; y<dst->height; y++)
@ -159,6 +159,7 @@ return FUNC_IS_BETA;
* 27 Oct 2003: je debugge pendant que le thé infuse :) * 27 Oct 2003: je debugge pendant que le thé infuse :)
* 16 Mai 2005: je commence a ecrire la documentation. * 16 Mai 2005: je commence a ecrire la documentation.
* 29 sept 2015: je devrais finir la doc d'ici 2 ans. * 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 int
@ -168,16 +169,16 @@ int foo, sx, sy;
int x, y, r, g, b; int x, y, r, g, b;
int cx, cy, dx, dy; 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)) ) if ( (foo=Image_compare_desc(src, dst)) )
{ {
fprintf(stderr, "%s: images are differents %d\n", __func__, foo); fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
return 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) if (strlen(comp) != 2)
{ {
fprintf(stderr, "eff x3: bad comp parameter '%s'\n", comp); fprintf(stderr, "eff x3: bad comp parameter '%s'\n", comp);

View File

@ -24,23 +24,19 @@ Image_save_color_Map(char *file, char *name, RGB_map *map)
int foo; int foo;
FILE *fp; FILE *fp;
if ( (fp=fopen(file, "w")) == NULL ) if ( (fp=fopen(file, "w")) == NULL ) {
{
fprintf(stderr, "Save Color Map: err fopen\n"); fprintf(stderr, "Save Color Map: err fopen\n");
return FILE_CREATE_ERR; return FILE_CREATE_ERR;
} }
if ( map->nbre == 0 ) if ( map->nbre == 0 ) {
{
fprintf(stderr, "Save Color Map: empty map\n"); fprintf(stderr, "Save Color Map: empty map\n");
} }
for (foo=0; foo<map->nbre; foo++) for (foo=0; foo<map->nbre; foo++) {
{
fprintf(fp, "%3d %3d %3d", fprintf(fp, "%3d %3d %3d",
map->red[foo], map->green[foo], map->blue[foo]); map->red[foo], map->green[foo], map->blue[foo]);
switch (foo) switch (foo) {
{
case 0: case 0:
if (name != NULL) if (name != NULL)
fprintf(fp, " Name: %s", name); fprintf(fp, " Name: %s", name);
@ -85,20 +81,17 @@ FILE *fp;
int nbre, r, g, b, foo, errcode; int nbre, r, g, b, foo, errcode;
char buffer[256]; char buffer[256];
if ( name != NULL ) if ( name != NULL ) {
{ if (strlen(name)>IMG_OBJNAME_LEN) return STRING_TOO_LONG;
if (strlen(name)>IMG_OBJNAME_LEN)
return STRING_TOO_LONG;
strcpy(where->name, name); strcpy(where->name, name);
} }
else strcpy(where->name, "no name"); else strcpy(where->name, "no name");
/* /*
* patch du 11 Décembre 2001: on utilise une fonction qui recherche le * 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 */ /* safety poke */
where->nbre = 0; where->nbre = 0;
fprintf(stderr, "Load color MAP: %s not found\n", file); 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; nbre = 0; errcode = 0;
where->nbre = 0; /* kill bad value */ 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); foo = sscanf(buffer, "%d %d %d", &r, &g, &b);
if (foo != 3) if (foo != 3) {
{
fprintf(stderr, "line %d: [%s]\n", nbre, buffer); fprintf(stderr, "line %d: [%s]\n", nbre, buffer);
errcode = BAD_COLOR_NUMBER; break; errcode = BAD_COLOR_NUMBER; break;
} }
@ -120,8 +111,7 @@ while ( fgets(buffer, 250, fp) != NULL )
where->green[nbre] = g; where->green[nbre] = g;
where->blue[nbre] = b; where->blue[nbre] = b;
nbre++; nbre++;
if (nbre > 256) if (nbre > 256) {
{
fprintf(stderr, "load color map: nbre = %d\n", nbre); fprintf(stderr, "load color map: nbre = %d\n", nbre);
errcode = MAP_TOO_BIG; break; errcode = MAP_TOO_BIG; break;
} }
@ -146,8 +136,7 @@ int foo;
fprintf(stderr, "Image attach Map: cette fonction n'est pas finie\n"); fprintf(stderr, "Image attach Map: cette fonction n'est pas finie\n");
foo = Image_load_color_Map(nom_map, "", &map); foo = Image_load_color_Map(nom_map, "", &map);
if (foo == 0) if (foo == 0) {
{
fprintf(stderr, "Attach Map: foo is zero ?\n"); fprintf(stderr, "Attach Map: foo is zero ?\n");
} }
@ -163,15 +152,13 @@ int foo;
fprintf(stderr, "making a random map named '%s'\n", nom); 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); fprintf(stderr, "make random map: nbre = %d\n", map->nbre);
return BAD_COLOR_NUMBER; return BAD_COLOR_NUMBER;
} }
map->nbre = nbre; map->nbre = nbre;
for (foo=0; foo<nbre; foo++) for (foo=0; foo<nbre; foo++) {
{
map->red[foo] = rand() & 0xff; map->red[foo] = rand() & 0xff;
map->green[foo] = rand() & 0xff; map->green[foo] = rand() & 0xff;
map->blue[foo] = rand() & 0xff; map->blue[foo] = rand() & 0xff;
@ -196,8 +183,7 @@ strcpy(map->name, "* FMBL roulaize *");
map->nbre = 64; map->nbre = 64;
for (foo=0; foo<64; foo++) for (foo=0; foo<64; foo++) {
{
r = ((foo >> 0) & 0x03) * 85; r = ((foo >> 0) & 0x03) * 85;
g = ((foo >> 2) & 0x03) * 85; g = ((foo >> 2) & 0x03) * 85;
b = ((foo >> 4) & 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]); fprintf(stderr, " %3d %g\n", foo, pars[foo]);
#endif #endif
for (foo=0; foo<256; foo++) for (foo=0; foo<256; foo++) {
{
dfoo = (double)foo / 255.0 * M_PI * 2; dfoo = (double)foo / 255.0 * M_PI * 2;
dra = sin((pars[0] * dfoo) + pars[3]); dra = sin((pars[0] * dfoo) + pars[3]);
dga = sin((pars[1] * dfoo) + pars[4]); dga = sin((pars[1] * dfoo) + pars[4]);
@ -262,27 +247,23 @@ fprintf(stderr, "Image mix palette: work in progress...\n");
k2 = 10000 - k; k2 = 10000 - k;
for (idx=0; idx<256; idx++) for (idx=0; idx<256; idx++) {
{
if (idx < p1->nbre) if (idx < p1->nbre)
{ {
r1 = p1->red[idx]; r1 = p1->red[idx];
g1 = p1->green[idx]; g1 = p1->green[idx];
b1 = p1->blue[idx]; b1 = p1->blue[idx];
} }
else else {
{
r1 = g1 = b1 = 0; r1 = g1 = b1 = 0;
} }
if (idx < p2->nbre) if (idx < p2->nbre) {
{
r2 = p2->red[idx]; r2 = p2->red[idx];
g2 = p2->green[idx]; g2 = p2->green[idx];
b2 = p2->blue[idx]; b2 = p2->blue[idx];
} }
else else {
{
r2 = g2 = b2 = 0; r2 = g2 = b2 = 0;
} }
@ -315,19 +296,16 @@ int foo;
int maxval = -99999; int maxval = -99999;
#endif #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", fprintf(stderr, "%s: RGB_map %p has %d entries ?\n",
__func__, p, p->nbre); __func__, p, p->nbre);
} }
for (foo=0; foo<p->nbre; foo++) for (foo=0; foo<p->nbre; foo++) {
{
p->red[foo] = round((double)p->red[foo] * v); p->red[foo] = round((double)p->red[foo] * v);
p->green[foo] = round((double)p->green[foo] * v); p->green[foo] = round((double)p->green[foo] * v);
p->blue[foo] = round((double)p->blue[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] < 0) p->red[foo] = 0;
if (p->red[foo] > 255) p->red[foo] = 255; if (p->red[foo] > 255) p->red[foo] = 255;
if (p->green[foo] < 0) p->green[foo] = 0; 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; 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", fprintf(stderr, "%s: RGB_map %p has %d entries ?\n",
__func__, p, p->nbre); __func__, p, p->nbre);
} }
for (foo=0; foo<p->nbre; foo++) for (foo=0; foo<p->nbre; foo++) {
{
p->red[foo] = round((double)p->red[foo] * rk); p->red[foo] = round((double)p->red[foo] * rk);
p->green[foo] = round((double)p->green[foo] * gk); p->green[foo] = round((double)p->green[foo] * gk);
p->blue[foo] = round((double)p->blue[foo] * bk); 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] < 0) p->red[foo] = 0;
if (p->red[foo] > 255) p->red[foo] = 255; if (p->red[foo] > 255) p->red[foo] = 255;
if (p->green[foo] < 0) p->green[foo] = 0; 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); fprintf(stderr, "%s (( %p '%s' '%s' ))\n", __func__, p, fname, comment);
#endif #endif
if (NULL==p) if (NULL == p) {
{
fprintf(stderr, "in %s, can't gruik au nill map\n", __func__); fprintf(stderr, "in %s, can't gruik au nill map\n", __func__);
abort(); abort();
} }
@ -405,8 +379,7 @@ if (NULL==p)
fprintf(stderr, "we have %d colors in palette at %p\n", p->nbre, p); fprintf(stderr, "we have %d colors in palette at %p\n", p->nbre, p);
#endif #endif
if ( (fp=fopen(fname, "w")) == NULL ) if ( (fp=fopen(fname, "w")) == NULL ) {
{
fprintf(stderr, "%s: err fopen %s\n", __func__, fname); fprintf(stderr, "%s: err fopen %s\n", __func__, fname);
return FILE_CREATE_ERR; return FILE_CREATE_ERR;
} }
@ -414,8 +387,8 @@ fprintf(fp, "P3\n%d 1\n255\n", p->nbre);
if (NULL != comment) { if (NULL != comment) {
fprintf(fp, "# %s\n", comment); fprintf(fp, "# %s\n", comment);
} }
for (foo=0; foo<p->nbre; foo++)
{ for (foo=0; foo<p->nbre; foo++) {
fprintf(fp, "%3d %3d %3d\n", p->red[foo], p->green[foo], p->blue[foo]); fprintf(fp, "%3d %3d %3d\n", p->red[foo], p->green[foo], p->blue[foo]);
} }

View File

@ -62,7 +62,7 @@ int foo;
fprintf(stderr, "Pixeliz X: appel de test, pas finalise.\n"); fprintf(stderr, "Pixeliz X: appel de test, pas finalise.\n");
#endif #endif
foo = Image_pixeliz_0(src, dst, 5, 15); foo = Image_pixeliz_0(src, dst, 5, 16);
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "Pixeliz X: valeur obtenue: %d\n", foo); 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"); fprintf(stderr, "Pixeliz Y: appel de test, pas finalise.\n");
#endif #endif
foo = Image_pixeliz_0(src, dst, 15, 5); foo = Image_pixeliz_0(src, dst, 16, 5);
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "Pixeliz Y: valeur obtenue: %d\n", foo); fprintf(stderr, "Pixeliz Y: valeur obtenue: %d\n", foo);

View File

@ -174,7 +174,7 @@ int len1, len2, len, foo;
len1 = len2 = 0; len1 = len2 = 0;
if (NULL != lig1) len1 = strlen(lig1); if (NULL != lig1) len1 = strlen(lig1);
if (NULL != lig2) len2 - strlen(lig2); if (NULL != lig2) len2 = strlen(lig2);
if (len2 > len1) len = len2; if (len2 > len1) len = len2;
else len = len1; else len = len1;
@ -364,6 +364,9 @@ int res[8], foo;
printf(" R G B A\n"); printf(" R G B A\n");
foo = Image_minmax_RGB(img, res); 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("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]); printf("max %4d %4d %4d %4d\n", res[1], res[3], res[5], res[7]);
return OLL_KORRECT; return OLL_KORRECT;

View File

@ -132,11 +132,9 @@ switch (commande)
break; break;
} }
#if DEBUG_LEVEL
if (foo) if (foo)
fprintf(stderr, "dither %d retour = %d, %s\n", commande, fprintf(stderr, "dither %d retour = %d, %s\n", commande,
foo, Image_err2str(foo)); foo, Image_err2str(foo));
#endif
foo = Image_TGA_save(argv[3], dst, 0); foo = Image_TGA_save(argv[3], dst, 0);

View File

@ -399,6 +399,10 @@ switch(mode)
fprintf(stderr, "Hu ho %d ?\n", mode); fprintf(stderr, "Hu ho %d ?\n", mode);
break; break;
} }
if (foo) {
fprintf(stderr, "at end of %s, foo was %d\n", __func__, foo);
}
return 0; return 0;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/

View File

@ -4,7 +4,7 @@
http:///la.buvette.org/devel/libimage/ http:///la.buvette.org/devel/libimage/
*/ */
#ifndef IMAGE_VERSION_STRING #ifndef IMAGE_VERSION_STRING
#define IMAGE_VERSION_STRING "0.4.51 pl 16" #define IMAGE_VERSION_STRING "0.4.51 pl 18"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*