diff --git a/.gitignore b/.gitignore index 2045157..861a864 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,7 @@ Lib/t_t16x24 Lib/testbmp Tests/*.tga +Tests/t_t16x24 Tools/genplot2 Tools/tga_alpha diff --git a/Lib/Makefile b/Lib/Makefile index 9e422fb..791aefc 100644 --- a/Lib/Makefile +++ b/Lib/Makefile @@ -16,9 +16,11 @@ all: foo testtga alpha.o: alpha.c $(DEPS) alpha2.o: alpha2.c $(DEPS) +anamorphose.o: anamorphose.c $(DEPS) basic_io.o: basic_io.c $(DEPS) bitblt.o: bitblt.c $(DEPS) +bitplanes.o: bitplanes.c $(DEPS) bmp.o: bmp.c $(DEPS) bmp.h cadres.o: cadres.c $(DEPS) @@ -89,6 +91,7 @@ patterns2.o: patterns2.c $(DEPS) patterns3.o: patterns3.c $(DEPS) patterns4.o: patterns4.c $(DEPS) photomaton.o: photomaton.c $(DEPS) +pcx.o: pcx.c $(DEPS) pht.o: pht.c $(DEPS) pixeliz.o: pixeliz.c $(DEPS) pixels.o: pixels.c $(DEPS) @@ -104,6 +107,8 @@ pov_hf15f.o: pov_hf15f.c $(DEPS) pov_synth.o: pov_synth.c $(DEPS) ptlist.o: ptlist.c $(DEPS) +quadpics.o: quadpics.c $(DEPS) + recurse.o: recurse.c $(DEPS) rgbmask.o: rgbmask.c $(DEPS) @@ -119,6 +124,7 @@ text1.o: text1.c $(DEPS) text16x24.o: text16x24.c $(DEPS) tga.o: tga.c $(DEPS) tools.o: tools.c $(DEPS) +turtle.o: turtle.c $(DEPS) vignetize.o: vignetize.c $(DEPS) @@ -132,11 +138,11 @@ zoom.o: zoom.c $(DEPS) #----------------------------------------------------------------- OBJECTS = 7seg.o \ - alpha.o alpha2.o \ - basic_io.o bitblt.o bmp.o \ + alpha.o alpha2.o anamorphose.o \ + basic_io.o bitblt.o bitplanes.o bmp.o \ cadres2.o cadres3.o cadres4.o cadres84.o cadresbox.o \ cadres.o \ - calculs.o classif.o \ + calcluts.o calculs.o classif.o \ col4bits.o colors.o colors2.o col_reduc.o col_xyz.o \ combine.o combine2.o combine3.o combine4.o combine5.o \ combine6.o combine_rnd.o \ @@ -155,22 +161,24 @@ OBJECTS = 7seg.o \ operat.o op2x2.o \ palettes.o \ patterns.o patterns2.o patterns3.o patterns4.o \ + pcx.o \ photomaton.o pht.o pixeliz.o pixels.o plotteur.o \ pnm.o png.o \ pov_hf15a.o pov_hf15b.o pov_hf15c.o pov_hf15d.o \ pov_hf15e.o pov_hf15e.o pov_hf15f.o pov_synth.o \ ptlist.o \ + quadpics.o \ recurse.o rgbmask.o \ scale.o sobel4.o stereo.o \ tamppool.o tele_2.o television.o \ text0.o text1.o text16x24.o \ - tga.o tools.o \ + tga.o tools.o turtle.o \ vignetize.o \ warp0.o warp1.o warp2.o warp3.o \ zoom.o ../libtthimage.a: $(OBJECTS) - $(AR) vrs $@ $? + $(AR) rs $@ $? $(RANLIB) $@ #----------------------------------------------------------------- @@ -178,16 +186,12 @@ OBJECTS = 7seg.o \ foo: foo.c $(DEPS) ../libtthimage.a gcc $(CFLAGS) $< ../libtthimage.a -o $@ -t_t16x24: t_t16x24.c $(DEPS) ../libtthimage.a - gcc $(CFLAGS) $< ../libtthimage.a -o $@ - t_png: t_png.c $(DEPS) ../libtthimage.a gcc $(CFLAGS) $< ../libtthimage.a -lpng -lz -o $@ testbmp: testbmp.c $(DEPS) ../libtthimage.a gcc $(CFLAGS) $< ../libtthimage.a -lm -o $@ - #----------------------------------------------------------------- essais.o: essais.c $(DEPS) essais.h diff --git a/Lib/anamorphose.c b/Lib/anamorphose.c index 378c3cf..65c5cff 100644 --- a/Lib/anamorphose.c +++ b/Lib/anamorphose.c @@ -7,7 +7,7 @@ #include #include -#include "tthimage.h" +#include "../tthimage.h" /*::------------------------------------------------------------------::*/ int @@ -16,16 +16,14 @@ Image_anmo_X(Image_Desc *src, Image_Desc *dst) int x, y; double dnormx, dnormy; -fprintf(stderr, "%s : %p -> %p\n", __func__, src, dst); +fprintf(stderr, ">>> %s: %p -> %p\n", __func__, src, dst); /* * we scan the destination picture */ -for (y=0; yheight; y++) - { +for (y=0; yheight; y++) { dnormy = (double)y/(double)dst->height; - for (x=0; xwidth; x++) - { + for (x=0; xwidth; x++) { dnormx = (double)x/(double)dst->width; @@ -73,10 +71,8 @@ double xamp, yamp; long nb_in, nb_out; #endif -image = Image_alloc(w, h, 3); -if (image==NULL) - { - fprintf(stderr, "%s: Abend: no mem\n", __FILE__); +if (NULL==(image = Image_alloc(w, h, 3))) { + fprintf(stderr, "%s %s : Abend: no mem\n", __FILE__, __func__); exit(5); } diff --git a/Lib/bitplanes.c b/Lib/bitplanes.c index 9f76c72..03420d7 100644 --- a/Lib/bitplanes.c +++ b/Lib/bitplanes.c @@ -12,7 +12,7 @@ #include "../tthimage.h" -#define VERSION_STRING "5 octobre 2015" +#define VERSION_STRING "7 juiller 2022" /*::------------------------------------------------------------------::*/ /*:: private variables */ @@ -45,7 +45,7 @@ int taille; uint8_t *pbits; #if DEBUG_LEVEL -fprintf(stderr, "%s ( %d %d )\n", __func__, w, h); +fprintf(stderr, ">>> %s ( %d %d )\n", __func__, w, h); #endif /* is there a sanity check on the dimensions ? */ @@ -90,7 +90,7 @@ int Image_free_that_BP(A_BitPlane *bp, int k) { #if DEBUG_LEVEL -fprintf(stderr, "%s ( %p %d )\n", __func__, bp, k); +fprintf(stderr, ">>> %s ( %p %d )\n", __func__, bp, k); #endif if (bp->magic != MAGIC_BIT_PLANE) { @@ -117,7 +117,7 @@ return FUNC_IS_ALPHA; int Image_BP_setname(A_BitPlane *bp, const char *name) { #if DEBUG_LEVEL -fprintf(stderr, "%s ( %p '%s' )\n", __func__, bp, name); +fprintf(stderr, ">>> %s ( %p '%s' )\n", __func__, bp, name); #endif if (MAGIC_BIT_PLANE != bp->magic) { @@ -186,10 +186,9 @@ offbit = x % 8; fprintf(stderr, " offbyte %d, offbit %d\n", offbyte, offbit); fprintf(stderr, " avant 0x%02x\n", bp->plane[offbyte]); #endif -if (bit) - bp->plane[offbyte] |= (1 << offbit); -else - bp->plane[offbyte] &= ~(1 << offbit); + +if (bit) bp->plane[offbyte] |= (1 << offbit); +else bp->plane[offbyte] &= ~(1 << offbit); #if DEBUG_LEVEL > 1 fprintf(stderr, " apres 0x%02x\n", bp->plane[offbyte]); @@ -243,7 +242,7 @@ fprintf(stderr, "%s ( %p '%s' 0x%03x )\n", __func__, bp, fname, k); if (NULL==(fp=fopen(fname, "w"))) { - fprintf(stderr, "fucked in %s\n", __func__); + fprintf(stderr, "fucked in %s on file '%s'\n", __func__, fname); return FULL_NUCKED; } @@ -252,17 +251,14 @@ fprintf(fp, "# written by libtthimage v %s\n# bitplane module '%s'\n", IMAGE_VERSION_STRING, VERSION_STRING); chariot = 0; -for (y=0; yheight; y++) - { - for (x=0; xwidth; x++) - { +for (y=0; yheight; y++) { + for (x=0; xwidth; x++) { Image_BP_pget(bp, x, y, &v); if (v) fputc('1', fp); else fputc('0', fp); if (chariot++ < 74) fputc(' ', fp); - else - { + else { fputc('\n', fp); chariot=0; } } diff --git a/Lib/calcluts.c b/Lib/calcluts.c index be67048..ec3d99d 100644 --- a/Lib/calcluts.c +++ b/Lib/calcluts.c @@ -14,7 +14,7 @@ #include #endif -#include "tthimage.h" +#include "../tthimage.h" /*::------------------------------------------------------------------::*/ int diff --git a/Lib/combine.c b/Lib/combine.c index f4f8893..16d6d03 100644 --- a/Lib/combine.c +++ b/Lib/combine.c @@ -244,6 +244,9 @@ for (y=0; yheight; y++) b2 = (s2->Bpix[y])[x]; coef = (fx2+fy2)/dmax; + if (1==yo) { + coef = cos(coef); + } if (coef < 0.0) coef = 0.0; if (coef > 1.0) coef = 1.0; @@ -253,6 +256,7 @@ for (y=0; yheight; y++) (d->Bpix[y])[x] = (int)(b1*(1.0-coef)+b2*coef); } + fprintf(stderr, "x %4d y %4d c %f\n", x, y, coef); } return OLL_KORRECT; diff --git a/Lib/combine5.c b/Lib/combine5.c index a26356e..4de83dd 100644 --- a/Lib/combine5.c +++ b/Lib/combine5.c @@ -21,20 +21,17 @@ int r2, g2, b2; int rd, gd, bd; double k, ka, kb; -if ( (foo=Image_compare_desc(s1, s2)) ) - { - fprintf(stderr, "V degrade: sources err: %s\n", Image_err2str(foo)); +if ( (foo=Image_compare_desc(s1, s2)) ) { + fprintf(stderr, "%s: sources err: %s\n", __func__, Image_err2str(foo)); return foo; } -for (y=0; yheight; y++) - { +for (y=0; yheight; y++) { k = (double)y/(double)s1->height; if (sens) { ka = k; kb = 1.0 - ka; } else { kb = k; ka = 1.0 - kb; } - for (x=0; xwidth; x++) - { + for (x=0; xwidth; x++) { Image_getRGB(s1, x, y, &r1, &g1, &b1); Image_getRGB(s2, x, y, &r2, &g2, &b2); rd = (int)((double)r1*ka+(double)r2*(kb)); @@ -57,19 +54,16 @@ int r2, g2, b2; int rd, gd, bd; double k, ka, kb; -if ( (foo=Image_compare_desc(s1, s2)) ) - { - fprintf(stderr, "H degrade: sources err: %s\n", Image_err2str(foo)); +if ( (foo=Image_compare_desc(s1, s2)) ) { + fprintf(stderr, "%s: sources err: %s\n", __func__, Image_err2str(foo)); return foo; } -for (x=0; xwidth; x++) - { +for (x=0; xwidth; x++) { k = (double)x/(double)s1->width; if (sens) { ka = k; kb = 1.0-ka; } else { kb = k; ka = 1.0-kb; } - for (y=0; yheight; y++) - { + for (y=0; yheight; y++) { Image_getRGB(s1, x, y, &r1, &g1, &b1); Image_getRGB(s2, x, y, &r2, &g2, &b2); rd = (int)((double)r1*ka+(double)r2*(kb)); @@ -96,14 +90,12 @@ int foo; fprintf(stderr, "%s:%d:%s: no such function or procedure\n", __FILE__, __LINE__, __func__); -if ( (foo=Image_compare_desc(s1, s2)) ) - { - fprintf(stderr, "D degrade: sources err: %s\n", Image_err2str(foo)); +if ( (foo=Image_compare_desc(s1, s2)) ) { + fprintf(stderr, "%s: sources err: %s\n", __func__, Image_err2str(foo)); return foo; } -if ( (foo=Image_compare_desc(s1, dst)) ) - { - fprintf(stderr, "D degrade: dst err: %s\n", Image_err2str(foo)); +if ( (foo=Image_compare_desc(s1, dst)) ) { + fprintf(stderr, "%s: dst err: %s\n", __func__, Image_err2str(foo)); return foo; } @@ -120,30 +112,25 @@ int Image_combine_Vsplit(Image_Desc *s1, Image_Desc *s2, Image_Desc *d, int foo, x, y; #if DEBUG_LEVEL -fprintf(stderr, "%s ( %p %p %p %d %d )\n", __func__, s1, s2, d, xv, uh); +fprintf(stderr, ">>> %s ( %p %p %p %d %d )\n", __func__, s1, s2, d, xv, uh); #endif if (0 != uh) fprintf(stderr, "%s : uh must be 0 and not %d\n", __func__, uh); -if ( (foo=Image_compare_desc(s1, s2)) ) - { +if ( (foo=Image_compare_desc(s1, s2)) ) { fprintf(stderr, "%s : src err: %s\n", __func__, Image_err2str(foo)); return foo; } -for (y=0; yheight; y++) - { - for (x=0; xwidth; x++) - { - if (xheight; y++) { + for (x=0; xwidth; x++) { + if (xRpix[y])[x] = (s1->Rpix[y])[x]; (d->Gpix[y])[x] = (s1->Gpix[y])[x]; (d->Bpix[y])[x] = (s1->Bpix[y])[x]; } - else - { + else { (d->Rpix[y])[x] = (s2->Rpix[y])[x]; (d->Gpix[y])[x] = (s2->Gpix[y])[x]; (d->Bpix[y])[x] = (s2->Bpix[y])[x]; @@ -163,7 +150,7 @@ int Image_combine_Hsplit(Image_Desc *s1, Image_Desc *s2, Image_Desc *d, int x, y; #if DEBUG_LEVEL -fprintf(stderr, "%s (%p %p %p %d %d)\n", __func__, s1, s2, d, yv, uh); +fprintf(stderr, ">>> %s ( %p %p %p %d %d )\n", __func__, s1, s2, d, yv, uh); #endif if (0 != uh) diff --git a/Lib/contours.c b/Lib/contours.c index d266786..a664282 100644 --- a/Lib/contours.c +++ b/Lib/contours.c @@ -4,7 +4,7 @@ #include -#include "tthimage.h" +#include "../tthimage.h" /*::------------------------------------------------------------------::*/ /* diff --git a/Lib/detect2.c b/Lib/detect2.c index 4f8ae89..57509e0 100644 --- a/Lib/detect2.c +++ b/Lib/detect2.c @@ -4,7 +4,7 @@ */ #include -#include "tthimage.h" +#include "../tthimage.h" /*::------------------------------------------------------------------::*/ /* @@ -17,6 +17,10 @@ int foo, val; int x, y; long nbre; +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( %p %d %p )\n", __func__, img, seuilr, ptl); +#endif + nbre = 0; for (y=0; yheight; y++) { diff --git a/Lib/effects.c b/Lib/effects.c index 2540425..2b8beee 100644 --- a/Lib/effects.c +++ b/Lib/effects.c @@ -100,22 +100,18 @@ Image_noise(Image_Desc *source, Image_Desc *but, int intensite) { int x, y, r, g, b, foo; -if ( (foo=Image_compare_desc(source, but)) ) - { - fprintf(stderr, "%s : images are differents %d\n", __func__, foo); - return foo; - } +if ( (foo=Image_compare_desc(source, but)) ) { + fprintf(stderr, "%s : images are differents %d\n", __func__, foo); + return foo; + } -if (intensite < 1) - { - fprintf(stderr, "%s : bad intensity %d\n", __func__, intensite); - intensite = 1; - } +if (intensite < 1) { + fprintf(stderr, "%s : bad intensity %d\n", __func__, intensite); + intensite = 1; + } -for (x=0; xwidth; x++) - { - for (y=0; yheight; y++) - { +for (x=0; xwidth; x++) { + for (y=0; yheight; y++) { r = Image_clamp_pixel((source->Rpix[y])[x] + (rand()%intensite) - (intensite/2)); g = Image_clamp_pixel((source->Gpix[y])[x] diff --git a/Lib/gray_ops.c b/Lib/gray_ops.c index 99c97db..bc8caae 100644 --- a/Lib/gray_ops.c +++ b/Lib/gray_ops.c @@ -5,7 +5,7 @@ #include #include -#include "tthimage.h" +#include "../tthimage.h" /*::------------------------------------------------------------------::*/ int Image_gray_ops_0(Image_Desc *src, Image_Desc *dst, int k, int mask) diff --git a/Lib/imprime.c b/Lib/imprime.c index 2559593..1e1b1e2 100644 --- a/Lib/imprime.c +++ b/Lib/imprime.c @@ -7,15 +7,13 @@ #include "../tthimage.h" /*::------------------------------------------------------------------::*/ -int -Image_print_histo_0(long *histo, char *fname, char *texte) +int Image_print_histo_0(long *histo, char *fname, char *texte) { int foo; -printf("** %s **\n", texte); +printf("** %s / %s **\n", texte, fname); -for (foo=0; foo<256; foo++) - { +for (foo=0; foo<256; foo++) { printf("%7ld ", histo[foo]); if ((foo % 8)==0) printf("\n"); @@ -36,8 +34,7 @@ unsigned long grand; unsigned char *ucptr; int foo; -if (NULL != texte) - { +if (NULL != texte) { printf("============= %s ============\n", texte); } @@ -57,16 +54,16 @@ for (foo=0; foo>> %s ( %p %d )\n", __func__, dst, flag); #endif -if (dst->width != 256 || dst->height != 256) - { +if (flag) { + fprintf(stderr, "flag is %d in %s\n", flag, __func__); + } + +if (dst->width != 256 || dst->height != 256) { fprintf(stderr, "Image mire RGB 0: image is not 256x256\n"); return IMAGE_BAD_DIMS; } -for (x=0; x<256; x++) - { - for (y=0; y<256; y++) - { +for (x=0; x<256; x++) { + for (y=0; y<256; y++) { (dst->Rpix[y])[x] = x; (dst->Gpix[y])[x] = y; (dst->Bpix[y])[x] = (y+x)/2; diff --git a/Lib/octree.c b/Lib/octree.c index eacd043..5961864 100644 --- a/Lib/octree.c +++ b/Lib/octree.c @@ -11,7 +11,7 @@ #include -#include "tthimage.h" +#include "../tthimage.h" /*::------------------------------------------------------------------::*/ /* @@ -22,7 +22,7 @@ Image_octree_0(Image_Desc *src, Image_Desc *dst) { #if DEBUG -fprintf(stderr, "%s ( %p %p )\n", __func__, src, dst); +fprintf(stderr, ">>> %s ( %p %p )\n", __func__, src, dst); #endif return FULL_NUCKED; @@ -33,7 +33,7 @@ Image_octree_1(Image_Desc *src, Image_Desc *dst) { #if DEBUG -fprintf(stderr, "%s ( %p %p )\n", __func__, src, dst); +fprintf(stderr, ">>> %s ( %p %p )\n", __func__, src, dst); #endif return FULL_NUCKED; diff --git a/Lib/palettes.c b/Lib/palettes.c index de461fc..d1daca5 100644 --- a/Lib/palettes.c +++ b/Lib/palettes.c @@ -411,6 +411,9 @@ if ( (fp=fopen(fname, "w")) == NULL ) return FILE_CREATE_ERR; } fprintf(fp, "P3\n%d 1\n255\n", p->nbre); +if (NULL != comment) { + fprintf(fp, "# %s\n", comment); + } for (foo=0; foonbre; foo++) { fprintf(fp, "%3d %3d %3d\n", p->red[foo], p->green[foo], p->blue[foo]); diff --git a/Lib/patterns3.c b/Lib/patterns3.c index eb36d0e..91f65cc 100644 --- a/Lib/patterns3.c +++ b/Lib/patterns3.c @@ -99,7 +99,7 @@ for (x=0; xwidth; x++) for (y=0; yheight; y++) { dy = (double)x / (double)dst->height; - r = (int)round(256.0 * sqrt(dx * dy)); + r = (int)round(256.0 * sqrt(dx * dy)); /* XXX */ g = b = rand() & 0xf0; Image_plotRGB(dst, x, y, r, g, b); } diff --git a/Lib/pixeliz.c b/Lib/pixeliz.c index 0523df8..4a54216 100644 --- a/Lib/pixeliz.c +++ b/Lib/pixeliz.c @@ -58,10 +58,14 @@ Image_pixeliz_X(Image_Desc *src, Image_Desc *dst) { int foo; +#if DEBUG_LEVEL fprintf(stderr, "Pixeliz X: appel de test, pas finalise.\n"); +#endif foo = Image_pixeliz_0(src, dst, 5, 13); +#if DEBUG_LEVEL fprintf(stderr, "Pixeliz X: valeur obtenue: %d\n", foo); +#endif return foo; } diff --git a/Lib/pixels.c b/Lib/pixels.c index 9c994b5..96fdfd0 100644 --- a/Lib/pixels.c +++ b/Lib/pixels.c @@ -9,7 +9,7 @@ int Image_XOR_pixel(Image_Desc *img, int x, int y, int r, int g, int b) { -int pr, pg, pb, a; +int pr, pg, pb; if ( (x<0) || (y<0) || (x>=img->width) || (y>=img->height) ) { diff --git a/Lib/png.c b/Lib/png.c index 5d9ff97..d34ef5e 100644 --- a/Lib/png.c +++ b/Lib/png.c @@ -42,7 +42,7 @@ fprintf(stderr, "%s ( '%s' %d )\n", __func__, fname, k); writepng_version_info(); #endif -return 666; +return NULL; } /*::------------------------------------------------------------------::*/ int Image_save_as_PNG(Image_Desc *img, char *fname, int p1, int p2) diff --git a/Lib/pov_hf15c.c b/Lib/pov_hf15c.c index 860d256..c65855c 100644 --- a/Lib/pov_hf15c.c +++ b/Lib/pov_hf15c.c @@ -19,30 +19,25 @@ * * Le coefficient K va de 0 a 10000 ! */ -int -Image_hf15_mix(Image_Desc *s1, Image_Desc *s2, Image_Desc *dst, int k) +int Image_hf15_mix(Image_Desc *s1, Image_Desc *s2, Image_Desc *dst, int k) { int foo, x, y, h1, h2, hd; #if DEBUG_LEVEL -fprintf(stderr, "%s: k = %d\n", __func__, k); +fprintf(stderr, ">>> %s: k = %d\n", __func__, k); #endif -if ( (foo=Image_compare_desc(s1, s2)) ) - { +if ( (foo=Image_compare_desc(s1, s2)) ) { fprintf(stderr, "hf15 mix: err on sources: %s\n", Image_err2str(foo)); return foo; } -if ( (foo=Image_compare_desc(s1, dst)) ) - { +if ( (foo=Image_compare_desc(s1, dst)) ) { fprintf(stderr, "hf15 mix: err on dest: %s\n", Image_err2str(foo)); return foo; } -for (y=0; yheight; y++) - { - for (x=0; xwidth; x++) - { +for (y=0; yheight; y++) { + for (x=0; xwidth; x++) { h1 = Image_hf15_height(s1, x, y); h2 = Image_hf15_height(s2, x, y); hd = ((h1*k) + (h2*(10000-k))) / 10000; @@ -63,26 +58,21 @@ return FUNC_IS_BETA; * new 5 Janvier 2003 * il y a probablement des problemes d'overflow ici. */ -int -Image_hf15_mult_i(Image_Desc *s1, Image_Desc *s2, Image_Desc *dst) +int Image_hf15_mult_i(Image_Desc *s1, Image_Desc *s2, Image_Desc *dst) { int foo, x, y, h1, h2, hd; -if ( (foo=Image_compare_desc(s1, s2)) ) - { +if ( (foo=Image_compare_desc(s1, s2)) ) { fprintf(stderr, "hf15 mult i: err on srces: %s\n", Image_err2str(foo)); return foo; } -if ( (foo=Image_compare_desc(s1, dst)) ) - { +if ( (foo=Image_compare_desc(s1, dst)) ) { fprintf(stderr, "hf15 mult: err on dest: %s\n", Image_err2str(foo)); return foo; } -for (y=0; yheight; y++) - { - for (x=0; xwidth; x++) - { +for (y=0; yheight; y++) { + for (x=0; xwidth; x++) { h1 = Image_hf15_height(s1, x, y); h2 = Image_hf15_height(s2, x, y); hd = (h1 * h2) / 32768; @@ -96,21 +86,17 @@ return FUNC_IS_BETA; } /*::------------------------------------------------------------------::*/ /* nouveau 17 novembre 2009 - avenue St Exupery */ -int -Image_hf15_mult_k(Image_Desc *s, Image_Desc *d, float dk) +int Image_hf15_mult_k(Image_Desc *s, Image_Desc *d, float dk) { int foo, x, y, h1, h2; -if ( (foo=Image_compare_desc(s, d)) ) - { +if ( (foo=Image_compare_desc(s, d)) ) { fprintf(stderr, "hf15 mult k: error: %s\n", Image_err2str(foo)); return foo; } -for (y=0; yheight; y++) - { - for (x=0; xwidth; x++) - { +for (y=0; yheight; y++) { + for (x=0; xwidth; x++) { h1 = Image_hf15_height(s, x, y); h2 = (int)( (float)h1 * dk ); Image_hf15_plot(d, x, y, h2); @@ -121,12 +107,11 @@ return FULL_NUCKED; } /*::------------------------------------------------------------------::*/ /* nouveau Juin 2008 - avenue St Exupery */ -int -Image_hf15_div_i(Image_Desc *s1, Image_Desc *s2, Image_Desc *dst) +int Image_hf15_div_i(Image_Desc *s1, Image_Desc *s2, Image_Desc *dst) { #if DEBUG_LEVEL -fprintf(stderr, "%s ( %p %p %p )\n", __func__, s1, s2, dst); +fprintf(stderr, ">>> %s ( %p %p %p )\n", __func__, s1, s2, dst); #endif return FULL_NUCKED; @@ -141,24 +126,20 @@ int foo; float rh, mean_a; #if DEBUG_LEVEL -fprintf(stderr, "%s ( %p , %p )\n", __func__, src, dst); +fprintf(stderr, ">>> %s ( %p , %p )\n", __func__, src, dst); #endif -if ( (foo=Image_compare_desc(src, dst)) ) - { +if ( (foo=Image_compare_desc(src, dst)) ) { fprintf(stderr, "hf15 sqrt: (failed) : %s\n", Image_err2str(foo)); return foo; } mean_a = 0.0; -for (y=0; yheight; y++) - { - for (x=0; xwidth; x++) - { +for (y=0; yheight; y++) { + for (x=0; xwidth; x++) { h = Image_hf15_height(src, x, y); - if (h < 0) - { + if (h < 0) { fprintf(stderr, "WTF ! %s %p %d,%d %d\n", __func__, src, x, y, h); @@ -178,8 +159,7 @@ return FUNC_IS_BETA; } /*::------------------------------------------------------------------::*/ /* nouveau Novembre 2008 - avenue St Exupery */ -int -Image_hf15_pow(Image_Desc *src, Image_Desc *dst, double p0w44) +int Image_hf15_pow(Image_Desc *src, Image_Desc *dst, double p0w44) { int x, y, h; int foo; @@ -188,20 +168,18 @@ float rh; float minh, maxh; #if DEBUG_LEVEL -fprintf(stderr, "%s ( %p , %p, %g )\n", __func__, src, dst, p0w44); +fprintf(stderr, ">>> %s ( %p , %p, %g )\n", __func__, src, dst, p0w44); #endif -if ( (foo=Image_compare_desc(src, dst)) ) - { +if ( (foo=Image_compare_desc(src, dst)) ) { fprintf(stderr, "%s : (fail) : %s\n", __func__, Image_err2str(foo)); return foo; } -minh = 999999.99; -maxh = -999999.99; -for (y=0; yheight; y++) - { - for (x=0; xwidth; x++) - { + +minh = 9999999.99; +maxh = -9999999.99; +for (y=0; yheight; y++) { + for (x=0; xwidth; x++) { h = Image_hf15_height(src, x, y); rh = (float)h / 32768.0; rh = pow(rh, p0w44); @@ -226,19 +204,16 @@ int foo, x, y, h; double rh; #if DEBUG_LEVEL -fprintf(stderr, "%s ( %p , %p )\n", __func__, src, dst); +fprintf(stderr, ">>> %s ( %p , %p )\n", __func__, src, dst); #endif -if ( (foo=Image_compare_desc(src, dst)) ) - { +if ( (foo=Image_compare_desc(src, dst)) ) { fprintf(stderr, "%s : (fail) : %s\n", __func__, Image_err2str(foo)); return foo; } -for (y=0; yheight; y++) - { - for (x=0; xwidth; x++) - { +for (y=0; yheight; y++) { + for (x=0; xwidth; x++) { h = Image_hf15_height(src, x, y); rh = (double)h / 32768.0; rh = exp(rh) - 1.0; @@ -254,7 +229,7 @@ return FUNC_IS_ALPHA; int Image_hf15_exp2(Image_Desc *src, Image_Desc *dst) { #if DEBUG_LEVEL -fprintf(stderr, "%s ( %p , %p )\n", __func__, src, dst); +fprintf(stderr, ">>> %s ( %p %p )\n", __func__, src, dst); #endif return FULL_NUCKED; } diff --git a/Lib/pov_hf15f.c b/Lib/pov_hf15f.c index 8157800..e7b652d 100644 --- a/Lib/pov_hf15f.c +++ b/Lib/pov_hf15f.c @@ -29,6 +29,10 @@ fprintf(stderr, "%s : img=%p hfin=%d taille=%d k=%d\n", fprintf(stderr, " pic dims : %d x %d\n", im->width, im->height); #endif +if (taille) { + fprintf(stderr, "%s : taille = %d, wtf?\n", __func__, taille); + } + /* this is really a MESS ! */ fhfin = (float)(hfin*hfin); x2 = im->width / 2; diff --git a/Lib/ptlist.c b/Lib/ptlist.c index ad2834e..1eb1ffb 100644 --- a/Lib/ptlist.c +++ b/Lib/ptlist.c @@ -12,15 +12,13 @@ #include "../tthimage.h" /*::------------------------------------------------------------------::*/ -int -Image_print_point(Image_Point *ppt) +int Image_print_point(Image_Point *ppt) { printf(" xy %-4d %-4d c %-3d h %d\n", ppt->x, ppt->y, ppt->c, ppt->h); return FUNC_IS_ALPHA; } /*::------------------------------------------------------------------::*/ -int -Image_ptl_dump(Image_PtList *pl, char *txt) +int Image_ptl_dump(Image_PtList *pl, char *txt) { fprintf(stderr, "---+---------------\n"); fprintf(stderr, " | %s\n", txt); @@ -32,8 +30,7 @@ fprintf(stderr, "---+---------------\n"); return FUNC_IS_BETA; } /*::------------------------------------------------------------------::*/ -Image_PtList * -Image_ptl_alloc(int nbre, char *name) +Image_PtList * Image_ptl_alloc(int nbre, char *name) { Image_PtList *ptr; @@ -71,8 +68,7 @@ if ( (ptr->points=malloc(sizeof(Image_Point)*nbre))==NULL) return ptr; } /*::------------------------------------------------------------------::*/ -int -Image_ptl_add(Image_PtList *ptl, int x, int y, int h, int c) +int Image_ptl_add(Image_PtList *ptl, int x, int y, int h, int c) { Image_Point *ptrpt; int newsize, idx; @@ -124,8 +120,7 @@ return FUNC_IS_BETA; * des programmes FORTRAN, beaucoup plus pointilleux sur le * formatage des données. */ -int -Image_ptl_write(char *filename, Image_PtList *ptl) +int Image_ptl_write(char *filename, Image_PtList *ptl) { FILE *fp; int foo; @@ -151,19 +146,19 @@ fclose(fp); return FUNC_IS_BETA; } /*::------------------------------------------------------------------::*/ -int -Image_ptl_read(char *filename, Image_PtList *ptl) +int Image_ptl_read(char *filename, Image_PtList *ptl) { FILE *fp; int foo; #if DEBUG_LEVEL -fprintf(stderr, "%s ( '%s' %p )\n", __func__, filename, ptl); +fprintf(stderr, ">>> %s ( '%s' %p )\n", __func__, filename, ptl); #endif if (ptl->control != 0xfde9601a) { fprintf(stderr, "%s: no deadbeef in %p\n", __func__, ptl); + fprintf(stderr, " can't read '%s'\n", filename); return 666; } @@ -174,8 +169,7 @@ return FULL_NUCKED; } /*::------------------------------------------------------------------::*/ /* destruction d'une liste de points */ -int -Image_ptl_kill(Image_PtList *ptl, char *msg) +int Image_ptl_kill(Image_PtList *ptl, char *msg) { #if DEBUG_LEVEL fprintf(stderr, "Killing point list %p for '%s'\n", ptl, msg); @@ -187,6 +181,10 @@ if (ptl->control != 0xfde9601a) return 666; } +if (NULL != msg) { + fprintf(stderr, "%s is killing %p because %s\n", __func__, ptl, msg); + } + /* killing the array */ free(ptl->points); ptl->points = NULL; ptl->control = 0; @@ -211,8 +209,7 @@ if (NULL != alloc) *alloc = ptl->alloc; return OLL_KORRECT; } /*::------------------------------------------------------------------::*/ -int -Image_ptl_get_point(Image_PtList *ptl, Image_Point *pt, int idx) +int Image_ptl_get_point(Image_PtList *ptl, Image_Point *pt, int idx) { if (ptl->control != 0xfde9601a) { @@ -241,8 +238,7 @@ fprintf(stderr, "%s: %p %d -> %d %d\n", __func__, ptl, idx, pt->x, pt->y); return FUNC_IS_BETA; } /*::------------------------------------------------------------------::*/ -int -Image_ptl_boundingbox(Image_PtList *ptl, Image_Rect *box) +int Image_ptl_boundingbox(Image_PtList *ptl, Image_Rect *box) { int xmin, ymin, xmax, ymax; int foo; diff --git a/Lib/quadpics.c b/Lib/quadpics.c index 584372d..24ace35 100644 --- a/Lib/quadpics.c +++ b/Lib/quadpics.c @@ -5,7 +5,7 @@ #include #include -#include "tthimage.h" +#include "../tthimage.h" /*::------------------------------------------------------------------::*/ /* diff --git a/Lib/scale.c b/Lib/scale.c index e145bf7..bfac8d7 100644 --- a/Lib/scale.c +++ b/Lib/scale.c @@ -33,6 +33,11 @@ fprintf(stderr, "scale simple: %p (%dx%d) -> %p (%dx%d) k:%d \n", dst, dst->width, dst->height, k); #endif +if (k) { + fprintf(stderr, "in %s, k must be zero, was %d\n", __func__, k); + return BAD_PARAMETER; + } + coefX = (float)dst->width / (float)src->width; coefY = (float)dst->height / (float)src->height; @@ -65,8 +70,8 @@ return FUNC_IS_ALPHA; } /*::------------------------------------------------------------------::*/ /* new 2 nov 2009 - ave StEx */ -/* I've lost all my mathematical concepts (la vieillesse est un naufrage) - * so I'm going to make some approximations\dots */ +/* I've lost all my mathematical concepts so I'm going to make + some approximations\dots */ static int getpix_bilin(Image_Desc *src, double fx, double fy, int *pr, int *pg, int *pb) @@ -145,6 +150,11 @@ fprintf(stderr, "scale bilinear: %p (%dx%d) -> %p (%dx%d) k:%d \n", dst, dst->width, dst->height, k); #endif +if (k) { + fprintf(stderr, "in %s, k must be zero, was %d\n", __func__, k); + return BAD_PARAMETER; + } + coefX = (double)dst->width / (double)src->width; coefY = (double)dst->height / (double)src->height; @@ -152,12 +162,10 @@ coefY = (double)dst->height / (double)src->height; fprintf(stderr, "%s : coefs %lf %lf\n", __func__, coefX, coefY); #endif -for (yd=0; ydheight; yd++) - { +for (yd=0; ydheight; yd++) { fyd = (double)yd; fys = fyd / coefY; - for (xd=0; xdwidth; xd++) - { + for (xd=0; xdwidth; xd++) { fxd = (double)xd; fxs = fxd / coefX; @@ -199,6 +207,11 @@ fprintf(stderr, "image\t%d %d, scale %f %f\n", src->width, src->height, scaleX, scaleY); #endif +if (methode) { + fprintf(stderr, "in %s, methode must be zero, was %d\n", __func__, methode); + return NULL; + } + fx = (float)src->width * scaleX; fy = (float)src->height * scaleY; @@ -221,6 +234,9 @@ fprintf(stderr, "\tnew image @ %p\n", dst); #endif foo = Image_scale_simple(src, dst, 0); +if (foo) { + fprintf(stderr, "in %s scale_simple -> %d\n", __func__, foo); + } return dst; } diff --git a/Lib/sobel4.c b/Lib/sobel4.c index a5b2c37..a60eb83 100644 --- a/Lib/sobel4.c +++ b/Lib/sobel4.c @@ -25,11 +25,9 @@ int x, y, r, g, b; memcpy(filtre, Sobel, 11*sizeof(int)); -for (foo=0; foo<4; foo++) - { +for (foo=0; foo<4; foo++) { fprintf(stderr, "sobel4: pass %d\n", foo); - if (NULL == (tmp[foo] = Image_clone(src, 0))) - { + if (NULL == (tmp[foo] = Image_clone(src, 0))) { fprintf(stderr,"Sobel 4: no memory, aborting\n"); abort(); } @@ -38,10 +36,8 @@ for (foo=0; foo<4; foo++) Image_rotate_filtre(filtre); } -for (x=0; xwidth; x++) - { - for (y=0; yheight; y++) - { +for (x=0; xwidth; x++) { + for (y=0; yheight; y++) { r = ( tmp[0]->Rpix[y][x] + tmp[1]->Rpix[y][x] + tmp[2]->Rpix[y][x] + tmp[3]->Rpix[y][x]) / 4; g = ( tmp[0]->Gpix[y][x] + tmp[1]->Gpix[y][x] + @@ -57,8 +53,7 @@ for (x=0; xwidth; x++) dst->modified = 1; -for (foo=0; foo<4; foo++) - { +for (foo=0; foo<4; foo++) { #if DEBUG_LEVEL > 1 fprintf(stderr, "%s: freeing %d\n", __func__, foo); #endif @@ -68,6 +63,3 @@ for (foo=0; foo<4; foo++) return FUNC_NOT_FINISH; } /*::------------------------------------------------------------------::*/ -/*::------------------------------------------------------------------::*/ -/*::------------------------------------------------------------------::*/ - diff --git a/Lib/stereo.c b/Lib/stereo.c index 65aa38c..05bcdf6 100644 --- a/Lib/stereo.c +++ b/Lib/stereo.c @@ -20,20 +20,17 @@ Image_combine_stereo_0(Image_Desc *gauche, Image_Desc *droite, int x, y, foo; int rouge, vert; -if ( (foo=Image_compare_desc(gauche, droite)) ) - { +if ( (foo=Image_compare_desc(gauche, droite)) ) { fprintf(stderr, "Combine Stereo 0: sources are differents (%d)\n", foo); return foo; } -if ( (foo=Image_compare_desc(gauche, stereo)) ) - { +if ( (foo=Image_compare_desc(gauche, stereo)) ) { fprintf(stderr, "Combine Stereo 0: dest have a bad dim (%d)\n", foo); return foo; } -for (y=0; yheight; y++) - { +for (y=0; yheight; y++) { for (x=0; xwidth; x++) { rouge = ( Image_R_pixel(droite, x, y)+ @@ -67,13 +64,11 @@ Image_combine_stereo_1(Image_Desc *s1, Image_Desc *s2, Image_Desc *d, int x, y, foo, cumul; int rouge, bleu; -if ( (foo=Image_compare_desc(s1, s2)) ) - { +if ( (foo=Image_compare_desc(s1, s2)) ) { fprintf(stderr, "Combine Stereo 1: sources are differents (%d)\n", foo); return foo; } -if ( (foo=Image_compare_desc(s1, d)) ) - { +if ( (foo=Image_compare_desc(s1, d)) ) { fprintf(stderr, "Combine Stereo 1: dest have a bad dim (%d)\n", foo); return foo; } @@ -84,10 +79,8 @@ fprintf(stderr, "Combine Stereo 1: coefs are %d %d %d\n", kr, kg, kb); fprintf(stderr, "Combine Stereo 1: cumul is %d\n", cumul); #endif -for (y=0; yheight; y++) - { - for (x=0; xwidth; x++) - { +for (y=0; yheight; y++) { + for (x=0; xwidth; x++) { rouge = Image_R_pixel(s2, x, y) * kr + Image_G_pixel(s2, x, y) * kg + Image_B_pixel(s2, x, y) * kb; diff --git a/Lib/turtle.c b/Lib/turtle.c index 51a8644..264bc4c 100644 --- a/Lib/turtle.c +++ b/Lib/turtle.c @@ -6,7 +6,7 @@ #include #include -#include "tthimage.h" +#include "../tthimage.h" /*::------------------------------------------------------------------::*/ int diff --git a/Lib/warp0.c b/Lib/warp0.c index a2249f9..b4b9144 100644 --- a/Lib/warp0.c +++ b/Lib/warp0.c @@ -23,7 +23,7 @@ Image_warp_essai_0(Image_Desc *src, Image_Desc *dst, double angle, { int x, y, r, g, b; long lfoo; -double arad, dheight, dwidth, tmax, dist, va; +double arad, dheight, dwidth, tmax, dist; int ofx, ofy; dheight = (double)dst->height; @@ -31,28 +31,23 @@ dwidth = (double)dst->width; lfoo = ((dst->height*dst->height)+(dst->width*dst->width)); tmax = sqrt((double)lfoo) / 2.0; -va = angle / 360.0; +#if DEBUG_LEVEL fprintf(stderr, "%s : %d,%d dh = %f dw = %f tmax = %f\n", __func__, xc, yc, dheight, dwidth, tmax); +#endif -for (y=0; yheight; y++) - { - /* - printf("------- Ligne %d -----------------\n", y); - */ +for (y=0; yheight; y++) { + /* printf("------- Ligne %d -----------------\n", y); */ arad = ((double)y / dheight) * M_PI; - for (x=0; xwidth; x++) - { + for (x=0; xwidth; x++) { dist = (double)x / dwidth; ofx = xc + (int)(sin(arad)*dist*tmax); ofy = yc + (int)(cos(arad)*dist*tmax); - /* - printf("%15f %15f %6d %6d\n", arad, dist, ofx, ofy); - */ + /* printf("%15f %15f %6d %6d\n", arad, dist, ofx, ofy); */ if ( ofx>=0 && ofxwidth && ofy>=0 && ofyheight ) { @@ -67,7 +62,7 @@ for (y=0; yheight; y++) } } -return FUNC_NOT_FINISH; +return FUNC_IS_BETA; } /*::------------------------------------------------------------------::*/ int diff --git a/Lib/warp1.c b/Lib/warp1.c index 8023d2f..5646025 100644 --- a/Lib/warp1.c +++ b/Lib/warp1.c @@ -30,11 +30,9 @@ my = dst->height / 2; sincalc = sin(arad); coscalc = cos(arad); -for (xd=0; xdwidth; xd++) - { +for (xd=0; xdwidth; xd++) { fxd = (double)(xd-mx); - for (yd=0; ydheight; yd++) - { + for (yd=0; ydheight; yd++) { fyd = (double)(yd-my); fxs = fxd * coscalc - fyd * sincalc; fys = fxd * sincalc + fyd * coscalc; @@ -42,15 +40,14 @@ for (xd=0; xdwidth; xd++) xs = (int)fxs + mx; ys = (int)fys + my; - if (xs>=0 && xswidth && ys>=0 && ysheight) - { + if (xs>=0 && xswidth && ys>=0 && ysheight) { /* Image_getRGB(src, xs, ys, &r, &g, &b); */ r = (src->Rpix[ys])[xs]; g = (src->Gpix[ys])[xs]; b = (src->Bpix[ys])[xs]; } else - { r = g = b = 142; } + { r = g = b = 127; } /* Image_plotRGB(dst, xd, yd, r, g, b); */ (dst->Rpix[yd])[xd] = r; @@ -93,11 +90,9 @@ coscalc = cos(arad); fxs = fys = 0.0; /* ? hein ? */ foo = 0; -for (xd=0; xdwidth; xd++) - { +for (xd=0; xdwidth; xd++) { fxd = (double)(xd-mx); - for (yd=0; ydheight; yd++) - { + for (yd=0; ydheight; yd++) { fyd = (double)(yd-my); @@ -106,6 +101,7 @@ for (xd=0; xdwidth; xd++) /* MAIS C'EST PAS ENCORE FINI CE TRUC ? */ /* 4 mai 2007: ben non, ya rien :) */ + /* 5 juillet 2022 : toujours pas fait ??? */ return FULL_NUCKED; } diff --git a/Lib/warp2.c b/Lib/warp2.c index c0bc230..828bf12 100644 --- a/Lib/warp2.c +++ b/Lib/warp2.c @@ -4,6 +4,7 @@ */ #include +#include #include #include "../tthimage.h" @@ -19,7 +20,7 @@ int x, y; int x2, y2, foo; #if DEBUG_LEVEL -fprintf(stderr, "*** Image_shift_xy: work in progress...\n"); +fprintf(stderr, "*** %s: work in progress...\n", __func__); fprintf(stderr, "src=%p dst=%p ox=%d oy=%d\n", src, dst, ox, oy); #endif @@ -62,23 +63,55 @@ return FUNC_IS_BETA; /* et elle coredumpe ? */ /* OPTIMIZED FOR SPEED */ int Image_shift_x(Image_Desc *src, Image_Desc *dst, int ox) { +unsigned char *buffer; +int foo, line; #if DEBUG_LEVEL fprintf(stderr, "*** %s : work in progress...\n", __func__); fprintf(stderr, "%p -> sX(%d) -> %p\n", src, ox, dst); #endif +if ( (foo=Image_compare_desc(src, dst)) ) + { + fprintf(stderr, "%s: images are differents %d\n", __func__, foo); + return foo; + } + +if (NULL==(buffer=malloc(src->width))) { + fprintf(stderr, "%s: malloc(%d) fail.\n", __func__, src->width); +#if MUST_ABORT + abort(); +#endif + exit(1); + } + +for (line=0; linewidth; line++) { + + /* do something here */ + + } + +free(buffer); + return FULL_NUCKED; } /*::------------------------------------------------------------------::*/ /* OPTIMIZED FOR SPEED */ int Image_shift_y(Image_Desc *src, Image_Desc *dst, int oy) { +int foo; + #if DEBUG_LEVEL fprintf(stderr, "*** %s : work in progress...\n", __func__); fprintf(stderr, "%p -> sY(%d) -> %p\n", src, oy, dst); #endif +if ( (foo=Image_compare_desc(src, dst)) ) + { + fprintf(stderr, "%s: images are differents %d\n", __func__, foo); + return foo; + } + return FULL_NUCKED; } /*::------------------------------------------------------------------::*/ diff --git a/Paramakes.mk b/Paramakes.mk index c23f7af..6cc87eb 100644 --- a/Paramakes.mk +++ b/Paramakes.mk @@ -1,5 +1,6 @@ # # GLOBAL MAKE CONFIGURATION +# For the "tTh" image library # DESTDIR=/usr/local @@ -18,9 +19,10 @@ HTML_DIR=$(DESTDIR)/html # --> see file 'PORTING.txt' for porting tips on misc # architextures (just sparc64 for now) # +# use -Wmissing-prototypes ? LIBIMG_OPT=-DFORCE_ABORT=1 -DDEBUG_LEVEL=0 -DIMGCOMMENT=0 -CC_OPTS=-Wall -W -g -ansi -Wmissing-prototypes -fPIC -no-pie +CC_OPTS=-Wall -W -g -ansi -O3 -fPIC -no-pie CC_HACKS=-DNEED_ALLOCA_H CFLAGS= $(CC_OPTS) \ $(LIBIMG_OPT) \ diff --git a/Tests/Makefile b/Tests/Makefile new file mode 100644 index 0000000..dc1cc13 --- /dev/null +++ b/Tests/Makefile @@ -0,0 +1,14 @@ +#----------------------------------------------------------------- + +include ../Paramakes.mk + +DEPS = ../tthimage.h ../Paramakes.mk Makefile + +all: t_t16x24 + +#----------------------------------------------------------------- + +t_t16x24: t_t16x24.c $(DEPS) ../libtthimage.a + gcc $(CFLAGS) $< ../libtthimage.a -o $@ + +#----------------------------------------------------------------- diff --git a/Lib/t_t16x24.c b/Tests/t_t16x24.c similarity index 92% rename from Lib/t_t16x24.c rename to Tests/t_t16x24.c index 0d2d814..2d92369 100644 --- a/Lib/t_t16x24.c +++ b/Tests/t_t16x24.c @@ -18,6 +18,10 @@ RGBA encre, papier; img = Image_TGA_alloc_load(tgasrc); foo = Image_t16x24_txtload("16x24thin", NULL, 0); +if (foo) { + fprintf(stderr, "%s err %d loading font '16x24thin'\n", __func__, foo); + return foo; + } encre.r = 0; encre.g = 255; encre.b = 100; encre.a = 255; papier.r = 255; papier.b = 0; papier.g = 0; papier.a = 200; @@ -31,9 +35,7 @@ return -1; /*::------------------------------------------------------------------::*/ int main(int argc, char *argv[]) { -char *fichier; -int foo; -Image_Desc *image; +int foo; fprintf(stderr, "-------------- %s ------------\n", argv[0]); foo = Image_t16x24_chars_map("16x24thin", "all16x24chars.tga", 0); diff --git a/Tools/README.md b/Tools/README.md index 987dbef..ac0be1d 100644 --- a/Tools/README.md +++ b/Tools/README.md @@ -39,6 +39,7 @@ La gestion de la ligne de commande est désastreuse. **À REFAIRE** Pas mal de façons de mettre un cadre sur l'image. Niveau de kitchitude assez élevé. +Paramètres mal documentés. ## tga_combine diff --git a/Tools/fonctions.c b/Tools/fonctions.c index b8c042a..51ab5ab 100644 --- a/Tools/fonctions.c +++ b/Tools/fonctions.c @@ -127,7 +127,7 @@ memset(prect, 0, sizeof(Image_Rect)); cptr = strdup(str); #if DEBUG_LEVEL -fprintf(stder, "copie dans cptr %p\n", cptr); +fprintf(stderr, "copie dans cptr %p\n", cptr); #endif idx = 0; @@ -135,6 +135,9 @@ cptr = strtok(cptr, ","); while (NULL != cptr) { fprintf(stderr, "%3d %p = '%s'\n", idx, cptr, cptr); foo = sscanf(cptr, "%d", &val); + /* + * no error check ? + */ fprintf(stderr, "val = %d\n", val); switch (idx) { case 0: prect->x = val; break; @@ -227,7 +230,7 @@ for (foo=prem, idxt=0; foo 1 fprintf(stderr, "GetStringParameter(%d)\n", rang); #endif -if (rang<0 || params[rang].type!='s') - { +if (rang<0 || params[rang].type!='s') { fprintf(stderr, "erreur GSP %d\n", rang); exit(5); } @@ -347,8 +346,7 @@ return params[rang].p.s; double GDP(int rang) { -if (rang<0 || params[rang].type!='d') - { +if (rang<0 || params[rang].type!='d') { fprintf(stderr, "erreur GDP %d\n", rang); exit(5); } @@ -357,8 +355,7 @@ return params[rang].p.d; int GFP(int rang) { -if (rang<0 || params[rang].type!='f') - { +if (rang<0 || params[rang].type!='f') { fprintf(stderr, "erreur GFP %d\n", rang); exit(5); } @@ -395,8 +392,7 @@ fprintf(stderr, "%s : %s, argc=%d\n", __func__, argv[0], argc); envvar = getenv(NOM_VAR_ENV_VERBOSE); if ( (envvar!=NULL) && !strcmp(envvar, "yes") ) flag = 1; -if (flag || force) - { +if (flag || force) { fprintf(stderr, "TGA(%d) %d arg:", getpid(), argc); for (foo=0; foo EFF [p1] ... [p8]\n"); -if (flag) - { +if (flag) { Image_print_version(0); liste_mots_clefs(mots_clef, 42); } -else - { +else { fprintf(stderr, "\ttry 'tga_effects list' for a list.\n"); } exit(5); @@ -236,7 +236,7 @@ srand(getpid()); idx = cherche_mot_clef(argv[2], mots_clef, &commande, &nbargs); if (idx < 0) { - fprintf(stderr, "tga_effects: mot-clef %s inconnu...\n", argv[2]); + fprintf(stderr, "tga_effects: mot-clef '%s' inconnu...\n", argv[2]); exit (5); } @@ -284,6 +284,11 @@ switch (commande) case EFF_MIRROR: foo = Image_mirror(src, dst, 0); break; + case EFF_ROTULACION: /* new 6 juillet 2022 */ + angle = GDP(0); + fprintf(stderr, "%s: angle rotulacion = %f\n", __FILE__, angle); + foo = Image_center_rotate(src, dst, angle); + break; case EFF_EXTRBIT0: foo = Image_extrbits_0(src, dst, GIP(0), GIP(1), GIP(2)); break; @@ -326,9 +331,10 @@ switch (commande) case EFF_WARP_0: angle = 33.5; xc = GIP(1); yc = GIP(2); - fprintf(stderr, "WARP_0 %f %d %d\n", angle, xc, yc); foo = Image_warp_essai_0(src, dst, angle, xc, yc); - fprintf(stderr, " -> %d\n", foo); +#if DEBUG_LEVEL + fprintf(stderr, "warp0 %f %d %d > %d\n", angle, xc, yc, foo); +#endif break; case EFF_RECURSE: #if DEBUG_LEVEL diff --git a/Tools/tga_export.c b/Tools/tga_export.c index a9c32cd..d41ae93 100644 --- a/Tools/tga_export.c +++ b/Tools/tga_export.c @@ -18,6 +18,7 @@ #define PCX8 60 #define PCX24 61 #define PGMHF 80 +#define TIFF 90 mot_clef mots_clef[] = { @@ -28,6 +29,7 @@ mot_clef mots_clef[] = { "pcx8", PCX8, "i", "plop" }, { "pcx24", PCX24, "i", "plup" }, { "pgmhf", PGMHF, "", "height fields for POV" }, +{ "tiff", TIFF, "", "" }, { NULL, 0, NULL, NULL } }; @@ -35,13 +37,12 @@ mot_clef mots_clef[] = void usage(int flag) { -fprintf(stderr, "*** tga_export v 0.0.9 [%s] %s\n", +fprintf(stderr, "*** tga_export v 0.0.10 [%s] %s\n", TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT); fprintf(stderr, "tga_export source.tga format destination.xxx [params]\n\n"); -if (flag) - { +if (flag) { liste_mots_clefs(mots_clef, 42); } exit(5); @@ -65,13 +66,11 @@ if (argc < 4) usage(1); /* recherche du type d'exportation demandé */ idx = cherche_mot_clef(argv[2], mots_clef, &commande, &nbargs); -if (idx < 0) - { +if (idx < 0) { fprintf(stderr, "tga_export: format %s inconnu...\n", argv[2]); exit (5); } -if ( (argc-nbargs) != FIRST_PARAM ) - { +if ( (argc-nbargs) != FIRST_PARAM ) { fprintf(stderr, "%s: bad number of parameters\n", argv[0]); exit(5); } @@ -79,14 +78,12 @@ if ( (argc-nbargs) != FIRST_PARAM ) /* analyse des paramètres */ foo = parse_parametres(argc, argv, mots_clef[idx].ptypes, FIRST_PARAM); -if ( (img=Image_TGA_alloc_load(argv[1]))==NULL ) - { +if ( (img=Image_TGA_alloc_load(argv[1]))==NULL ) { fprintf(stderr, "tga_export: can't load '%s'\n", argv[1]); exit(5); } -switch (commande) - { +switch (commande) { case PGM0: foo = Image_wr_pgm_0(argv[3], img, GCP(0)); break; @@ -109,10 +106,10 @@ switch (commande) break; } -if (foo) - { +if (foo) { fprintf(stderr, "tga_export (%s) ", argv[2]); Image_print_error("ecriture fichier", foo); + exit(1); } return 0; diff --git a/Tools/tga_filtres.c b/Tools/tga_filtres.c index 1fa8a94..6ce420f 100644 --- a/Tools/tga_filtres.c +++ b/Tools/tga_filtres.c @@ -39,18 +39,16 @@ mot_clef mots_clef[] = /*::------------------------------------------------------------------::*/ void usage(int flag) { -fprintf(stderr, "*** tga_filtres v 0.0.17 [%s] %s\n", +fprintf(stderr, "*** tga_filtres v 0.0.18 [%s] %s\n", TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT); fprintf(stderr, "\nUsage:\n"); fprintf(stderr, "\ttga_filtres FILTR [p1] ... [pn]\n"); -if (flag) - { +if (flag) { Image_print_version(0); liste_mots_clefs(mots_clef, 42); } -else - { +else { fprintf(stderr, "\ttry 'tga_filtres list' for a list.\n"); } exit(5); @@ -77,8 +75,7 @@ srand(getpid()); /* recherche du type d'effet demandé */ idx = cherche_mot_clef(argv[2], mots_clef, &commande, &nbargs); -if (idx < 0) - { +if (idx < 0) { fprintf(stderr, "tga_filtres: mot-clef %s inconnu...\n", argv[2]); exit (5); } @@ -88,8 +85,7 @@ fprintf(stderr, "%s --> idx=%d, commande=%d, %d args\n", fprintf(stderr, "argc = %d\n", argc); #endif -if ( (argc-nbargs) != FIRST_PARAM ) - { +if ( (argc-nbargs) != FIRST_PARAM ) { fprintf(stderr, "%s: bad number of parameters\n", argv[0]); exit(5); } @@ -97,14 +93,12 @@ if ( (argc-nbargs) != FIRST_PARAM ) /* analyse des paramètres */ foo = parse_parametres(argc, argv, mots_clef[idx].ptypes, FIRST_PARAM); -if ((src = Image_TGA_alloc_load(argv[1]))==NULL) - { +if ((src = Image_TGA_alloc_load(argv[1]))==NULL) { fprintf(stderr, "tga_filtres: can't load image %s\n", argv[1]); exit(5); } -if ( (dst=Image_clone(src, 0)) == NULL ) - { +if ( (dst=Image_clone(src, 0)) == NULL ) { fprintf(stderr, "tga_filtres: can't clone %p\n", src); exit(1); } @@ -145,9 +139,10 @@ switch (commande) break; } -if (foo) - Image_print_error("filtrage ", foo); - +if (foo) { + Image_print_error("tga_filtres ", foo); + exit(1); + } foo = Image_TGA_save(argv[3], dst, 0); return 0; diff --git a/Tools/tga_incrust.c b/Tools/tga_incrust.c index 2b7f7d5..b7b9782 100644 --- a/Tools/tga_incrust.c +++ b/Tools/tga_incrust.c @@ -84,13 +84,11 @@ if (must_be_verbose()) #endif idx = cherche_mot_clef(argv[3], mots_clef, &commande, &nbargs); -if (idx < 0) - { +if (idx < 0) { fprintf(stderr, "tga_incrust: mot-clef '%s' inconnu...\n", argv[3]); exit (5); } -if ( (argc-nbargs) != FIRST_PARAM ) - { +if ( (argc-nbargs) != FIRST_PARAM ) { fprintf(stderr, "%s: bad number of parameters\n", argv[0]); #if DEBUG_LEVEL fprintf(stderr, "argc=%d nbargs=%d FIRST_PARAM=%d\n", @@ -106,14 +104,12 @@ foo = parse_parametres(argc, argv, mots_clef[idx].ptypes, FIRST_PARAM); fprintf(stderr, "parse params -> %d\n", foo); #endif -if (NULL==(where=Image_TGA_alloc_load(argv[1]))) - { +if (NULL==(where=Image_TGA_alloc_load(argv[1]))) { fprintf(stderr, "can't load %s\n", argv[1]); exit(2); } -if (NULL==(what=Image_TGA_alloc_load(argv[2]))) - { +if (NULL==(what=Image_TGA_alloc_load(argv[2]))) { fprintf(stderr, "can't load %s\n", argv[2]); exit(2); } @@ -134,8 +130,7 @@ switch (commande) Image_DeAllocate(what); free(what); foo = Image_TGA_save(argv[4], where, 0); -if (foo) - { +if (foo) { fprintf(stderr, "save -> %d\n", foo); } Image_DeAllocate(where); free(where); diff --git a/build.sh b/build.sh index 5be98f3..1f4eb91 100755 --- a/build.sh +++ b/build.sh @@ -11,3 +11,8 @@ cd Tools echo "========== in $PWD" make cd .. + +cd Tests +echo "========== in $PWD" +make +cd .. diff --git a/tthimage.h b/tthimage.h index 5a3a066..bd38e0b 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 8" + #define IMAGE_VERSION_STRING "0.4.51 pl 16" /*::------------------------------------------------------------------::*/ /*