Compare commits
6 Commits
64489f5707
...
162e04e6fc
Author | SHA1 | Date | |
---|---|---|---|
|
162e04e6fc | ||
|
75584b8ada | ||
|
bce4464719 | ||
|
05f65ef5c9 | ||
|
530d2755d3 | ||
|
ce49cc7a08 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -11,6 +11,7 @@ Lib/t_t16x24
|
|||||||
Lib/testbmp
|
Lib/testbmp
|
||||||
|
|
||||||
Tests/*.tga
|
Tests/*.tga
|
||||||
|
Tests/*.gif
|
||||||
Tests/t_t16x24
|
Tests/t_t16x24
|
||||||
|
|
||||||
Tools/genplot2
|
Tools/genplot2
|
||||||
|
9
Docs/README.md
Normal file
9
Docs/README.md
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# libtthimage
|
||||||
|
|
||||||
|
Les fichiers HTML que vous avez ici sont des versions historiques,
|
||||||
|
qui seront peut-être mise à jour au prochain grand refactoring.
|
||||||
|
Leur contenu est donc à prendre avec des pincettes, ymmv.
|
||||||
|
|
||||||
|
Ceci dit, les principes généraux sont encore bons...
|
||||||
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "../tthimage.h"
|
#include "../tthimage.h"
|
||||||
|
|
||||||
@ -17,6 +18,10 @@ h = img->height; w = img->width;
|
|||||||
fprintf(stderr, "%s: %p px=%d py=%d k=%d\n", __func__, img, parX, parY, k);
|
fprintf(stderr, "%s: %p px=%d py=%d k=%d\n", __func__, img, parX, parY, k);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (k) {
|
||||||
|
fprintf(stderr, "%s: k (%d) muste be 0\n", __func__, k);
|
||||||
|
}
|
||||||
|
|
||||||
for (y=0; y<h; y++)
|
for (y=0; y<h; y++)
|
||||||
{
|
{
|
||||||
for (foo=0; foo<parX; foo++)
|
for (foo=0; foo<parX; foo++)
|
||||||
@ -41,6 +46,13 @@ int foo;
|
|||||||
fprintf(stderr, "%s ( %p %d %d )\n", __func__, img, k0, k1);
|
fprintf(stderr, "%s ( %p %d %d )\n", __func__, img, k0, k1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (k0) {
|
||||||
|
fprintf(stderr, "%s: k0 (%d) muste be 0\n", __func__, k0);
|
||||||
|
}
|
||||||
|
if (k1) {
|
||||||
|
fprintf(stderr, "%s: k1 (%d) muste be 0\n", __func__, k1);
|
||||||
|
}
|
||||||
|
|
||||||
for (x=0; x<img->width; x++)
|
for (x=0; x<img->width; x++)
|
||||||
{
|
{
|
||||||
for (foo=0; foo<k1; foo++)
|
for (foo=0; foo<k1; foo++)
|
||||||
|
@ -191,6 +191,9 @@ int Image_degouline_0(Image_Desc *source, Image_Desc *but, int k1, int k2)
|
|||||||
int x, y;
|
int x, y;
|
||||||
int foo;
|
int foo;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">> %s ( %p %p %d %d )\n", __func__, source, but, k1, k2);
|
||||||
|
#endif
|
||||||
fprintf(stderr, "Degouline %d %d\n", k1, k2);
|
fprintf(stderr, "Degouline %d %d\n", k1, k2);
|
||||||
|
|
||||||
if ( (foo=Image_compare_desc(source, but)) ) {
|
if ( (foo=Image_compare_desc(source, but)) ) {
|
||||||
@ -198,10 +201,6 @@ if ( (foo=Image_compare_desc(source, but)) ) {
|
|||||||
return foo;
|
return foo;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
|
||||||
fprintf(stderr, "%s ( %p %p %d %d )\n", __func__, source, but, k1, k2);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
for (x=0; x<source->width; x++)
|
for (x=0; x<source->width; x++)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -26,22 +26,20 @@ Image_effect_x_0(Image_Desc *src, Image_Desc *dst, int kr, int kg, int kb)
|
|||||||
int foo, x, y, r, g, b;
|
int foo, x, y, r, g, b;
|
||||||
int cr, cg, cb;
|
int cr, cg, cb;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, "*** Effect X_0: coeffs: %d %d %d\n", kr, kg, kb);
|
||||||
|
#endif
|
||||||
|
|
||||||
if ( (foo=Image_compare_desc(src, dst)) )
|
if ( (foo=Image_compare_desc(src, dst)) )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Image effect x 0: images are differents %d\n", foo);
|
fprintf(stderr, "Image effect x 0: images are differents %d\n", foo);
|
||||||
return foo;
|
return foo;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
cr = cg = cb = 0; /* raz des compteurs */
|
||||||
fprintf(stderr, "*** Effect X_0: coeffs: %d %d %d\n", kr, kg, kb);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
cr = cg = cb = 0;
|
for (y=0; y<dst->height; y++) {
|
||||||
|
for (x=0; x<dst->width; x++) {
|
||||||
for (y=0; y<dst->height; y++)
|
|
||||||
{
|
|
||||||
for (x=0; x<dst->width; x++)
|
|
||||||
{
|
|
||||||
Image_getRGB(src, x, y, &r, &g, &b);
|
Image_getRGB(src, x, y, &r, &g, &b);
|
||||||
if (r > kr) {
|
if (r > kr) {
|
||||||
foo = g; g = b; b = foo;
|
foo = g; g = b; b = foo;
|
||||||
@ -61,7 +59,7 @@ for (y=0; y<dst->height; y++)
|
|||||||
|
|
||||||
fprintf(stderr, "* %s : counts: %d %d %d\n", __func__, cr, cg, cb);
|
fprintf(stderr, "* %s : counts: %d %d %d\n", __func__, cr, cg, cb);
|
||||||
|
|
||||||
return FUNC_IS_ALPHA;
|
return FUNC_IS_BETA;
|
||||||
}
|
}
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
/* 2 fevrier 2003: je fait du n'importe quoi, la... */
|
/* 2 fevrier 2003: je fait du n'importe quoi, la... */
|
||||||
@ -113,10 +111,10 @@ if ( (foo=Image_compare_desc(src, dst)) )
|
|||||||
return foo;
|
return foo;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (y=0; y<dst->height; y++)
|
/* a vrai dire, je ne comprend pas ou caser kx, ky et kz */
|
||||||
{
|
|
||||||
for (x=0; x<dst->width; x++)
|
for (y=0; y<dst->height; y++) {
|
||||||
{
|
for (x=0; x<dst->width; x++) {
|
||||||
r = src->Rpix[y][x];
|
r = src->Rpix[y][x];
|
||||||
g = src->Gpix[y][x];
|
g = src->Gpix[y][x];
|
||||||
b = src->Bpix[y][x];
|
b = src->Bpix[y][x];
|
||||||
@ -159,6 +157,7 @@ return FUNC_IS_BETA;
|
|||||||
* 27 Oct 2003: je debugge pendant que le thé infuse :)
|
* 27 Oct 2003: je debugge pendant que le thé infuse :)
|
||||||
* 16 Mai 2005: je commence a ecrire la documentation.
|
* 16 Mai 2005: je commence a ecrire la documentation.
|
||||||
* 29 sept 2015: je devrais finir la doc d'ici 2 ans.
|
* 29 sept 2015: je devrais finir la doc d'ici 2 ans.
|
||||||
|
* 19 aout 2022: je comprend pas ce que c'est censé faire :)
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
@ -168,16 +167,16 @@ int foo, sx, sy;
|
|||||||
int x, y, r, g, b;
|
int x, y, r, g, b;
|
||||||
int cx, cy, dx, dy;
|
int cx, cy, dx, dy;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, "%s : kx %d ky %d comp '%s'\n", __func__, kx, ky, comp);
|
||||||
|
#endif
|
||||||
|
|
||||||
if ( (foo=Image_compare_desc(src, dst)) )
|
if ( (foo=Image_compare_desc(src, dst)) )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
|
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
|
||||||
return foo;
|
return foo;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
|
||||||
fprintf(stderr, "%s : kx %d ky %d comp '%s'\n", __func__, kx, ky, comp);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (strlen(comp) != 2)
|
if (strlen(comp) != 2)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "eff x3: bad comp parameter '%s'\n", comp);
|
fprintf(stderr, "eff x3: bad comp parameter '%s'\n", comp);
|
||||||
@ -242,8 +241,7 @@ for (y=0; y<dst->height; y++)
|
|||||||
return FUNC_IS_ALPHA;
|
return FUNC_IS_ALPHA;
|
||||||
}
|
}
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
int
|
int Image_effect_x_4(Image_Desc *src, Image_Desc *dst, int flags)
|
||||||
Image_effect_x_4(Image_Desc *src, Image_Desc *dst, int flags)
|
|
||||||
{
|
{
|
||||||
int foo;
|
int foo;
|
||||||
int x, y;
|
int x, y;
|
||||||
@ -253,16 +251,13 @@ int r, g, b, r2, g2, b2;
|
|||||||
fprintf(stderr, "*** effect x4 is not ready for prime time ***\n");
|
fprintf(stderr, "*** effect x4 is not ready for prime time ***\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( (foo=Image_compare_desc(src, dst)) )
|
if ( (foo=Image_compare_desc(src, dst)) ) {
|
||||||
{
|
|
||||||
fprintf(stderr, "Image effect x 4: images are differents %d\n", foo);
|
fprintf(stderr, "Image effect x 4: images are differents %d\n", foo);
|
||||||
return foo;
|
return foo;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (y=0; y<src->height; y++)
|
for (y=0; y<src->height; y++) {
|
||||||
{
|
for (x=0; x<src->width; x++) {
|
||||||
for (x=0; x<src->width; x++)
|
|
||||||
{
|
|
||||||
r = src->Rpix[y][x];
|
r = src->Rpix[y][x];
|
||||||
g = src->Gpix[y][x];
|
g = src->Gpix[y][x];
|
||||||
b = src->Bpix[y][x];
|
b = src->Bpix[y][x];
|
||||||
@ -289,6 +284,7 @@ return FUNC_IS_BETA;
|
|||||||
/* 22 avril 2007: je vais essayer d'inventer un nouveau truc, mais il
|
/* 22 avril 2007: je vais essayer d'inventer un nouveau truc, mais il
|
||||||
* faudrait que les gosses arretent de ma casser les oreilles avec leur
|
* faudrait que les gosses arretent de ma casser les oreilles avec leur
|
||||||
* machine a batailles. putain de gamecube... */
|
* machine a batailles. putain de gamecube... */
|
||||||
|
/* 23 aout 2022 : j'ai bien envie d'une SNES et d'un Trinitron */
|
||||||
int
|
int
|
||||||
Image_effect_x_5(Image_Desc *src, Image_Desc *dst, int kx, int ky, int kz)
|
Image_effect_x_5(Image_Desc *src, Image_Desc *dst, int kx, int ky, int kz)
|
||||||
{
|
{
|
||||||
@ -299,7 +295,7 @@ double dr, dg, db, dr2, dg2, db2;
|
|||||||
|
|
||||||
fprintf(stderr, "*** effect x5 is not ready for prime time ***\n");
|
fprintf(stderr, "*** effect x5 is not ready for prime time ***\n");
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, "%s ( %p %p %d %d %d )\n", __func__, src, dst,
|
fprintf(stderr, ">>> %s ( %p %p %d %d %d )\n", __func__, src, dst,
|
||||||
kx, ky, kz);
|
kx, ky, kz);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -24,23 +24,19 @@ Image_save_color_Map(char *file, char *name, RGB_map *map)
|
|||||||
int foo;
|
int foo;
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
if ( (fp=fopen(file, "w")) == NULL )
|
if ( (fp=fopen(file, "w")) == NULL ) {
|
||||||
{
|
|
||||||
fprintf(stderr, "Save Color Map: err fopen\n");
|
fprintf(stderr, "Save Color Map: err fopen\n");
|
||||||
return FILE_CREATE_ERR;
|
return FILE_CREATE_ERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( map->nbre == 0 )
|
if ( map->nbre == 0 ) {
|
||||||
{
|
|
||||||
fprintf(stderr, "Save Color Map: empty map\n");
|
fprintf(stderr, "Save Color Map: empty map\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (foo=0; foo<map->nbre; foo++)
|
for (foo=0; foo<map->nbre; foo++) {
|
||||||
{
|
|
||||||
fprintf(fp, "%3d %3d %3d",
|
fprintf(fp, "%3d %3d %3d",
|
||||||
map->red[foo], map->green[foo], map->blue[foo]);
|
map->red[foo], map->green[foo], map->blue[foo]);
|
||||||
switch (foo)
|
switch (foo) {
|
||||||
{
|
|
||||||
case 0:
|
case 0:
|
||||||
if (name != NULL)
|
if (name != NULL)
|
||||||
fprintf(fp, " Name: %s", name);
|
fprintf(fp, " Name: %s", name);
|
||||||
@ -85,20 +81,17 @@ FILE *fp;
|
|||||||
int nbre, r, g, b, foo, errcode;
|
int nbre, r, g, b, foo, errcode;
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
|
|
||||||
if ( name != NULL )
|
if ( name != NULL ) {
|
||||||
{
|
if (strlen(name)>IMG_OBJNAME_LEN) return STRING_TOO_LONG;
|
||||||
if (strlen(name)>IMG_OBJNAME_LEN)
|
|
||||||
return STRING_TOO_LONG;
|
|
||||||
strcpy(where->name, name);
|
strcpy(where->name, name);
|
||||||
}
|
}
|
||||||
else strcpy(where->name, "no name");
|
else strcpy(where->name, "no name");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* patch du 11 Décembre 2001: on utilise une fonction qui recherche le
|
* patch du 11 Décembre 2001: on utilise une fonction qui recherche le
|
||||||
* fichier dans differents endroits. Cf 'musopen.c' pour + de détails.
|
* fichier dans differents endroits. Cf 'mustopen.c' pour + de détails.
|
||||||
*/
|
*/
|
||||||
if ((fp=Image_must_fopen(file, "r", 0)) == NULL)
|
if ((fp=Image_must_fopen(file, "r", 0)) == NULL) {
|
||||||
{
|
|
||||||
/* safety poke */
|
/* safety poke */
|
||||||
where->nbre = 0;
|
where->nbre = 0;
|
||||||
fprintf(stderr, "Load color MAP: %s not found\n", file);
|
fprintf(stderr, "Load color MAP: %s not found\n", file);
|
||||||
@ -108,11 +101,9 @@ if ((fp=Image_must_fopen(file, "r", 0)) == NULL)
|
|||||||
nbre = 0; errcode = 0;
|
nbre = 0; errcode = 0;
|
||||||
where->nbre = 0; /* kill bad value */
|
where->nbre = 0; /* kill bad value */
|
||||||
|
|
||||||
while ( fgets(buffer, 250, fp) != NULL )
|
while ( fgets(buffer, 250, fp) != NULL ) {
|
||||||
{
|
|
||||||
foo = sscanf(buffer, "%d %d %d", &r, &g, &b);
|
foo = sscanf(buffer, "%d %d %d", &r, &g, &b);
|
||||||
if (foo != 3)
|
if (foo != 3) {
|
||||||
{
|
|
||||||
fprintf(stderr, "line %d: [%s]\n", nbre, buffer);
|
fprintf(stderr, "line %d: [%s]\n", nbre, buffer);
|
||||||
errcode = BAD_COLOR_NUMBER; break;
|
errcode = BAD_COLOR_NUMBER; break;
|
||||||
}
|
}
|
||||||
@ -120,8 +111,7 @@ while ( fgets(buffer, 250, fp) != NULL )
|
|||||||
where->green[nbre] = g;
|
where->green[nbre] = g;
|
||||||
where->blue[nbre] = b;
|
where->blue[nbre] = b;
|
||||||
nbre++;
|
nbre++;
|
||||||
if (nbre > 256)
|
if (nbre > 256) {
|
||||||
{
|
|
||||||
fprintf(stderr, "load color map: nbre = %d\n", nbre);
|
fprintf(stderr, "load color map: nbre = %d\n", nbre);
|
||||||
errcode = MAP_TOO_BIG; break;
|
errcode = MAP_TOO_BIG; break;
|
||||||
}
|
}
|
||||||
@ -146,8 +136,7 @@ int foo;
|
|||||||
|
|
||||||
fprintf(stderr, "Image attach Map: cette fonction n'est pas finie\n");
|
fprintf(stderr, "Image attach Map: cette fonction n'est pas finie\n");
|
||||||
foo = Image_load_color_Map(nom_map, "", &map);
|
foo = Image_load_color_Map(nom_map, "", &map);
|
||||||
if (foo == 0)
|
if (foo == 0) {
|
||||||
{
|
|
||||||
fprintf(stderr, "Attach Map: foo is zero ?\n");
|
fprintf(stderr, "Attach Map: foo is zero ?\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,15 +152,13 @@ int foo;
|
|||||||
|
|
||||||
fprintf(stderr, "making a random map named '%s'\n", nom);
|
fprintf(stderr, "making a random map named '%s'\n", nom);
|
||||||
|
|
||||||
if (nbre < 0 || nbre > 255)
|
if (nbre < 0 || nbre > 255) {
|
||||||
{
|
|
||||||
fprintf(stderr, "make random map: nbre = %d\n", map->nbre);
|
fprintf(stderr, "make random map: nbre = %d\n", map->nbre);
|
||||||
return BAD_COLOR_NUMBER;
|
return BAD_COLOR_NUMBER;
|
||||||
}
|
}
|
||||||
map->nbre = nbre;
|
map->nbre = nbre;
|
||||||
|
|
||||||
for (foo=0; foo<nbre; foo++)
|
for (foo=0; foo<nbre; foo++) {
|
||||||
{
|
|
||||||
map->red[foo] = rand() & 0xff;
|
map->red[foo] = rand() & 0xff;
|
||||||
map->green[foo] = rand() & 0xff;
|
map->green[foo] = rand() & 0xff;
|
||||||
map->blue[foo] = rand() & 0xff;
|
map->blue[foo] = rand() & 0xff;
|
||||||
@ -196,8 +183,7 @@ strcpy(map->name, "* FMBL roulaize *");
|
|||||||
|
|
||||||
map->nbre = 64;
|
map->nbre = 64;
|
||||||
|
|
||||||
for (foo=0; foo<64; foo++)
|
for (foo=0; foo<64; foo++) {
|
||||||
{
|
|
||||||
r = ((foo >> 0) & 0x03) * 85;
|
r = ((foo >> 0) & 0x03) * 85;
|
||||||
g = ((foo >> 2) & 0x03) * 85;
|
g = ((foo >> 2) & 0x03) * 85;
|
||||||
b = ((foo >> 4) & 0x03) * 85;
|
b = ((foo >> 4) & 0x03) * 85;
|
||||||
@ -232,8 +218,7 @@ for (foo=0; foo<8; foo++)
|
|||||||
fprintf(stderr, " %3d %g\n", foo, pars[foo]);
|
fprintf(stderr, " %3d %g\n", foo, pars[foo]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (foo=0; foo<256; foo++)
|
for (foo=0; foo<256; foo++) {
|
||||||
{
|
|
||||||
dfoo = (double)foo / 255.0 * M_PI * 2;
|
dfoo = (double)foo / 255.0 * M_PI * 2;
|
||||||
dra = sin((pars[0] * dfoo) + pars[3]);
|
dra = sin((pars[0] * dfoo) + pars[3]);
|
||||||
dga = sin((pars[1] * dfoo) + pars[4]);
|
dga = sin((pars[1] * dfoo) + pars[4]);
|
||||||
@ -262,27 +247,23 @@ fprintf(stderr, "Image mix palette: work in progress...\n");
|
|||||||
|
|
||||||
k2 = 10000 - k;
|
k2 = 10000 - k;
|
||||||
|
|
||||||
for (idx=0; idx<256; idx++)
|
for (idx=0; idx<256; idx++) {
|
||||||
{
|
|
||||||
if (idx < p1->nbre)
|
if (idx < p1->nbre)
|
||||||
{
|
{
|
||||||
r1 = p1->red[idx];
|
r1 = p1->red[idx];
|
||||||
g1 = p1->green[idx];
|
g1 = p1->green[idx];
|
||||||
b1 = p1->blue[idx];
|
b1 = p1->blue[idx];
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
r1 = g1 = b1 = 0;
|
r1 = g1 = b1 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (idx < p2->nbre)
|
if (idx < p2->nbre) {
|
||||||
{
|
|
||||||
r2 = p2->red[idx];
|
r2 = p2->red[idx];
|
||||||
g2 = p2->green[idx];
|
g2 = p2->green[idx];
|
||||||
b2 = p2->blue[idx];
|
b2 = p2->blue[idx];
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
r2 = g2 = b2 = 0;
|
r2 = g2 = b2 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,19 +296,16 @@ int foo;
|
|||||||
int maxval = -99999;
|
int maxval = -99999;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (p->nbre < 1 || p->nbre > 256)
|
if (p->nbre < 1 || p->nbre > 256) {
|
||||||
{
|
|
||||||
fprintf(stderr, "%s: RGB_map %p has %d entries ?\n",
|
fprintf(stderr, "%s: RGB_map %p has %d entries ?\n",
|
||||||
__func__, p, p->nbre);
|
__func__, p, p->nbre);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (foo=0; foo<p->nbre; foo++)
|
for (foo=0; foo<p->nbre; foo++) {
|
||||||
{
|
|
||||||
p->red[foo] = round((double)p->red[foo] * v);
|
p->red[foo] = round((double)p->red[foo] * v);
|
||||||
p->green[foo] = round((double)p->green[foo] * v);
|
p->green[foo] = round((double)p->green[foo] * v);
|
||||||
p->blue[foo] = round((double)p->blue[foo] * v);
|
p->blue[foo] = round((double)p->blue[foo] * v);
|
||||||
if (clip_it)
|
if (clip_it) {
|
||||||
{
|
|
||||||
if (p->red[foo] < 0) p->red[foo] = 0;
|
if (p->red[foo] < 0) p->red[foo] = 0;
|
||||||
if (p->red[foo] > 255) p->red[foo] = 255;
|
if (p->red[foo] > 255) p->red[foo] = 255;
|
||||||
if (p->green[foo] < 0) p->green[foo] = 0;
|
if (p->green[foo] < 0) p->green[foo] = 0;
|
||||||
@ -356,19 +334,16 @@ int Image_scale3_palette(RGB_map *p, double rk, double gk, double bk,
|
|||||||
{
|
{
|
||||||
int foo;
|
int foo;
|
||||||
|
|
||||||
if (p->nbre < 1 || p->nbre > 256)
|
if (p->nbre < 1 || p->nbre > 256) {
|
||||||
{
|
|
||||||
fprintf(stderr, "%s: RGB_map %p has %d entries ?\n",
|
fprintf(stderr, "%s: RGB_map %p has %d entries ?\n",
|
||||||
__func__, p, p->nbre);
|
__func__, p, p->nbre);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (foo=0; foo<p->nbre; foo++)
|
for (foo=0; foo<p->nbre; foo++) {
|
||||||
{
|
|
||||||
p->red[foo] = round((double)p->red[foo] * rk);
|
p->red[foo] = round((double)p->red[foo] * rk);
|
||||||
p->green[foo] = round((double)p->green[foo] * gk);
|
p->green[foo] = round((double)p->green[foo] * gk);
|
||||||
p->blue[foo] = round((double)p->blue[foo] * bk);
|
p->blue[foo] = round((double)p->blue[foo] * bk);
|
||||||
if (clip_it)
|
if (clip_it) {
|
||||||
{
|
|
||||||
if (p->red[foo] < 0) p->red[foo] = 0;
|
if (p->red[foo] < 0) p->red[foo] = 0;
|
||||||
if (p->red[foo] > 255) p->red[foo] = 255;
|
if (p->red[foo] > 255) p->red[foo] = 255;
|
||||||
if (p->green[foo] < 0) p->green[foo] = 0;
|
if (p->green[foo] < 0) p->green[foo] = 0;
|
||||||
@ -395,8 +370,7 @@ int foo;
|
|||||||
fprintf(stderr, "%s (( %p '%s' '%s' ))\n", __func__, p, fname, comment);
|
fprintf(stderr, "%s (( %p '%s' '%s' ))\n", __func__, p, fname, comment);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (NULL==p)
|
if (NULL == p) {
|
||||||
{
|
|
||||||
fprintf(stderr, "in %s, can't gruik au nill map\n", __func__);
|
fprintf(stderr, "in %s, can't gruik au nill map\n", __func__);
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
@ -405,8 +379,7 @@ if (NULL==p)
|
|||||||
fprintf(stderr, "we have %d colors in palette at %p\n", p->nbre, p);
|
fprintf(stderr, "we have %d colors in palette at %p\n", p->nbre, p);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( (fp=fopen(fname, "w")) == NULL )
|
if ( (fp=fopen(fname, "w")) == NULL ) {
|
||||||
{
|
|
||||||
fprintf(stderr, "%s: err fopen %s\n", __func__, fname);
|
fprintf(stderr, "%s: err fopen %s\n", __func__, fname);
|
||||||
return FILE_CREATE_ERR;
|
return FILE_CREATE_ERR;
|
||||||
}
|
}
|
||||||
@ -414,8 +387,8 @@ fprintf(fp, "P3\n%d 1\n255\n", p->nbre);
|
|||||||
if (NULL != comment) {
|
if (NULL != comment) {
|
||||||
fprintf(fp, "# %s\n", comment);
|
fprintf(fp, "# %s\n", comment);
|
||||||
}
|
}
|
||||||
for (foo=0; foo<p->nbre; foo++)
|
|
||||||
{
|
for (foo=0; foo<p->nbre; foo++) {
|
||||||
fprintf(fp, "%3d %3d %3d\n", p->red[foo], p->green[foo], p->blue[foo]);
|
fprintf(fp, "%3d %3d %3d\n", p->red[foo], p->green[foo], p->blue[foo]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ int foo;
|
|||||||
fprintf(stderr, "Pixeliz X: appel de test, pas finalise.\n");
|
fprintf(stderr, "Pixeliz X: appel de test, pas finalise.\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
foo = Image_pixeliz_0(src, dst, 5, 15);
|
foo = Image_pixeliz_0(src, dst, 5, 16);
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, "Pixeliz X: valeur obtenue: %d\n", foo);
|
fprintf(stderr, "Pixeliz X: valeur obtenue: %d\n", foo);
|
||||||
@ -79,12 +79,13 @@ Image_pixeliz_Y(Image_Desc *src, Image_Desc *dst)
|
|||||||
{
|
{
|
||||||
int foo;
|
int foo;
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL > 1
|
||||||
fprintf(stderr, "Pixeliz Y: appel de test, pas finalise.\n");
|
fprintf(stderr, "Pixeliz Y: appel de test, pas finalise.\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
foo = Image_pixeliz_0(src, dst, 16, 5);
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
foo = Image_pixeliz_0(src, dst, 15, 5);
|
|
||||||
fprintf(stderr, "Pixeliz Y: valeur obtenue: %d\n", foo);
|
fprintf(stderr, "Pixeliz Y: valeur obtenue: %d\n", foo);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ int len1, len2, len, foo;
|
|||||||
|
|
||||||
len1 = len2 = 0;
|
len1 = len2 = 0;
|
||||||
if (NULL != lig1) len1 = strlen(lig1);
|
if (NULL != lig1) len1 = strlen(lig1);
|
||||||
if (NULL != lig2) len2 - strlen(lig2);
|
if (NULL != lig2) len2 = strlen(lig2);
|
||||||
if (len2 > len1) len = len2;
|
if (len2 > len1) len = len2;
|
||||||
else len = len1;
|
else len = len1;
|
||||||
|
|
||||||
@ -364,6 +364,9 @@ int res[8], foo;
|
|||||||
|
|
||||||
printf(" R G B A\n");
|
printf(" R G B A\n");
|
||||||
foo = Image_minmax_RGB(img, res);
|
foo = Image_minmax_RGB(img, res);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "in %s, minmax rgb -> %d\n", __func__, foo);
|
||||||
|
}
|
||||||
printf("min %4d %4d %4d %4d\n", res[0], res[2], res[4], res[6]);
|
printf("min %4d %4d %4d %4d\n", res[0], res[2], res[4], res[6]);
|
||||||
printf("max %4d %4d %4d %4d\n", res[1], res[3], res[5], res[7]);
|
printf("max %4d %4d %4d %4d\n", res[1], res[3], res[5], res[7]);
|
||||||
return OLL_KORRECT;
|
return OLL_KORRECT;
|
||||||
|
@ -2,6 +2,12 @@
|
|||||||
|
|
||||||
Tester, c'est douter.
|
Tester, c'est douter.
|
||||||
|
|
||||||
|
## État des lieux
|
||||||
|
|
||||||
|
Pas grand chose.
|
||||||
|
|
||||||
|
Allez quand même voir `config.sh` et `functions.sh` pour avoir une idée
|
||||||
|
du désastre actuel
|
||||||
|
|
||||||
## Mais encore ?
|
## Mais encore ?
|
||||||
|
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
SRC="/tmp/src.tga"
|
source ./config.sh
|
||||||
BW="/tmp/bw.tga"
|
|
||||||
|
|
||||||
DST="foo.tga"
|
DST="foo.tga"
|
||||||
|
|
||||||
|
8
Tests/config.sh
Normal file
8
Tests/config.sh
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
|
||||||
|
|
||||||
|
SRC="/tmp/src.tga"
|
||||||
|
BW="/tmp/bw.tga"
|
||||||
|
GIF89A="flashy.gif"
|
||||||
|
|
||||||
|
# find the last version of tga_*
|
||||||
|
COMDIR="../Tools"
|
43
Tests/functions.sh
Normal file
43
Tests/functions.sh
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
|
||||||
|
|
||||||
|
# ---------------------------------------------------------------
|
||||||
|
test_des_xpers ()
|
||||||
|
{
|
||||||
|
command=$1
|
||||||
|
echo ; echo " Test du xper $command"
|
||||||
|
|
||||||
|
# generation d'une image sur laquelle travailler
|
||||||
|
$COMDIR/tga_mires mircol0 $SRC "hard xper '$command'"
|
||||||
|
|
||||||
|
|
||||||
|
case $command in
|
||||||
|
zero)
|
||||||
|
$COMDIR/tga_effects $SRC x0 $DST 64 128 192
|
||||||
|
;;
|
||||||
|
un)
|
||||||
|
$COMDIR/tga_effects $SRC x1 $DST 64 128 192
|
||||||
|
;;
|
||||||
|
deux)
|
||||||
|
$COMDIR/tga_effects $SRC x2 $DST 64 128 192
|
||||||
|
;;
|
||||||
|
trois)
|
||||||
|
$COMDIR/tga_effects $SRC x3 $DST 42 R1 "rg"
|
||||||
|
;;
|
||||||
|
quatre)
|
||||||
|
$COMDIR/tga_effects $SRC x4 $DST 27
|
||||||
|
;;
|
||||||
|
cinq)
|
||||||
|
$COMDIR/tga_effects $SRC x5 $DST 64 128 192
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "==== ERROR ON $command ===="
|
||||||
|
exit 1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
gif89a=$(printf "flashy_%s.gif" $command)
|
||||||
|
|
||||||
|
convert -delay 80 $SRC $DST $gif89a
|
||||||
|
}
|
||||||
|
# ---------------------------------------------------------------
|
||||||
|
# ---------------------------------------------------------------
|
||||||
|
|
17
Tests/xper.sh
Executable file
17
Tests/xper.sh
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
source ./config.sh
|
||||||
|
source ./functions.sh
|
||||||
|
|
||||||
|
DST="foo.tga"
|
||||||
|
|
||||||
|
$COMDIR/tga_tools version
|
||||||
|
|
||||||
|
|
||||||
|
test_des_xpers "zero"
|
||||||
|
test_des_xpers "un"
|
||||||
|
test_des_xpers "deux"
|
||||||
|
test_des_xpers "trois"
|
||||||
|
test_des_xpers "quatre"
|
||||||
|
test_des_xpers "cinq"
|
||||||
|
|
@ -132,11 +132,9 @@ switch (commande)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
|
||||||
if (foo)
|
if (foo)
|
||||||
fprintf(stderr, "dither %d retour = %d, %s\n", commande,
|
fprintf(stderr, "dither %d retour = %d, %s\n", commande,
|
||||||
foo, Image_err2str(foo));
|
foo, Image_err2str(foo));
|
||||||
#endif
|
|
||||||
|
|
||||||
foo = Image_TGA_save(argv[3], dst, 0);
|
foo = Image_TGA_save(argv[3], dst, 0);
|
||||||
|
|
||||||
|
@ -437,12 +437,16 @@ switch (commande)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
if (foo) {
|
||||||
fprintf(stderr, "%s: return code is %d\n", __FILE__, foo);
|
fprintf(stderr, "%s: return code is %d\n", __FILE__, foo);
|
||||||
puts(""); /* make a nicer display in debug mode */
|
Image_print_error(argv[0], foo);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
foo = Image_TGA_save(argv[3], dst, 0);
|
foo = Image_TGA_save(argv[3], dst, 0);
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "%s: error %d saving '%s'\n", __FILE__, foo, argv[3]);
|
||||||
|
Image_print_error(argv[0], foo);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
#include "../tthimage.h"
|
#include "../tthimage.h"
|
||||||
|
|
||||||
#define TGA_OUTILS_VERSION "0.60"
|
#define TGA_OUTILS_VERSION "0.61"
|
||||||
/*
|
/*
|
||||||
* 13 Dec 2001: v0.11 a cause du 'mustopen' pour les palettes.
|
* 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)
|
* 11 Fev 2002: v0.12 a cause du '-ansi' (hein Kerdeuzz, on y vient)
|
||||||
@ -21,7 +21,7 @@
|
|||||||
* 27 Jan 2014: V0.52 added : 'parse_rect_param'.
|
* 27 Jan 2014: V0.52 added : 'parse_rect_param'.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define TGA_OUTILS_COPYLEFT "(dwtfywl) TontonTh 2018"
|
#define TGA_OUTILS_COPYLEFT "(dwtfywl) TontonTh 2022"
|
||||||
#define TGA_WWW_SITE "http://la.buvette.org/devel/libimage/"
|
#define TGA_WWW_SITE "http://la.buvette.org/devel/libimage/"
|
||||||
|
|
||||||
#define PERR(txt) fprintf(stderr, "\t| %s\n", (txt))
|
#define PERR(txt) fprintf(stderr, "\t| %s\n", (txt))
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
#define TIMESTAMP 34
|
#define TIMESTAMP 34
|
||||||
#define PRHISTO 35
|
#define PRHISTO 35
|
||||||
#define TAG7SEG0 40
|
#define TAG7SEG0 40
|
||||||
|
#define BIZARRE 41
|
||||||
#define ENVIRON 50
|
#define ENVIRON 50
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
mot_clef commandes[] =
|
mot_clef commandes[] =
|
||||||
@ -47,6 +47,7 @@ mot_clef commandes[] =
|
|||||||
{ "prhisto", PRHISTO, "s", "filename.tga" },
|
{ "prhisto", PRHISTO, "s", "filename.tga" },
|
||||||
{ "tag7", TAG7SEG0, "si", "fname.tga nnn" },
|
{ "tag7", TAG7SEG0, "si", "fname.tga nnn" },
|
||||||
{ "environ", ENVIRON, "", "" },
|
{ "environ", ENVIRON, "", "" },
|
||||||
|
{ "bizarre", BIZARRE, "", "portnawak..." },
|
||||||
{ "mk_rgb", MK_RGB, "siiiii", "fname w h r g b" },
|
{ "mk_rgb", MK_RGB, "siiiii", "fname w h r g b" },
|
||||||
{ NULL, 0, NULL, NULL }
|
{ NULL, 0, NULL, NULL }
|
||||||
};
|
};
|
||||||
@ -66,31 +67,28 @@ if (foo)
|
|||||||
{
|
{
|
||||||
fprintf(stderr, "something is bad with %s : %d\n", filename, foo);
|
fprintf(stderr, "something is bad with %s : %d\n", filename, foo);
|
||||||
Image_print_error("explanation", foo);
|
Image_print_error("explanation", foo);
|
||||||
|
return foo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foo = 0;
|
||||||
switch(flags)
|
switch(flags)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
printf("%8d %8d\n", width, height);
|
printf("%8d %8d\n", width, height); break;
|
||||||
break;
|
|
||||||
case 1:
|
case 1:
|
||||||
printf("%dx%d\n", width, height);
|
printf("%dx%d\n", width, height); break;
|
||||||
break;
|
|
||||||
case 2:
|
case 2:
|
||||||
printf(" -w%d -h%d\n", width, height);
|
printf(" -w%d -h%d\n", width, height); break;
|
||||||
break;
|
|
||||||
case 3:
|
case 3:
|
||||||
printf("width=%d height=%d\n", width, height);
|
printf("width=%d height=%d\n", width, height); break;
|
||||||
break;
|
|
||||||
case 4:
|
case 4:
|
||||||
printf("%d\n", width);
|
printf("%d\n", width); break;
|
||||||
break;
|
|
||||||
case 5:
|
case 5:
|
||||||
printf("%d\n", height);
|
printf("%d\n", height);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "bad flag %d in %s\n", flags, __func__);
|
fprintf(stderr, "bad flag %d in %s\n", flags, __func__);
|
||||||
abort();
|
foo = BAD_PARAMETER;
|
||||||
break; /* unreached ? */
|
break; /* unreached ? */
|
||||||
}
|
}
|
||||||
return foo;
|
return foo;
|
||||||
@ -104,7 +102,7 @@ int foo;
|
|||||||
fprintf(stderr, "Show Header '%s' %d\n", filename, flag);
|
fprintf(stderr, "Show Header '%s' %d\n", filename, flag);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
foo = Image_TGA_show_header(filename, 0);
|
foo = Image_TGA_show_header(filename, flag);
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, "%s got %d\n", __func__, foo);
|
fprintf(stderr, "%s got %d\n", __func__, foo);
|
||||||
@ -240,13 +238,13 @@ char *noms[] =
|
|||||||
"FIXED_SEED", ENV_DEFAULT_RGBA
|
"FIXED_SEED", ENV_DEFAULT_RGBA
|
||||||
};
|
};
|
||||||
|
|
||||||
for (foo=0; foo<(sizeof(noms)/sizeof(char *)); foo++)
|
for (foo=0; foo<(int)(sizeof(noms)/sizeof(char *)); foo++)
|
||||||
{
|
{
|
||||||
ptr = getenv(noms[foo]);
|
ptr = getenv(noms[foo]);
|
||||||
printf("%5d %-25s %s\n", foo, noms[foo], ptr);
|
printf("%5d %-25s %s\n", foo, noms[foo], ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return FUNC_NOT_FINISH;
|
return OLL_KORRECT; /* ? seriously ? */
|
||||||
}
|
}
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
int tag_7_segments_0(char *fname, int value)
|
int tag_7_segments_0(char *fname, int value)
|
||||||
@ -271,6 +269,10 @@ foo = Image_7seg_tag0(src, buffer, 0);
|
|||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, "%s : tagging %s -> %d\n", __func__, fname, foo);
|
fprintf(stderr, "%s : tagging %s -> %d\n", __func__, fname, foo);
|
||||||
#endif
|
#endif
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "ERR %d IN %s\n", foo, __func__);
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
|
||||||
foo = Image_TGA_save(fname, src, 0);
|
foo = Image_TGA_save(fname, src, 0);
|
||||||
#if DEBUG_LEVEL > 1
|
#if DEBUG_LEVEL > 1
|
||||||
@ -280,6 +282,20 @@ fprintf(stderr, "%s : saving %s -> %d\n", __func__, fname, foo);
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
|
int bizarre(char *fname, int notused)
|
||||||
|
{
|
||||||
|
|
||||||
|
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, fname, notused);
|
||||||
|
|
||||||
|
if (notused) {
|
||||||
|
fprintf(stderr, "in %s notused must be zero, was %d\n",
|
||||||
|
__func__, notused);
|
||||||
|
return INVALID_PARAM;
|
||||||
|
}
|
||||||
|
|
||||||
|
return OLL_KORRECT;
|
||||||
|
}
|
||||||
|
/*::------------------------------------------------------------------::*/
|
||||||
int main (int argc, char *argv[])
|
int main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int foo;
|
int foo;
|
||||||
@ -397,8 +413,13 @@ switch(mode)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Hu ho %d ?\n", mode);
|
fprintf(stderr, "Hu ho %d ?\n", mode);
|
||||||
|
foo = FULL_NUCKED;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (foo) {
|
||||||
|
fprintf(stderr, "*** at end of %s, foo was %d\n", __func__, foo);
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
http:///la.buvette.org/devel/libimage/
|
http:///la.buvette.org/devel/libimage/
|
||||||
*/
|
*/
|
||||||
#ifndef IMAGE_VERSION_STRING
|
#ifndef IMAGE_VERSION_STRING
|
||||||
#define IMAGE_VERSION_STRING "0.4.51 pl 16"
|
#define IMAGE_VERSION_STRING "0.4.51 pl 18"
|
||||||
|
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user