a few cleanup + new patterns

This commit is contained in:
tTh 2023-09-22 14:15:52 +02:00
parent 7b10854729
commit 806c9b0071
11 changed files with 76 additions and 22 deletions

View File

@ -81,7 +81,7 @@ tga_extract: tga_extract.c $(DEPS) fonctions.o
# gcc $(CFLAGS) $< ../libimage.a fonctions.o -lm -o $@
tga_pattern: tga_pattern.c $(DEPS) fonctions.o
gcc $(CFLAGS) $< ../libtthimage.a fonctions.o -lm -o $@
gcc $(CFLAGS) $< ../libtthimage.a fonctions.o -lm -o $@
#-----------------------------------------------------------------

View File

@ -43,6 +43,14 @@ Paramètres mal documentés.
## tga_combine
```
Usage:
tga_combine s1.tga s2.tga MODE d.tga [PARAMS]
```
Il existe plein de façon de combiner deux images, la commande
`testtga list` vous les fera découvrir, la cinquième va vous étonner.
## tga_dither
Comment drastiquement réduire le nombre de couleurs d'une image ?
@ -67,6 +75,9 @@ La génération de diverses image de test ou de calibration.
## tga_pattern
Les résultats sont très ésotériques et l'aide en ligne est
vraiment trop nulle...
## tga_remap
## tga_television

View File

@ -159,6 +159,10 @@ cptr = strtok(cptr, ",");
while (NULL != cptr) {
fprintf(stderr, "%3d %p = '%s'\n", idx, cptr, cptr);
foo = sscanf(cptr, "%d", &val);
if (1 != foo) {
fprintf(stderr, "%s: err sscanf on '%s'\n", __func__, cptr);
exit(1);
}
/*
* no error check ?
*/

View File

@ -58,8 +58,8 @@ int main(int argc, char *argv[])
{
Image_Desc *src, *dst;
int foo;
RGB_map map;
int idx, commande, nbargs;
/* XXX RGB_map map; */
dump_command_line(argc, argv, 0);

View File

@ -101,14 +101,14 @@ Image_print_version(0);
fputs("Usage:\n", stderr);
fputs("\ttga_combine s1.tga s2.tga MODE d.tga [PARAMS]\n", stderr);
fputs("\n", stderr);
if (flag) liste_mots_clefs(les_types, 0);
if (flag) liste_mots_clefs(les_types, 42);
exit(0);
}
/*::------------------------------------------------------------------::*/
int combine_proto(Image_Desc *sa, Image_Desc *sb, Image_Desc *dest)
{
fprintf(stderr, "%p + %p -> %p\n", sa, sb, dest);
fprintf(stderr, "%s: %p + %p -> %p\n", __func__, sa, sb, dest);
return 42;
}

View File

@ -134,6 +134,10 @@ int contours_du_gris(Image_Desc *src, Image_Desc *dst)
Image_Desc *tmp;
int foo;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p )\n", src, dst);
#endif
tmp = Image_clone(src, 1);
foo = Image_to_gray(src, tmp, 0);
@ -142,13 +146,13 @@ fprintf(stderr, "to_gray %d\n", foo);
#endif
foo = Image_seuil_RGB(tmp, tmp, 64, 128, 192);
#if DEBUG_LEVEL
fprintf(stderr, "seuil rgb %d\n", foo);
#endif
fprintf(stderr, "%s: seuil rgb -> %d\n", __func__, foo);
Image_2x2_contours_0(tmp);
Image_copy(tmp, dst);
Image_DeAllocate(tmp); free(tmp);
return 42;
}
/*::------------------------------------------------------------------::*/
@ -202,7 +206,7 @@ fprintf(stderr, "%s :\n\t%p %p %s %d\n", __func__,
#endif
foo = Image_Glitch_simple(src, dst, nbre);
fprintf(stderr, "glitch simple -> %d\n", foo);
fprintf(stderr, "glitch (%s) simple -> %d\n", type, foo);
return 0;
}

View File

@ -127,12 +127,13 @@ switch (commande)
break;
}
#if DEBUG_LEVEL
if (foo)
fprintf(stderr, "retour = %d, %s\n", foo, Image_err2str(foo));
#endif
if (foo) {
fprintf(stderr, "%s: retour = %d, %s\n", argv[0],
foo, Image_err2str(foo));
}
foo = Image_TGA_save(argv[3], dst, 0);
return 0;
}
/*::------------------------------------------------------------------::*/

View File

@ -7,7 +7,7 @@
#include "../tthimage.h"
#define TGA_OUTILS_VERSION "0.61"
#define TGA_OUTILS_VERSION "0.62"
/*
* 13 Dec 2001: v0.11 a cause du 'mustopen' pour les palettes.
* 11 Fev 2002: v0.12 a cause du '-ansi' (hein Kerdeuzz, on y vient)
@ -22,7 +22,7 @@
* 18 Nov 2022: Vx.xx added parse_size_param
*/
#define TGA_OUTILS_COPYLEFT "(dwtfywl) TontonTh 2022"
#define TGA_OUTILS_COPYLEFT "(dwtfywl) TontonTh 2023"
#define TGA_WWW_SITE "http://la.buvette.org/devel/libimage/"
#define PERR(txt) fprintf(stderr, "\t| %s\n", (txt))

View File

@ -28,27 +28,35 @@ struct type
#define TEXTURE_1 21
#define TEXTURE_2 22
#define TEXTURE_3 23
#define EXPOV_0 30
#define EXPOV_0 24
#define PATT_100 30
#define PATT_101 31
#define PATT_102 32 /* new June 2003 */
#define GRAYNOISE2 40
#define RGBNOISE1 50
#define RGBNOISE2 51
#define CHECK_BW 80
#define PATT_000 90
#define PATT_001 91
#define PATT_002 92
static char no_help[] = "no help...";
mot_clef mots_clef[] =
{
{ "graynoise", GRAYNOISE, "ii", "bruit gris" },
{ "rgbnoise", RGBNOISE, "ii", "bruit RGB" },
{ "graynoise", GRAYNOISE, "ii", "bruit gris" },
{ "rgbnoise", RGBNOISE, "ii", "bruit RGB" },
{ "42", REPONSE, "ii", no_help },
{ "reponse", REPONSE, "ii", no_help },
{ "text1", TEXTURE_1, "ii", no_help },
{ "text2", TEXTURE_2, "iii", no_help },
{ "expov", EXPOV_0, "iii", no_help },
{ "cent", PATT_100, "iii", "kr kg kb" },
{ "centun", PATT_101, "iii", "kr kg kb" },
{ "centdeux", PATT_102, "iiii", no_help },
{ "first", PATT_000, "i", "byte mask" },
{ "first", PATT_000, "i", "byte mask" },
{ "second", PATT_001, "i", "magic value" },
{ "third", PATT_002, "i", "magic value" },
{ "graynoise2", GRAYNOISE2, "ii", no_help },
{ "rgbnoise1", RGBNOISE1, "iiiiii", no_help },
{ "rgbnoise2", RGBNOISE2, "iiiiii", no_help },
@ -59,7 +67,7 @@ mot_clef mots_clef[] =
/*::------------------------------------------------------------------::*/
void usage(int flag)
{
fprintf(stderr, "* Tga Pattern v 0.0.25 [%s] %s\n",
fprintf(stderr, "* Tga Pattern v 0.0.28 [%s] %s\n",
TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT);
Image_print_version(flag);
@ -87,7 +95,6 @@ RGBA rgba1, rgba2;
int commande, nbargs, idx;
dump_command_line(argc, argv, 0);
srand(getpid());
if (argc==1) usage(0);
@ -134,11 +141,14 @@ switch(commande)
break;
case RGBNOISE:
fprintf(stderr, "entering RGBNOISE\n");
foo = Image_rgb_noise_0(dst, GIP(0), GIP(1));
break;
case GRAYNOISE:
fprintf(stderr, "entering GRAYNOISE\n");
foo = Image_gray_noise_0(dst, GIP(0), GIP(1));
fprintf(stderr, "gray noise -> %d\n", foo);
break;
case TEXTURE_1:
@ -157,6 +167,21 @@ switch(commande)
foo = Image_pattern_000(dst, GIP(0));
break;
case PATT_001:
foo = Image_pattern_001(dst, GIP(0));
break;
case PATT_002:
foo = Image_pattern_002(dst, GIP(0));
break;
case PATT_100:
foo = Image_pattern_100(dst, GIP(0), GIP(1), GIP(2));
break;
case PATT_101:
foo = Image_pattern_101(dst, GIP(0), GIP(1), GIP(2));
break;
case PATT_102:
foo = Image_pattern_102(dst, GIP(0), GIP(1), GIP(2), GIP(3));
break;

View File

@ -47,7 +47,6 @@ int main(int argc, char *argv[])
Image_Desc *src, *dst;
int foo, type;
RGB_map map;
long t_debut, t_fin;
dump_command_line(argc, argv, 0);

View File

@ -149,6 +149,11 @@ if (w < 1 || h < 1)
img = Image_alloc(w, h, 3);
Image_clear(img, r, g, b);
foo = Image_TGA_save(fname, img, 0);
if (foo) {
fprintf(stderr, "%s: saving '%s' -> %d\n", __func__, fname, foo);
return foo;
}
Image_DeAllocate(img), free(img);
return 666;
}
@ -197,9 +202,10 @@ if (flag) {
posx = posy = 0;
}
if (must_be_verbose())
if (must_be_verbose()) {
fprintf(stderr, "%s:\n '%s' to '%s' with '%s' flg %d\n", \
__func__, fnin, fnout, txt, flag);
}
if ( (src=Image_TGA_alloc_load(fnin)) == NULL )
{
@ -224,6 +230,10 @@ Image_Desc *src;
long hr[256], hg[256], hb[256];
int foo;
if (flags) {
fprintf(stderr, "in %s, flags must be 0\n", __func__);
}
if ( (src=Image_TGA_alloc_load(filename)) == NULL )
{
fprintf(stderr, "tga_tools, chargement '%s' failed\n", filename);