From d298f63e7e8df8b692d33c2083bfed6e40324838 Mon Sep 17 00:00:00 2001 From: tTh Date: Fri, 15 Nov 2024 17:47:09 +0100 Subject: [PATCH] add 2 missing tools --- Tools/.gitignore | 2 ++ Tools/Makefile | 6 ++++ Tools/tga_plothisto.c | 61 +++++++++++++++++++++++++++++++++++++++++ Tools/tga_plotmap.c | 64 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 133 insertions(+) create mode 100644 Tools/tga_plothisto.c create mode 100644 Tools/tga_plotmap.c diff --git a/Tools/.gitignore b/Tools/.gitignore index 5da6fce..bd4fa26 100644 --- a/Tools/.gitignore +++ b/Tools/.gitignore @@ -4,3 +4,5 @@ tga_extract tga_to_text +tga_plothisto +tga_plotmap diff --git a/Tools/Makefile b/Tools/Makefile index 5f71913..7c0223a 100644 --- a/Tools/Makefile +++ b/Tools/Makefile @@ -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 gcc $(CFLAGS) $< ../libtthimage.a fonctions.o -lm -o $@ diff --git a/Tools/tga_plothisto.c b/Tools/tga_plothisto.c new file mode 100644 index 0000000..5c87bd8 --- /dev/null +++ b/Tools/tga_plothisto.c @@ -0,0 +1,61 @@ +/* + utilitaire pour plotter les histogrammes d'une image. + ----------------------------------------------------- +*/ + +#include +#include + +#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; +} diff --git a/Tools/tga_plotmap.c b/Tools/tga_plotmap.c new file mode 100644 index 0000000..cd6a2e7 --- /dev/null +++ b/Tools/tga_plotmap.c @@ -0,0 +1,64 @@ +/* + ---------------------------------------------- + utilitaire pour tracer une map 'a la fractint' + ---------------------------------------------- + http://tth.zouh.org/libimage.html + ---------------------------------------------- +*/ + +#include +#include + +#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; +}