Compare commits

..

3 Commits

Author SHA1 Message Date
tth
99b580a1d7 television compiled 2022-06-27 09:00:44 +02:00
tth
9644b43b11 television compiled 2022-06-27 09:00:29 +02:00
tth
cfe308968f three more tools compiled 2022-06-27 08:53:59 +02:00
17 changed files with 1456 additions and 24 deletions

8
.gitignore vendored
View File

@ -6,4 +6,12 @@ libimage.a
foo
Lib/foo
Lib/testtga
Lib/t_t16x24
Tools/tga_cadre
Tools/tga_tools
Tools/tga_effects
Tools/tga_filtres
Tools/tga_television

View File

@ -8,6 +8,8 @@ include ../Paramakes.mk
DEPS = ../tthimage.h ../Paramakes.mk Makefile
all: foo testtga
#-----------------------------------------------------------------
7seg.o: 7seg.c $(DEPS)
@ -37,6 +39,7 @@ combine4.o: combine4.c $(DEPS)
combine5.o: combine5.c $(DEPS)
combine6.o: combine6.c $(DEPS)
detect.o: detect.c $(DEPS)
distances.o: distances.c $(DEPS)
dither.o: dither.c $(DEPS)
dither2.o: dither2.c $(DEPS)
@ -50,10 +53,13 @@ drawpatt.o: drawpatt.c $(DEPS)
effects.o: effects.c $(DEPS)
effects2.o: effects2.c $(DEPS)
effects3.o: effects3.c $(DEPS)
extractbits.o: extractbits.c $(DEPS)
filtadapt.o: filtadapt.c $(DEPS)
filtres.o: filtres.c $(DEPS)
gadgrect.o: gadgrect.c $(DEPS)
glitch.o: glitch.c $(DEPS)
halfsize.o: halfsize.c $(DEPS)
@ -77,6 +83,7 @@ patterns.o: patterns.c $(DEPS)
patterns2.o: patterns2.c $(DEPS)
patterns3.o: patterns3.c $(DEPS)
patterns4.o: patterns4.c $(DEPS)
photomaton.o: photomaton.c $(DEPS)
pht.o: pht.c $(DEPS)
pixeliz.o: pixeliz.c $(DEPS)
pixels.o: pixels.c $(DEPS)
@ -90,12 +97,14 @@ pov_hf15f.o: pov_hf15f.c $(DEPS)
pov_synth.o: pov_synth.c $(DEPS)
ptlist.o: ptlist.c $(DEPS)
recurse.o: recurse.c $(DEPS)
rgbmask.o: rgbmask.c $(DEPS)
scale.o: scale.c $(DEPS)
sobel4.o: sobel4.c $(DEPS)
tamppool.o: tamppool.c $(DEPS)
tele_2.o: tele_2.c $(DEPS)
television.o: television.c $(DEPS)
text0.o: text0.c $(DEPS)
text1.o: text1.c $(DEPS)
@ -121,12 +130,12 @@ OBJECTS = 7seg.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 \
distances.o \
detect.o distances.o \
dither.o dither2.o dither3.o dither4.o \
doublesz.o drawalpha.o drawing.o drawpatt.o \
effects.o effects2.o effects3.o \
filtres.o \
gadgrect.o \
effects.o effects2.o effects3.o extractbits.o \
filtadapt.o filtres.o \
gadgrect.o glitch.o \
halfsize.o \
image.o imprime.o \
luts15bits.o \
@ -135,13 +144,14 @@ OBJECTS = 7seg.o \
operat.o op2x2.o \
palettes.o \
patterns.o patterns2.o patterns3.o patterns4.o \
pht.o pixeliz.o pixels.o plotteur.o \
photomaton.o pht.o pixeliz.o pixels.o plotteur.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 \
rgbmask.o \
recurse.o rgbmask.o \
scale.o sobel4.o \
tamppool.o television.o text0.o text1.o text16x24.o \
tamppool.o tele_2.o television.o \
text0.o text1.o text16x24.o \
tga.o tools.o \
vignetize.o \
warp0.o warp1.o warp2.o warp3.o \

View File

@ -6,7 +6,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "tthimage.h"
#include "../tthimage.h"
/*::------------------------------------------------------------------::*/
/*
@ -87,7 +87,7 @@ return OLL_KORRECT;
/*
* on cherche les endroits ou le niveau de gris est 'plat'.
*
* le paramètre 'r1' n'est pas utilise et doit etre mis à 0
* le parametre 'r1' n'est pas utilise et doit etre mis a 0
*/
int
Image_detect_flat_gray(Image_Desc *src, Image_Desc *dst, int param, int r1)
@ -140,7 +140,7 @@ for (y=1; y<src->height-1; y++)
}
/*
* hop, en finale, on efface les bords, et on
* marque l'image "modifiée".
* marque l'image "modifiee".
*/
(void)Image_raz_sides(dst);
dst->modified = 1;

60
Lib/extractbits.c Normal file
View File

@ -0,0 +1,60 @@
/*
* extractbits.c
* new 11 mars 2014
*/
#include <stdio.h>
#include "../tthimage.h"
/*::------------------------------------------------------------------::*/
int Image_extrbits_0(Image_Desc *src, Image_Desc *dst, int rs, int gs, int bs)
{
int x, y, foo;
int mr, mg, mb, r, g, b;
#if DEBUG_LEVEL
fprintf(stderr, "%s ( %p %p %d %d %d )\n", __func__, src, dst, rs, gs, bs);
#endif
if ( rs<0 || gs<0 || bs<0 ) {
fprintf(stderr, "%s : no negativ shift\n", __func__);
return BAD_PARAMETER;
}
if ( rs>8 || gs>8 || bs>8 ) {
fprintf(stderr, "%s : no shift > 7\n", __func__);
return BAD_PARAMETER;
}
if ( (foo=Image_compare_desc(src, dst)) ) {
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
return foo;
}
mr = 1 << rs;
mg = 1 << gs;
mb = 1 << bs;
#if DEBUG_LEVEL
fprintf(stderr, "%s masques = 0x%02x 0X%02x 0x%02x\n", __func__, mr, mg, mb);
#endif
for (y=0; y<dst->height; y++)
{
for (x=0; x<dst->width; x++)
{
r = ((src->Rpix[y])[x] & mr) ? 255 : 0;
dst->Rpix[y][x] = r;
g = ((src->Gpix[y])[x] & mg) ? 255 : 0;
dst->Gpix[y][x] = g;
b = ((src->Bpix[y])[x] & mb) ? 255 : 0;
dst->Bpix[y][x] = b;
}
}
return FUNC_IS_BETA;
}
/*::------------------------------------------------------------------::*/
/*::------------------------------------------------------------------::*/
/*::------------------------------------------------------------------::*/

View File

@ -6,7 +6,7 @@
#include <stdio.h>
#include <math.h>
#include "tthimage.h"
#include "../tthimage.h"
/*::------------------------------------------------------------------::*/
int

View File

@ -5,7 +5,7 @@
#include <stdio.h>
#include <stdlib.h>
#include "tthimage.h"
#include "../tthimage.h"
/*::------------------------------------------------------------------::*/
int Image_GlitchMe(Image_Desc *src, Image_Desc *dst, char code,

93
Lib/photomaton.c Normal file
View File

@ -0,0 +1,93 @@
/*
D'apres un article paru dans 'Pour la Science', et il faudrait
que je retrouve les references exactes... Et je ,'ai meme pas
la date de ce numero de la revue :(
*/
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include "../tthimage.h"
/*::------------------------------------------------------------------::*/
int
Image_photomaton_0(Image_Desc *src, Image_Desc *dst)
{
int x, y, w, h;
int r, g, b;
if (src->width & 1)
{
w = src->width - 1;
fprintf(stderr, "photomaton: width is odd, ajust %d\n", w);
}
else
w = src->width;
if (src->height & 1)
{
h = src->height - 1;
fprintf(stderr, "photomaton: height is odd, ajust %d\n", h);
}
else
h = src->height;
for (y=0; y<src->height/2; y++)
{
for (x=0; x<src->width/2; x++)
{
Image_getRGB(src, x*2, y*2, &r, &g, &b);
Image_plotRGB(dst, x, y, r, g, b);
Image_getRGB(src, (x*2)+1, y*2, &r, &g, &b);
Image_plotRGB(dst, x+(src->width/2), y, r, g, b);
Image_getRGB(src, x*2, (y*2)+1, &r, &g, &b);
Image_plotRGB(dst, x, y+(src->height/2), r, g, b);
Image_getRGB(src, (x*2)+1, (y*2)+1, &r, &g, &b);
Image_plotRGB(dst, x+(src->width/2), y+(src->height/2), r,g,b);
}
}
dst->modified = 1;
return FUNC_NOT_FINISH;
}
/*::------------------------------------------------------------------::*/
int
Image_photomaton_n(Image_Desc *src, Image_Desc *dst, int nb)
{
Image_Desc *tmp;
int foo;
if (nb < 1)
{
fprintf(stderr, "photomaton_n: %d invalid\n", nb);
return INVALID_PARAM;
}
tmp = Image_clone(src, 1); /* copier aussi les pixels */
if (tmp==NULL)
{
fprintf(stderr, "no mem in %s %d %s\n", __FILE__, __LINE__, __func__);
abort();
}
for (foo=0; foo<nb; foo++)
{
Image_photomaton_0(tmp, dst);
Image_copy(dst, tmp);
fprintf(stderr, "photomaton N: passe %d\n", foo);
}
Image_copy(tmp, dst);
Image_DeAllocate(tmp); free(tmp);
dst->modified = 1;
return FUNC_NOT_FINISH;
}
/*::------------------------------------------------------------------::*/

154
Lib/recurse.c Normal file
View File

@ -0,0 +1,154 @@
/*
RECURSION 'QUADTREE' SUR LES IMAGES
-----------------------------------
*/
#include <stdio.h>
#include <math.h>
#include "../tthimage.h"
/*::------------------------------------------------------------------::*/
/*
* bon, c'est qu'un essai, mais il me semble prometteur.
* ceci dit, à l'epoque du Copam, il me semble que j'avais
* fait le meme genre de truc, mais en bien mieux...
*
*/
static Image_Desc *S, *D;
static int seuil;
static int level, maxlevel;
static int
recursion(Image_Rect *pRect)
{
Image_Rect rect;
int h1, h2, w1, w2, xx, yy, foo;
int mr, mg, mb, dr, dg, db, s;
level++;
if (level > maxlevel)
maxlevel = level;
#if DEBUG_LEVEL > 1
fprintf(stderr, "%5d -> %3d %3d %3d %3d\n",
level, pRect->x, pRect->y, pRect->w, pRect->h);
#endif
foo = Image_stats_zone_0(S, pRect, &mr, &mg, &mb, &dr, &dg, &db);
s = (dr + dg + db) / 3;
#if DEBUG_LEVEL > 1
printf(" %7d V %3d %3d %3d D %3d %3d %3d S %3d (%d)\n",
pRect->w*pRect->h, mr, mg, mb, dr, dg, db, s, foo);
#endif
if ( (s < seuil) || (pRect->w < 6) || (pRect->h < 6) )
{
Image_paint_rect(D, pRect, mr, mg, mb);
/* printf(" paint %d %d %d\n", mr, mg, mb); */
}
else
{
Image_paint_rect(D, pRect, 255, 0, 0);
/* Image_dump_rect(pRect, "R", 0); */
if ( pRect->h & 1 ) /* impair */
{
h1 = (pRect->h / 2) + 1;
h2 = (pRect->h / 2);
yy = (pRect->h / 2) + 1;
}
else /* pair */
{
h1 = (pRect->h / 2);
h2 = (pRect->h / 2);
yy = (pRect->h / 2);
}
if ( pRect->w & 1 ) /* impair */
{
w1 = (pRect->w / 2) + 1;
w2 = (pRect->w / 2);
xx = (pRect->w / 2) + 1;
}
else /* pair */
{
w1 = (pRect->w / 2);
w2 = (pRect->w / 2);
xx = (pRect->w / 2);
}
/*
printf(" w1 %3d w2 %3d \n", w1, w2);
printf(" h1 %3d h2 %3d \n", h1, h2);
printf(" xx %3d yy %3d \n", xx, yy);
printf("\n");
*/
rect.x = pRect->x; rect.y = pRect->y;
rect.w = w1; rect.h = h1;
recursion(&rect);
rect.x = pRect->x + xx; rect.y = pRect->y;
rect.w = w2; rect.h = h1;
recursion(&rect);
rect.x = pRect->x; rect.y = pRect->y + yy;
rect.w = w1; rect.h = h2;
recursion(&rect);
rect.x = pRect->x + xx; rect.y = pRect->y + yy;
rect.w = w2; rect.h = h2;
recursion(&rect);
}
level--;
return 0;
}
/*::------------------------------------------------------------------::*/
/*
* a quoi peut bien servir le parametre ?
*/
int
Image_call_recursion_0(Image_Desc *image, Image_Desc *dest, int param)
{
Image_Rect rect;
int foo;
rect.x = rect.y = 0;
rect.h = image->height;
rect.w = image->width;
#if DEBUG_LEVEL
fprintf(stderr, "-> demarrage de la recursion\n");
#endif
S = image; D = dest;
seuil = param;
level = maxlevel = 0;
foo = recursion(&rect);
fprintf(stderr, "-> fin recursion: %d, maxlevel=%d\n", foo, maxlevel);
dest->modified = 1;
return FUNC_IS_ALPHA;
}
/*::------------------------------------------------------------------::*/
int
Image_call_recursion(Image_Desc *image, Image_Desc *dest, int param)
{
int foo;
fprintf(stderr, "XXX %s is obsolete XXX\n", __func__);
foo = Image_call_recursion_0(image, dest, param);
return foo;
}
/*::------------------------------------------------------------------::*/

View File

@ -8,7 +8,7 @@
#include <string.h>
#include <math.h>
#include "tthimage.h"
#include "../tthimage.h"
/*::------------------------------------------------------------------::*/
/*

View File

@ -8,17 +8,30 @@ include ../Paramakes.mk
DEPS = ../tthimage.h Makefile
all: tga_tools
all: tga_cadre tga_effects tga_filtres tga_tools \
tga_television
#-----------------------------------------------------------------
fonctions.o: fonctions.c
fonctions.o: fonctions.c $(DEPS)
gcc $(CFLAGS) -c $<
#-----------------------------------------------------------------
tga_cadre: tga_cadre.c $(DEPS) fonctions.o
gcc $(CFLAGS) $< ../libimage.a fonctions.o -lm -o $@
tga_effects: tga_effects.c $(DEPS) fonctions.o
gcc $(CFLAGS) $< ../libimage.a fonctions.o -lm -o $@
tga_filtres: tga_filtres.c $(DEPS) fonctions.o
gcc $(CFLAGS) $< ../libimage.a fonctions.o -lm -o $@
tga_television: tga_television.c $(DEPS) fonctions.o
gcc $(CFLAGS) $< ../libimage.a fonctions.o -lm -o $@
tga_tools: tga_tools.c $(DEPS) fonctions.o
gcc $(CFLAGS) $< ../libimage.a fonctions.o -o $@
gcc $(CFLAGS) $< ../libimage.a fonctions.o -lm -o $@
#-----------------------------------------------------------------

331
Tools/tga_cadre.c Normal file
View File

@ -0,0 +1,331 @@
/*
Encadreur de Tga
----------------
http://la.buvette.org/devel/libimage/img-outils.html
=======================================================
3 Juin 2002: bon, une seule lettre pour selectionner le
type du cadre, c'est pas top... donc...
12 Juin 2002: mise en place du chercheur de commande
dont vous trouverez le source dans 'fonctions.c'
=======================================================
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "tga_outils.h"
/*::------------------------------------------------------------------::*/
#define CDR_A 1
#define CDR_B 2 /* cracra */
#define CDR_SWEEP 3 /* sweep */
#define CDR_D 4
#define CDR_E 5
#define CDR_f 6
#define CDR_p 7
#define CDR_P 8
#define CDR_r 9
#define CDR_BOX0 10
#define CDR_BURP0 20
#define CDR_BURP1 21
#define CDR_BURP2 22
#define CDR_BURP3 23
#define CDR_SOFT_1 30 /* new 13 mai 2009 */
#define CDR_PIXX 41
#define CDR_RASTA0 42 /* don't walk on the grass */
#define CDR_WAVE0 54
#define CDR_WAVE1 65
#define CDR_ZSND0 80
#define CDR_ZSND1 81
#define CDR_B84_A 90
#define CDR_B84_B 91
#define CDR_B84_C 92
mot_clef mots_clef[] =
{
{ "A", CDR_A, "", "use 'filet' instead" },
{ "filet", CDR_A, "", "un simple filet noir & blanc" },
{ "B", CDR_B, "i", "use 'cracra' instead" },
{ "cracra", CDR_B, "i", "un machin bizarre, un peu cracra" },
{ "sweep", CDR_SWEEP, "iiii", "degrade: rouge vert bleu taille" },
{ "D", CDR_D, "iiii", "use 'bruit' instead" },
{ "bruit", CDR_D, "iiii", "du bruit: r g b taille" },
{ "E", CDR_E, "iiii", "cadre 'blablanux': 4 parametres" },
{ "blablanux", CDR_E, "iiii", "cadre 'blablanux': 4 parametres" },
{ "f", CDR_f, "ii", "un simple filet en gris, 2 params" },
{ "filetg", CDR_f, "ii", "un simple filet en gris, 2 params" },
{ "p", CDR_p, "si", NULL },
{ "pattern", CDR_p, "si", "cadre pattern" },
{ "P", CDR_P, "si", NULL },
{ "patt_degr", CDR_P, "si", "pattern degrade" },
{ "r", CDR_r, "si", NULL },
{ "patt_rand", CDR_r, "si", "pattern random" },
{ "burp0", CDR_BURP0, "iii", "cadre burp 0" },
{ "burp1", CDR_BURP1, "ii", "cadre burp 1" },
{ "burp2", CDR_BURP2, "iiii", "inversion composantes" },
{ "burp3", CDR_BURP3, "", "en chantier..." },
{ "soft1", CDR_SOFT_1, "", "en chantier aussi" },
{ "x", CDR_PIXX, "ii", NULL },
{ "pixx", CDR_PIXX, "ii", "pixx me !" },
{ "rasta0", CDR_RASTA0, "i", "largeur des bandes" },
{ "w", CDR_WAVE0, "iiiii", NULL },
{ "wave0", CDR_WAVE0, "iiiii", "des vagues..." },
{ "zsnd0", CDR_ZSND0, "iii", "cadre zongo sound" },
{ "zsnd1", CDR_ZSND1, "iii", "cadre zongo sound" },
{ "b84a", CDR_B84_A, "iii", "cadre de la base 84" },
{ "b84b", CDR_B84_B, "ii", "cadre de la base 84" },
{ "b84c", CDR_B84_C, "iii", "non cadre base 84" },
{ NULL, 0, NULL, NULL }
};
/*::------------------------------------------------------------------::*/
void usage(int flag)
{
fprintf(stderr, "*** tga_cadre v 0.1.85 [%s] %s\n",
TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT);
if (flag)
{
Image_print_version(0);
fprintf(stderr, "\ttga_cadre <src.tga> STYLE <dst.tga> [p1]...[p8]\n");
liste_mots_clefs(mots_clef, 42);
#if DEBUG_LEVEL
fprintf(stderr, "ouba rand is %d\n", rand());
#endif
}
else
{
Image_print_version(1);
fprintf(stderr, "\nUsage:\n");
fprintf(stderr, "\ttga_cadre <src.tga> STYLE <dst.tga> [p1]...[p8]\n");
fprintf(stderr, "\ttry 'tga_cadre list' for a list.\n");
}
exit(5);
}
/*::------------------------------------------------------------------::*/
/*
* argv[1] type cadre
* argv[2] image source
* argv[3] image destination
* argv[...] paramètres
*/
#define FIRST_PARAM 4
int main(int argc, char *argv[])
{
Image_Desc *src, *dst, *pattern;
int foo, bar;
RGBA rgba;
int commande, nbargs, idx;
dump_command_line(argc, argv, 0);
foo = set_new_seed(0);
#if DEBUG_LEVEL
fprintf(stderr, "%s : newseed -> %d\n", argv[0], foo);
#endif
if (argc==2 && !strcmp(argv[1], "-?")) usage(0);
if (argc==2 && !strcmp(argv[1], "list")) usage(1);
if (argc < 4) usage(0);
if (strlen(argv[1])==1)
fprintf(stderr, "!!! %s : single letter arg '%s' is deprecated\n",
argv[0], argv[1]);
/* recherche du type de cadre demandé */
idx = cherche_mot_clef(argv[2], mots_clef, &commande, &nbargs);
if (idx < 0)
{
fprintf(stderr, "tga_cadre: mot-clef %s inconnu...\n", argv[2]);
exit(5);
}
#if DEBUG_LEVEL
fprintf(stderr, "retour %d commande %d nbargs %d argc %d\n",
idx, commande, nbargs, argc);
#endif
if ( (argc-nbargs) != FIRST_PARAM )
{
fprintf(stderr, "%s: bad number of parameters\n", argv[0]);
exit(5);
}
/*
* décodage des paramètres
*/
foo = parse_parametres(argc, argv, mots_clef[idx].ptypes, FIRST_PARAM);
#if DEBUG_LEVEL
fprintf(stderr, "retour de parse parameters = %d\n", foo);
#endif
/*
* debut du traitement des images.
* en premier le chargement de la source
*/
if ( (src=Image_TGA_alloc_load(argv[1])) == NULL )
{
fprintf(stderr, "tga_cadre: can't load \"%s\" ...\n", argv[1]);
exit(1);
}
/* 26 Jan 2002: en fait, est-il nécessaire de cloner l'image ? */
if ( (dst=Image_clone(src, 1)) == NULL )
{
fprintf(stderr, "tga_cadre: can't clone %p\n", src);
exit(1);
}
switch (commande)
{
case CDR_A: foo = Image_cadre_A(dst); break;
case CDR_B: foo = Image_cadre_cracra(dst, GIP(0), 0); break;
case CDR_SWEEP:
foo=Image_cadre_C(dst, GIP(0), GIP(1), GIP(2), GIP(3));
break;
case CDR_D:
#if DEBUG_LEVEL
printf("tga_cadre bruit : rand is %d\n", rand());
#endif
foo=Image_cadre_bruit(dst, GIP(0), GIP(1), GIP(2), GIP(3));
break;
case CDR_E:
/* aka blablanux */
foo=Image_cadre_E(dst, GIP(0), GIP(1), GIP(2), GIP(3));
break;
case CDR_f:
foo=Image_cadre_f(dst, GIP(0), GIP(1));
break;
case CDR_p: /* pattern */
pattern = Image_TGA_alloc_load(GSP(0));
if (pattern==NULL)
{
fprintf(stderr, "pattern '%s' not found\n", GSP(0));
exit(5);
}
Image_copy(src, dst);
foo = Image_cadre_pattern_0(dst, pattern, GIP(1));
break;
case CDR_P: /* pattern dégradé */
pattern = Image_TGA_alloc_load(GSP(0));
if (pattern==NULL)
{
fprintf(stderr, "pattern '%s' not found\n", GSP(0));
exit(5);
}
Image_copy(src, dst);
foo = Image_cadre_pattern_1(dst, pattern, GIP(1));
break;
case CDR_r: /* pattern random */
pattern = Image_TGA_alloc_load(argv[4]);
if (pattern==NULL)
{
fprintf(stderr, "pattern '%s' not found\n", argv[4]);
exit(5);
}
Image_copy(src, dst);
foo = Image_cadre_pattern_2(dst, pattern, GIP(1));
break;
case CDR_BURP0:
Image_copy(src, dst);
foo = Image_cadre_burp_0(dst, GIP(0), GIP(1), GIP(2));
break;
case CDR_BURP1:
Image_copy(src, dst);
foo = Image_cadre_burp_1(dst, GIP(0), GIP(1), 0);
break;
case CDR_BURP2:
Image_copy(src, dst);
/* a quoi correspondent les parametres ? */
foo = Image_cadre_burp_2(dst, GIP(0), GIP(1), GIP(2), GIP(3));
break;
case CDR_BURP3:
Image_copy(src, dst);
foo = Image_cadre_burp_3(dst, GIP(0), GIP(1), GIP(2), GIP(3));
break;
case CDR_PIXX:
bar = GIP(1);
fprintf(stderr, "* p2 of pixx is %d\n", bar);
foo=Image_cadre2_pixx(src, dst, GIP(0), bar);
break;
case CDR_RASTA0:
bar = GIP(0);
foo = Image_cadre_rasta_0(dst, bar);
break;
case CDR_WAVE0:
Image_copy(src, dst);
rgba.r = GIP(2);
rgba.g = GIP(3);
rgba.b = GIP(4);
rgba.a = 0; /* XXX */
foo = Image_cadre_waves_0(dst, GIP(0), GIP(1), &rgba, 12);
break;
case CDR_B84_A:
#if DEBUG_LEVEL
fprintf(stderr, "You are calling a COREDUMPER !\n");
#endif
foo = Image_cadre_b84_a(dst, GIP(0), GIP(1), GIP(2));
break;
case CDR_B84_B:
#if DEBUG_LEVEL
fprintf(stderr, "You are calling a COREDUMPER !\n");
#endif
/* XXX attention, cette fonction va peut-etre avoir
* un parametre supplementaire dans un proche avenir */
foo = Image_cadre_b84_b(dst, GIP(0), GIP(1));
break;
case CDR_B84_C:
#if DEBUG_LEVEL
fprintf(stderr, "You are calling a COREDUMPER !\n");
#endif
foo = Image_cadre_b84_c(dst, GIP(0), GIP(1), GIP(2));
break;
case CDR_ZSND0:
foo = Image_cadre_A(dst); /* FIXME */
break;
default:
fprintf(stderr, "*** case %d not found ***\n", commande);
usage(1);
break;
}
if (foo)
{
fprintf(stderr, "tga_cadre: type '%s': %d / %s\n",
argv[2], foo, Image_err2str(foo));
}
foo = Image_TGA_save(argv[3], dst, 0);
if (foo)
fprintf(stderr, "oups %d\n", foo);
exit (0);
}
/*::------------------------------------------------------------------::*/

441
Tools/tga_effects.c Normal file
View File

@ -0,0 +1,441 @@
/*
SPECIALS EFFECTS
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "tga_outils.h"
/*::------------------------------------------------------------------::*/
#define EFF_4BITS 4
#define EFF_CLASS0 5
#define EFF_DECOMP 6
#define EFF_FLATGRAY 7
#define EFF_GRAY 9
#define EFF_GRAYK 11
#define EFF_MOSAIC 13
#define EFF_MOSAIC0 14
#define EFF_PHMATON 15 /* new 30 avril 2007 */
#define EFF_MIRROR 16
#define EFF_EXTRBIT0 17 /* new 11 mars 2015 */
#define EFF_EXTRBIT1 18 /* new 11 mars 2015 */
#define EFF_NEGATE 20
#define EFF_SEUIL 22
#define EFF_DEGOULE 23 /* new octobre 2015 */
#define EFF_NOISE 27
#define EFF_PIXELX 33
#define EFF_PIXELY 34 /* new 30 mars 2007 */
#define EFF_FIVE 35 /* new 16 dec 2007 */
#define EFF_WARP_0 36 /* new 17 janv 2015 */
#define EFF_RECURSE 40
#define EFF_RGBMSKH 41
#define EFF_RGBMSKV 42
#define EFF_RGBMSK2 43
#define EFF_RGBMSKR 44
#define EFF_BICOLOR0 46 /* new 17 janv 2010 */
#define EFF_BICOLOR1 47 /* new 18 janv 2010 */
#define EFF_BICOLOR2 48 /* new 22 janv 2010 */
#define EFF_ROT4PIX 51
#define EFF_CONT2X2 52 /* new 1 sept 2008 */
#define EFF_CONT2X2G 53 /* new 8 sept 2008 */
#define EFF_SCRATCH 54
#define EFF_SINW0 55
#define EFF_SINW1 56
#define EFF_SWAPCOL 58
#define EFF_SWAPNIBBLE 59
#define EFF_UPDOWN 65
#define EFF_SHIFT_XY 66 /* new 8 mai 2009 */
#define EFF_WATER 72
#define EFF_FUKUNG 75
#define EFF_CLASS1 83 /* new 20 nov 2013 */
#define EFF_GLITCH 87 /* new 13 oct 2014 */
#define EFF_X0 100
#define EFF_X1 101
#define EFF_X2 102
#define EFF_X3 103
#define EFF_X4 104
#define EFF_X5 105
mot_clef mots_clef[] =
{
{ "4bits", EFF_4BITS, "", "and 0xf0" },
{ "class0", EFF_CLASS0, "", "experimental" },
{ "decomp", EFF_DECOMP, "f", "flag: print colors" },
{ "flatgray", EFF_FLATGRAY, "i", "detect flatgray zones" },
{ "gray", EFF_GRAY, "", "" },
{ "grayk", EFF_GRAYK, "iii", "3 coefs" },
{ "mirror", EFF_MIRROR, "", "" },
{ "extrbits0", EFF_EXTRBIT0, "iii", "shifts for r, g & b" },
{ "mosaic", EFF_MOSAIC, "", "?" },
{ "mosaic0", EFF_MOSAIC0, "iif", "?" },
{ "photomaton", EFF_PHMATON, "", "" },
{ "negate", EFF_NEGATE, "", "" },
{ "seuil", EFF_SEUIL, "iii", "rgb thresholds" },
{ "degoule", EFF_DEGOULE, "ii", "k1 & k2 ? wtf ?" },
{ "noise", EFF_NOISE, "i", "0..100" },
{ "pixelX", EFF_PIXELX, "", "prototype" },
{ "pixelY", EFF_PIXELY, "", "prototype" },
{ "efive", EFF_FIVE, "", "got it, code it" },
{ "warp0", EFF_WARP_0, "dii", "angle xc yc" },
{ "recurse", EFF_RECURSE, "i", "classic and recursif" },
{ "rgbmskh", EFF_RGBMSKH, "i", "'par' is a gray level" },
{ "rgbmskv", EFF_RGBMSKV, "i", "'par' is a gray level" },
{ "rgbmsk2", EFF_RGBMSK2, "i", "'par' is a gray level" },
{ "rgbmskr", EFF_RGBMSKR, "i", "'par' is a gray level" },
{ "bicolor0", EFF_BICOLOR0, "i", "?" },
{ "bicolor1", EFF_BICOLOR1, "ii", "..." },
{ "rot4pix", EFF_ROT4PIX, "i", "???" },
{ "cont2x2", EFF_CONT2X2, "", "contours 2x2 en auto" },
{ "cont2x2g", EFF_CONT2X2G, "", "contours 2x2 sur le gris" },
{ "scratch", EFF_SCRATCH, "i", "coredumper :)" },
{ "sinwave1", EFF_SINW1, "dddddd", "strange effect" },
{ "swapcol", EFF_SWAPCOL, "s", "rg rb bg" },
{ "swapnibble", EFF_SWAPNIBBLE, "", "swap all pix nibbles" },
{ "updown", EFF_UPDOWN, "", "upside down" },
{ "shift_xy", EFF_SHIFT_XY, "ii", "les deux offsets" },
{ "water", EFF_WATER, "i", "'par' is water distance" },
/* { "fukung", EFF_FUKUNG, "i", "OMG ! WTF ?" }, */
{ "class1", EFF_CLASS1, "iiii", "R G B diameter" },
{ "glitch", EFF_GLITCH, "si", "type nbre" },
{ "x0", EFF_X0, "iii", "3 thresholds for r, g, b" },
{ "x1", EFF_X1, "", "xor other componant" },
{ "x2", EFF_X2, "iii", "trigonometry" },
{ "x3", EFF_X3, "iis", "" },
{ "x4", EFF_X4, "i", "essai Aug 2008" },
{ "x5", EFF_X5, "iii", "essai Sept 2008" },
{ NULL, 0, NULL, NULL }
};
/*::------------------------------------------------------------------::*/
void usage(int flag)
{
fprintf(stderr, "*** tga_effects v 0.1.56 [%s] %s\n",
TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT);
fprintf(stderr, "\nUsage:\n");
fprintf(stderr, "\ttga_effects <src.tga> EFF <dst.tga> [p1] ... [p8]\n");
if (flag)
{
Image_print_version(0);
liste_mots_clefs(mots_clef, 42);
}
else
{
fprintf(stderr, "\ttry 'tga_effects list' for a list.\n");
}
exit(5);
}
/*::------------------------------------------------------------------::*/
/* fonction codee a la rache le 8 septembre 2008.
* a passer un jour ou l'autre dans la libimage */
int contours_du_gris(Image_Desc *src, Image_Desc *dst)
{
Image_Desc *tmp;
int foo;
tmp = Image_clone(src, 1);
foo = Image_to_gray(src, tmp, 0);
#if DEBUG_LEVEL
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
Image_2x2_contours_0(tmp);
Image_copy(tmp, dst);
return 42;
}
/*::------------------------------------------------------------------::*/
static int do_classif_1(Image_Desc *img, int kr, int kg, int kb, int diam)
{
int foo;
Une_Classe_Sph classes[2];
int r, g, b;
Image_Rect zone;
#if DEBUG_LEVEL
fprintf(stderr, "%s ( %p %d %d %d %d )\n", __func__, img, kr, kg, kb, diam);
#endif
zone.x = zone.y = 0;
zone.w = img->width;
zone.h = img->height;
foo = Image_stats_zone_0(img, &zone, &r, &g, &b, NULL, NULL, NULL);
#if DEBUG_LEVEL
fprintf(stderr, "%s, stats -> %d %d %d\n", __func__, r, g, b);
#endif
classes[0].rc = r; classes[0].gc = g; classes[0].bc = b;
classes[0].rad = 30;
classes[0].r = classes[0].g = 50; classes[0].b = 200;
classes[1].rc = kr; classes[1].gc = kg; classes[1].bc = kb;
classes[1].rad = diam;
classes[1].r = classes[1].g = 250; classes[1].b = 20;
if (must_be_verbose()) {
Image_display_classes(classes, 2, "umpf", 0);
}
foo = Image_classif_1(img, img, classes, 2, 0);
fprintf(stderr, "classif 1 -> %d\n", foo);
return FUNC_IS_BETA;
}
/*::------------------------------------------------------------------::*/
/* new 13 OCT 2014 - comburant: Kellegen 8.0 50cl */
static int do_glitch(Image_Desc *src, Image_Desc *dst, char *type, int nbre)
{
int foo;
#if DEBUG_LEVEL
fprintf(stderr, "%s :\n\t%p %p %s %d\n", __func__,
src, dst, type, nbre);
#endif
foo = Image_Glitch_simple(src, dst, nbre);
fprintf(stderr, "glitch simple -> %d\n", foo);
return 0;
}
/*::------------------------------------------------------------------::*/
/*
* argv[1] source.tga
* argv[2] type de l'effet
* argv[3] destination.tga
*/
#define FIRST_PARAM 4
int main(int argc, char *argv[])
{
Image_Desc *src, *dst;
int foo;
int commande, nbargs, idx;
double angle;
int xc, yc;
/*
* USE GETOPT HERE
*/
dump_command_line(argc, argv, 0);
if (argc==2 && !strcmp(argv[1], "-?")) usage(0);
if (argc==2 && !strcmp(argv[1], "list")) usage(1);
if (argc < 4) usage(0);
srand(getpid());
/* recherche du type d'effet demande */
idx = cherche_mot_clef(argv[2], mots_clef, &commande, &nbargs);
if (idx < 0)
{
fprintf(stderr, "tga_effects: mot-clef %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 parametres */
foo = parse_parametres(argc, argv, mots_clef[idx].ptypes, FIRST_PARAM);
if ((src = Image_TGA_alloc_load(argv[1]))==NULL)
{
fprintf(stderr, "tga_effect: can't load image %s\n", argv[1]);
exit(5);
}
if ( (dst=Image_clone(src, 1)) == NULL )
{
fprintf(stderr, "tga_effect: can't clone %p\n", src);
exit(1);
}
/* XXX ne serait-il pas de bon ton d'effacer l'image de destination ? */
switch (commande)
{
case EFF_4BITS:
foo = Image_col4bits_and(src, dst);
break;
case EFF_CLASS0:
foo = Image_classif_0(src, dst);
break;
case EFF_DECOMP:
foo = Image_decompose(src, dst, GFP(0));
break;
case EFF_FLATGRAY:
foo = Image_detect_flat_gray(src, dst, GIP(0), 0);
break;
case EFF_GRAY:
foo = Image_to_gray(src, dst, 0);
break;
case EFF_GRAYK:
foo = Image_to_gray_k(src, dst, GIP(0), GIP(1), GIP(2), 0);
break;
case EFF_MIRROR:
foo = Image_mirror(src, dst, 0);
break;
case EFF_EXTRBIT0:
foo = Image_extrbits_0(src, dst, GIP(0), GIP(1), GIP(2));
break;
case EFF_MOSAIC:
foo = Image_mosaic_simple(src, dst);
break;
case EFF_MOSAIC0:
/* explanation of the parameters, please */
foo = Image_mosaic_0(src, dst, GIP(0), GIP(1), GFP(2));
break;
case EFF_PHMATON:
foo = Image_photomaton_0(src, dst);
break;
case EFF_NEGATE:
foo = Image_negate(src, dst);
break;
case EFF_SEUIL:
foo = Image_seuil_RGB(src, dst, GIP(0), GIP(1), GIP(2));
break;
case EFF_DEGOULE:
foo = Image_degouline_0(src, dst, GIP(0), GIP(1));
#if DEBUG_LEVEL
fprintf(stderr, "Degouline ---> %d\n", foo);
#endif
break;
case EFF_NOISE:
foo = Image_noise(src, dst, GIP(0));
break;
case EFF_PIXELX:
fprintf(stderr, "Experimental : pixel X !\n");
foo = Image_pixeliz_X(src, dst);
break;
case EFF_PIXELY:
fprintf(stderr, "Experimental : pixel Y!\n");
foo = Image_pixeliz_Y(src, dst);
break;
case EFF_FIVE: /* XXX */
foo = Image_effect_x_5(src, dst, 0, 0, 0);
break;
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);
break;
case EFF_RECURSE:
fprintf(stderr, "RECURSE EXPERIMENTAL !\n");
foo = Image_call_recursion_0(src, dst, GIP(0));
break;
case EFF_RGBMSKH:
foo = Image_rgbmask_H(src, dst, GIP(0));
break;
case EFF_RGBMSKV:
foo = Image_rgbmask_V(src, dst, GIP(0));
break;
case EFF_RGBMSK2:
foo = Image_rgbmask_2(src, dst, GIP(0));
break;
case EFF_RGBMSKR:
foo = Image_rgbmask_R(src, dst, GIP(0));
break;
case EFF_BICOLOR0:
foo = Image_BiColor_0(src, dst, GIP(0));
break;
case EFF_BICOLOR1:
foo = Image_BiColor_1(src, dst, GIP(0), GIP(1));
break;
case EFF_ROT4PIX:
foo = Image_2x2_rot4pix(src, dst, GIP(0));
break;
case EFF_CONT2X2:
Image_AutoSeuilRGB(src, dst);
foo = Image_2x2_contours_0(dst);
break;
case EFF_CONT2X2G:
foo = contours_du_gris(src, dst);
break;
case EFF_SCRATCH:
foo = Image_scratch(src, dst, GIP(0));
break;
case EFF_SWAPCOL:
Image_copy(src, dst);
foo = Image_swap_colors(dst, GSP(0));
break;
case EFF_SWAPNIBBLE:
foo = Image_swap_nibbles(src, dst);
break;
case EFF_UPDOWN:
foo = Image_upside_down(src, dst, 0);
break;
case EFF_SHIFT_XY:
foo = Image_shift_xy(src, dst, GIP(0), GIP(1));
break;
case EFF_WATER:
foo = Image_water(src, dst, GIP(0));
break;
case EFF_CLASS1:
/* XXX not very trustable */
foo = do_classif_1(dst, GIP(0), GIP(1), GIP(2), GIP(3));
break;
/* new 13 october 2014 */
case EFF_GLITCH:
foo = do_glitch(src, dst, GSP(0), GIP(1));
fprintf(stderr, "do glitch -> %d\n", 0);
break;
case EFF_X0:
foo = Image_effect_x_0(src, dst, GIP(0), GIP(1), GIP(2));
break;
case EFF_X1:
foo = Image_effect_x_1(src, dst);
break;
case EFF_X2:
#if DEBUG_LEVEL
fprintf(stderr, "\teff X2 badly implemented :)\n");
#endif
foo = Image_effect_x_2(src, dst, 12, 12, 0);
break;
case EFF_X3:
#if DEBUG_LEVEL
fprintf(stderr, "\teff X3 badly implemented :)\n");
#endif
foo = Image_effect_x_3(src, dst, GIP(0), GIP(1), GSP(2));
break;
case EFF_X4:
foo = Image_effect_x_4(src, dst, GIP(0));
break;
case EFF_X5:
#if DEBUG_LEVEL
fprintf(stderr, "\teff X5 badly implemented :)\n");
#endif
foo = Image_effect_x_5(src, dst, GIP(0), GIP(1), GIP(2));
break;
default:
fprintf(stderr, "%s invalid command %d, plopped out\n",
argv[0], commande);
foo = 666;
break;
}
#if DEBUG_LEVEL
fprintf(stderr, "%s: return code is %d\n", __FILE__, foo);
puts(""); /* make a nicer display in debug mode */
#endif
foo = Image_TGA_save(argv[3], dst, 0);
return 0;
}
/*::------------------------------------------------------------------::*/

155
Tools/tga_filtres.c Normal file
View File

@ -0,0 +1,155 @@
/*
*
* F I L T R E S
*
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "tga_outils.h"
/*::------------------------------------------------------------------::*/
#define F_LISS2X2 2
#define F_ADAPT0 3
#define F_HIPASS 8
#define F_LOPASS 14
#define F_PREWITT 17
#define F_RANDOM 18
#define F_RANDOM2 19
#define F_SMOOTH 30
#define F_SOBEL 40
#define F_SOBEL4 41
mot_clef mots_clef[] =
{
{ "liss2x2", F_LISS2X2, "", "lissage 2x2" },
{ "adapt0", F_ADAPT0, "", "proto ymmv" },
{ "hipass", F_HIPASS, "", "" },
{ "lopass", F_LOPASS, "", "" },
{ "prewitt", F_PREWITT, "i", "rotation [0..8]" },
{ "random", F_RANDOM, "ii", "try it..." },
{ "random2", F_RANDOM2, "iiii", "try it..." },
{ "smooth", F_SMOOTH, "", "" },
{ "sobel", F_SOBEL, "i", "" },
{ "sobel4", F_SOBEL4, "i", "" },
{ NULL, 0, NULL, NULL }
};
/*::------------------------------------------------------------------::*/
void usage(int flag)
{
fprintf(stderr, "*** tga_filtres v 0.0.17 [%s] %s\n",
TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT);
fprintf(stderr, "\nUsage:\n");
fprintf(stderr, "\ttga_filtres <src.tga> FILTR <dst.tga> [p1] ... [pn]\n");
if (flag)
{
Image_print_version(0);
liste_mots_clefs(mots_clef, 42);
}
else
{
fprintf(stderr, "\ttry 'tga_filtres list' for a list.\n");
}
exit(5);
}
/*::------------------------------------------------------------------::*/
/*
* argv[1] source.tga
* argv[2] type filtrage
* argv[3] destination.tga
*/
#define FIRST_PARAM 4
int main(int argc, char *argv[])
{
Image_Desc *src, *dst;
int foo;
int commande, nbargs, idx;
dump_command_line(argc, argv, 0);
if (argc==2 && !strcmp(argv[1], "-?")) usage(0);
if (argc==2 && !strcmp(argv[1], "list")) usage(1);
if (argc < 4) usage(0);
srand(getpid());
/* recherche du type d'effet demandé */
idx = cherche_mot_clef(argv[2], mots_clef, &commande, &nbargs);
if (idx < 0)
{
fprintf(stderr, "tga_filtres: mot-clef %s inconnu...\n", argv[2]);
exit (5);
}
#if DEBUG_LEVEL
fprintf(stderr, "%s --> idx=%d, commande=%d, %d args\n",
argv[2], idx, commande, nbargs);
fprintf(stderr, "argc = %d\n", argc);
#endif
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 ((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 )
{
fprintf(stderr, "tga_filtres: can't clone %p\n", src);
exit(1);
}
Image_clear(dst, 0, 0, 0);
switch (commande)
{
case F_LISS2X2:
Image_2x2_lissage(src, dst);
break;
case F_ADAPT0:
foo = Image_filtadapt_0(src, dst, 5);
break;
case F_HIPASS:
foo = Image_filtre_passe_haut(src, dst);
break;
case F_LOPASS:
foo = Image_filtre_passe_bas(src, dst);
break;
case F_PREWITT:
foo = Image_filtre_Prewitt(src, dst, GIP(0));
break;
case F_RANDOM:
foo = Image_filtre_random(src, dst, GIP(0), GIP(1));
break;
case F_RANDOM2:
foo = Image_filtre_random_2(src, dst,
GIP(0), GIP(1), GIP(2), GIP(3));
break;
case F_SMOOTH:
foo = Image_lissage_3x3(src, dst);
break;
case F_SOBEL:
foo = Image_filtre_Sobel(src, dst, GIP(0));
break;
case F_SOBEL4:
foo = Image_filtre_Sobel_4(src, dst, GIP(0));
break;
}
if (foo)
Image_print_error("filtrage ", foo);
foo = Image_TGA_save(argv[3], dst, 0);
return 0;
}
/*::------------------------------------------------------------------::*/

View File

@ -11,7 +11,7 @@
/*
* 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)
* 21 Nov 2002: v0.13 a cause du parser de paramètres.
* 21 Nov 2002: v0.13 a cause du parser de parametres.
* 14 Jan 2006: v0.14 parce que je remet le truc dans le net.
* 05 Jan 2007: v0.15 pour etre synchrone avec la doc.
* 11 Dec 2007: v0.22 pour le parser de parametres (hexadecimal)
@ -38,25 +38,25 @@ int set_new_seed(int k);
* structure de description d'un mot-clef
* --------------------------------------
*
* types des parametres (chaine pointée par ptype)
* types des parametres (chaine pointee par ptype)
*
* i entier 32 bits / char parameter
* s chaine de caractères
* s chaine de caracteres
* d double flottant
*/
typedef struct
{
char *nom;
int code;
char *ptypes; /* type des paramètres */
char *ptypes; /* type des parametres */
char *aide;
char *longhelp;
/* char *longhelp; XXX */
} mot_clef;
#define NB_PARAMS 16 /* max number of allowed parameters */
/*
* structure contenant un paramètre.
* structure contenant un parametre.
*/
typedef struct
{

166
Tools/tga_television.c Normal file
View File

@ -0,0 +1,166 @@
/*
_____ _ __ ___ _
|_ _|__| | __\ \ / (_)___(_) ___ _ __
| |/ _ \ |/ _ \ \ / /| / __| |/ _ \| '_ \
| | __/ | __/\ V / | \__ \ | (_) | | | |
|_|\___|_|\___| \_/ |_|___/_|\___/|_| |_|
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "tga_outils.h"
/*::------------------------------------------------------------------::*/
/*::------------------------------------------------------------------::*/
#define TV_GRINK 2
#define TV_GROK 4
#define TV_GRUUD 6
#define TV_GRIIIZ 8
#define TV_PIX0 10
#define TV_PIX1 11
#define TV_MINITEL 12
#define TV_OLD 20
#define TV_HISTORY 21 /* wtf ? */
#define TV_TRILIGNE 22
#define TV_PROTO 30
mot_clef mots_clef[] =
{
{ "grink", TV_GRINK, "i", "colors are bipolars" },
{ "grok", TV_GROK, "i", "..." },
{ "gruud", TV_GRUUD, "i", "..." },
{ "griiiz", TV_GRIIIZ, "i", "parameter must be 0" },
{ "oldstyle", TV_OLD, "iii", "..." },
{ "pix0", TV_PIX0, "iii", "func not finished" },
{ "pix1", TV_PIX1, "iii", "func not finished" },
{ "triligne", TV_TRILIGNE, "f", "flag : rand or modulo" },
{ "proto", TV_PROTO, "i", "prototype canal+" }
};
/*::------------------------------------------------------------------::*/
void usage(int flag)
{
fprintf(stderr, "* tga_television v 0.0.23 [%s] %s\n",
TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT);
fprintf(stderr, "Usage: tga_television <src.tga> method <dst.tga> [params]\n");
Image_print_version(0);
liste_mots_clefs(mots_clef, 42);
exit(5);
}
/*::------------------------------------------------------------------::*/
int main(int argc, char *argv[])
{
Image_Desc *src, *dst;
int foo, mode;
int par[NB_PARAMS], nb_int_par, value;
int commande, nbargs;
dump_command_line(argc, argv, 0);
if (argc==2 && !strcmp(argv[1], "-?")) usage(0);
if (argc==2 && !strcmp(argv[1], "list")) usage(1);
if (argc < 4) usage(0);
srand(getpid());
if ( (src=Image_TGA_alloc_load(argv[1])) == NULL )
{
fprintf(stderr, "can't load '%s'\n", argv[1]);
exit(1);
}
if ( (dst=Image_clone(src, 0))==NULL )
{
fprintf(stderr, "can't clone %p, exiting...\n", src);
exit(2);
}
/*
* rechercher le mot clef dans la table
*/
mode = cherche_mot_clef(argv[2], mots_clef, &commande, &nbargs);
if (mode < 0)
{
fprintf(stderr, "%s : mot-clef %s inconnu\n", argv[0], argv[2]);
exit(5);
}
/*
* decoder les arguments
*/
for (foo=0; foo<NB_PARAMS; foo++) par[foo]=0;
nb_int_par = 0;
for (foo=4; foo<argc; foo++)
{
if ( sscanf(argv[foo], "%d", &value)==1 )
{
par[foo-4] = value;
nb_int_par++;
}
}
switch (commande)
{
case TV_GRINK:
/* third parameter is a boolean */
foo = Image_TV_grink(src, dst, par[0]);
break;
case TV_GROK:
foo = Image_TV_grok(src, dst, par[0]);
break;
case TV_GRUUD:
foo = Image_TV_gruud(src, dst, par[0]);
break;
case TV_GRIIIZ:
foo = Image_TV_griiiz(src, dst, par[0]);
break;
case TV_OLD:
foo = Image_TV_old(src, dst, par[0], par[1], par[2]);
break;
case TV_PIX0:
foo = Image_TV_pix_0(src, dst, par[0], par[1], par[2]);
break;
case TV_PIX1:
foo = Image_TV_pix_1(src, dst, par[0], par[1], par[2]);
break;
case TV_TRILIGNE:
foo = Image_TV_triligne(src, dst, par[0]);
break;
case TV_PROTO:
foo = Image_TV_cplus_v1(src, dst, par[0]);
break;
default:
fprintf(stderr, "commande %d inconnue\n", commande);
break;
}
if (foo && must_be_verbose())
{
fprintf(stderr, "%s : process error : %s\n",
argv[0], Image_err2str(foo));
}
foo = Image_TGA_save(argv[3], dst, 0);
if (foo)
{
fprintf(stderr, "%s: TGA_save: err %d %s\n",
argv[0], foo, Image_err2str(foo));
exit(1);
}
exit (0);
}
/*::------------------------------------------------------------------::*/

View File

@ -1,5 +1,6 @@
/*
* TGA_TOOLS
* TGA_TOOLS
* =========
*/
#include <stdio.h>

View File

@ -4,7 +4,7 @@
http:///la.buvette.org/devel/libimage/
*/
#ifndef IMAGE_VERSION_STRING
#define IMAGE_VERSION_STRING "0.4.46"
#define IMAGE_VERSION_STRING "0.4.47"
/*::------------------------------------------------------------------::*/
/*