importing the exporter :)
This commit is contained in:
@@ -10,7 +10,7 @@ DEPS = ../tthimage.h Makefile tga_outils.h ../libtthimage.a
|
||||
|
||||
all: genplot2 \
|
||||
tga_cadre tga_effects tga_filtres tga_remap tga_tools \
|
||||
tga_combine \
|
||||
tga_combine tga_export \
|
||||
tga_television tga_dither tga_applymap tga_makehf15 \
|
||||
tga_mires tga_incrust tga_pattern tga_equalize
|
||||
|
||||
@@ -37,6 +37,9 @@ tga_cadre: tga_cadre.c $(DEPS) fonctions.o
|
||||
tga_combine: tga_combine.c $(DEPS) fonctions.o
|
||||
gcc $(CFLAGS) $< ../libtthimage.a fonctions.o -lm -o $@
|
||||
|
||||
tga_export: tga_export.c $(DEPS) fonctions.o
|
||||
gcc $(CFLAGS) $< ../libtthimage.a fonctions.o -lm -o $@
|
||||
|
||||
tga_dither: tga_dither.c $(DEPS) fonctions.o
|
||||
gcc $(CFLAGS) $< ../libtthimage.a fonctions.o -lm -o $@
|
||||
|
||||
|
||||
120
Tools/tga_export.c
Normal file
120
Tools/tga_export.c
Normal file
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
convert a TGA image to various formats
|
||||
-----------------------------------------------
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "tga_outils.h"
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
|
||||
#define PGM0 1
|
||||
#define PGM1 2
|
||||
#define PPM0 10
|
||||
#define PHT 20
|
||||
#define BMP24 30
|
||||
#define PCX8 60
|
||||
#define PCX24 61
|
||||
#define PGMHF 80
|
||||
|
||||
mot_clef mots_clef[] =
|
||||
{
|
||||
{ "pgm0", PGM0, "c", "param: color component" },
|
||||
{ "ppm0", PPM0, "", "portable pixmap (rgb)" },
|
||||
{ "pht", PHT, "c", "param: color component" },
|
||||
{ "bmp24", BMP24, "i", "param must be 0" },
|
||||
{ "pcx8", PCX8, "i", "plop" },
|
||||
{ "pcx24", PCX24, "i", "plup" },
|
||||
{ "pgmhf", PGMHF, "", "height fields for POV" },
|
||||
{ NULL, 0, NULL, NULL }
|
||||
};
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
|
||||
void usage(int flag)
|
||||
{
|
||||
fprintf(stderr, "*** tga_export v 0.0.9 [%s] %s\n",
|
||||
TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT);
|
||||
|
||||
fprintf(stderr, "tga_export source.tga format destination.xxx [params]\n\n");
|
||||
|
||||
if (flag)
|
||||
{
|
||||
liste_mots_clefs(mots_clef, 42);
|
||||
}
|
||||
exit(5);
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/*
|
||||
* argv[1] source.tga
|
||||
* argv[2] format d'exportation
|
||||
* argv[3] destination.???
|
||||
*/
|
||||
#define FIRST_PARAM 4
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
Image_Desc *img;
|
||||
int foo;
|
||||
int idx, commande, nbargs;
|
||||
|
||||
dump_command_line(argc, argv, 0);
|
||||
|
||||
if (argc < 4) usage(1);
|
||||
|
||||
/* recherche du type d'exportation demandé */
|
||||
idx = cherche_mot_clef(argv[2], mots_clef, &commande, &nbargs);
|
||||
if (idx < 0)
|
||||
{
|
||||
fprintf(stderr, "tga_export: format %s inconnu...\n", argv[2]);
|
||||
exit (5);
|
||||
}
|
||||
if ( (argc-nbargs) != FIRST_PARAM )
|
||||
{
|
||||
fprintf(stderr, "%s: bad number of parameters\n", argv[0]);
|
||||
exit(5);
|
||||
}
|
||||
|
||||
/* analyse des paramètres */
|
||||
foo = parse_parametres(argc, argv, mots_clef[idx].ptypes, FIRST_PARAM);
|
||||
|
||||
if ( (img=Image_TGA_alloc_load(argv[1]))==NULL )
|
||||
{
|
||||
fprintf(stderr, "tga_export: can't load '%s'\n", argv[1]);
|
||||
exit(5);
|
||||
}
|
||||
|
||||
switch (commande)
|
||||
{
|
||||
case PGM0:
|
||||
foo = Image_wr_pgm_0(argv[3], img, GCP(0));
|
||||
break;
|
||||
case PPM0:
|
||||
foo = Image_wr_ppm_0(argv[3], img, 0);
|
||||
break;
|
||||
case PHT:
|
||||
foo = Image_PHT_save_component(argv[3], img, GCP(0));
|
||||
break;
|
||||
case BMP24:
|
||||
foo = Image_BMP_save_24(argv[3], img, 0);
|
||||
break;
|
||||
case PGMHF:
|
||||
/* une fonction equivalente est dans 'povhf_tools' et
|
||||
* il serait bien de mutualiser le code */
|
||||
foo = Image_hf15_save_PGM(argv[3], img, "Nice try...");
|
||||
break;
|
||||
default:
|
||||
foo = 9999;
|
||||
break;
|
||||
}
|
||||
|
||||
if (foo)
|
||||
{
|
||||
fprintf(stderr, "tga_export (%s) ", argv[2]);
|
||||
Image_print_error("ecriture fichier", foo);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
Reference in New Issue
Block a user