add 2 missing tools

This commit is contained in:
tTh 2024-11-15 17:47:09 +01:00
parent 0b8cf14126
commit d298f63e7e
4 changed files with 133 additions and 0 deletions

2
Tools/.gitignore vendored
View File

@ -4,3 +4,5 @@
tga_extract tga_extract
tga_to_text tga_to_text
tga_plothisto
tga_plotmap

View File

@ -29,6 +29,12 @@ genplot2: genplot2.c $(DEPS) fonctions.o
#----------------------------------------------------------------- #-----------------------------------------------------------------
tga_plotmap: tga_plotmap.c $(DEPS) fonctions.o
gcc $(CFLAGS) $< ../libtthimage.a fonctions.o -lm -o $@
tga_plothisto: tga_plothisto.c $(DEPS) fonctions.o
gcc $(CFLAGS) $< ../libtthimage.a fonctions.o -lm -o $@
tga_to_text: tga_to_text.c $(DEPS) fonctions.o tga_to_text: tga_to_text.c $(DEPS) fonctions.o
gcc $(CFLAGS) $< ../libtthimage.a fonctions.o -lm -o $@ gcc $(CFLAGS) $< ../libtthimage.a fonctions.o -lm -o $@

61
Tools/tga_plothisto.c Normal file
View File

@ -0,0 +1,61 @@
/*
utilitaire pour plotter les histogrammes d'une image.
-----------------------------------------------------
*/
#include <stdio.h>
#include <stdlib.h>
#include "tga_outils.h"
void usage()
{
fprintf(stderr, "*** tga_plothisto v 0.1.3 [%s] %s\n",
TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT);
fprintf(stderr, "\nusage: tga_plothisto image.tga histo.tga [texte]\n\n");
Image_print_version(0);
exit(5);
}
int main (int argc, char *argv[])
{
Image_Desc *src;
long hr[256], hg[256], hb[256];
int foo;
char *texte;
dump_command_line(argc, argv, 0);
if (argc < 3)
{
/*fprintf(stderr, "argc = %d\n", argc);*/
usage();
}
if ( (src=Image_TGA_alloc_load(argv[1])) == NULL )
{
fprintf(stderr, "tga_plothisto, chargement '%s' failed\n", argv[1]);
exit(5);
}
foo = Image_histo_RGB(src, hr, hb, hg);
if (foo)
{
fprintf(stderr, "tga_plothisto, calcul histogramme: %d %s\n",
foo, Image_err2str(foo));
exit(5);
}
if (argc == 3) texte = argv[1];
else texte = argv[3];
foo = Image_plot_histo(argv[2], hr, hg, hb, texte);
if (foo)
{
fprintf(stderr, "tga_plothisto, dessin de '%s': %d %s\n",
argv[2], foo, Image_err2str(foo));
exit(5);
}
return 0;
}

64
Tools/tga_plotmap.c Normal file
View File

@ -0,0 +1,64 @@
/*
----------------------------------------------
utilitaire pour tracer une map 'a la fractint'
----------------------------------------------
http://tth.zouh.org/libimage.html
----------------------------------------------
*/
#include <stdio.h>
#include <stdlib.h>
#include "tga_outils.h"
/* ------------------------------------------------------------------ */
void usage()
{
fprintf(stderr, "* tga_plotmap v 0.1.11 [%s] %s\n",
TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT);
fprintf(stderr, "usage:\n\ttga_plotmap colors.map graphe.tga [texte]\n\n");
Image_print_version(1);
exit(5);
}
#define CLASSIC 1
#define PAPER 2
#define SQUARE 3
mot_clef mots_clef[] =
{
{ "classic", CLASSIC, "", "classic" },
{ "paper", PAPER, "", "papier" },
{ "square", SQUARE, "", "square" },
{ NULL, 0, "", NULL }
};
/* ------------------------------------------------------------------ */
int main (int argc, char *argv[])
{
RGB_map map;
int foo;
dump_command_line(argc, argv, 0);
if ((argc!=3)&&(argc!=4)) usage();
foo = Image_load_color_Map(argv[1], "tga_plotmap", &map);
if (foo)
{
fprintf(stderr, "tga_plotmap, chargement '%s': %d %s\n",
argv[1], foo, Image_err2str(foo));
exit(5);
}
fprintf(stderr, "map file %s have %d colors\n", argv[1], map.nbre);
foo = Image_plot_Map(argv[2], &map, argc==4?argv[3]:argv[1]);
if (foo)
{
fprintf(stderr, "tga_plotmap, dessin de '%s': %d %s\n",
argv[2], foo, Image_err2str(foo));
}
return 0;
}