another big clean

This commit is contained in:
tTh 2022-09-21 00:06:11 +02:00
parent 1175eece63
commit a4e3d073f5
17 changed files with 261 additions and 438 deletions

View File

@ -11,6 +11,9 @@ points à préciser.
Certaines options de compilation sont dans le fichier de Certaines options de compilation sont dans le fichier de
[paramètres](../Paramakes.mk) pour les différents fichiers make. [paramètres](../Paramakes.mk) pour les différents fichiers make.
Je vous conseille de vérifier leurs pertinences, et en particulier
les options `-p` et `-pg` que j'oublie parfois d'enlever avant
le _/push_.
Le script [build.sh](../build.sh) tente d'automatiser les Le script [build.sh](../build.sh) tente d'automatiser les
compilations de la bibilothèque, des tests et des outils compilations de la bibilothèque, des tests et des outils

View File

@ -15,37 +15,32 @@
* l'epaisseur de ce cadre est de DEUX pixels, et cette valeur * l'epaisseur de ce cadre est de DEUX pixels, et cette valeur
* ne doit pas changer, car d'autres fonctions en dependent. * ne doit pas changer, car d'autres fonctions en dependent.
*/ */
int int Image_cadre_A(Image_Desc *im)
Image_cadre_A(Image_Desc *im)
{ {
int x, y; int x, y;
int a, b; int a, b;
a = 0; b = 255; a = 0; b = 255;
for (x=0; x<im->width; x++) for (x=0; x<im->width; x++) {
{
(im->Rpix[0])[x] = a; (im->Rpix[0])[x] = a;
(im->Gpix[0])[x] = a; (im->Gpix[0])[x] = a;
(im->Bpix[0])[x] = a; (im->Bpix[0])[x] = a;
Image_plotRGB(im, x, im->height-1, a, a, a); Image_plotRGB(im, x, im->height-1, a, a, a);
} }
for (y=0; y<im->height; y++) for (y=0; y<im->height; y++) {
{
(im->Rpix[y])[0] = a; (im->Rpix[y])[0] = a;
(im->Gpix[y])[0] = a; (im->Gpix[y])[0] = a;
(im->Bpix[y])[0] = a; (im->Bpix[y])[0] = a;
Image_plotRGB(im, im->width-1, y, a, a, a); Image_plotRGB(im, im->width-1, y, a, a, a);
} }
for (x=1; x<im->width-1; x++) for (x=1; x<im->width-1; x++) {
{
(im->Rpix[1])[x] = b; (im->Rpix[1])[x] = b;
(im->Gpix[1])[x] = b; (im->Gpix[1])[x] = b;
(im->Bpix[1])[x] = b; (im->Bpix[1])[x] = b;
Image_plotRGB(im, x, im->height-2, b, b, b); Image_plotRGB(im, x, im->height-2, b, b, b);
} }
for (y=1; y<im->height-1; y++) for (y=1; y<im->height-1; y++) {
{
(im->Rpix[y])[1] = b; (im->Rpix[y])[1] = b;
(im->Gpix[y])[1] = b; (im->Gpix[y])[1] = b;
(im->Bpix[y])[1] = b; (im->Bpix[y])[1] = b;
@ -57,8 +52,7 @@ return OLL_KORRECT;
/* /*
* 30 septembre 2008: Image_cadre_B devient Image_cadre_cracra :) * 30 septembre 2008: Image_cadre_B devient Image_cadre_cracra :)
*/ */
int int Image_cadre_cracra(Image_Desc *im, int largeur, int k)
Image_cadre_cracra(Image_Desc *im, int largeur, int k)
{ {
int x, y, r, g, b; int x, y, r, g, b;
@ -69,10 +63,8 @@ if (im->width < (largeur+5) || im->height < (largeur+5))
fprintf(stderr, "%s: k is $%04x\n", __func__, k); fprintf(stderr, "%s: k is $%04x\n", __func__, k);
#endif #endif
for (y=0; y<im->height; y++) for (y=0; y<im->height; y++) {
{ for (x=0; x<largeur; x++) {
for (x=0; x<largeur; x++)
{
r = rand() % (10 + x * 20); r = rand() % (10 + x * 20);
g = rand() % (11 + x * 10); g = rand() % (11 + x * 10);
b = rand() % (10 + x * 12); b = rand() % (10 + x * 12);
@ -81,8 +73,7 @@ for (y=0; y<im->height; y++)
(im->Gpix[y])[x] = g; (im->Gpix[y])[x] = g;
(im->Bpix[y])[x] = b; (im->Bpix[y])[x] = b;
} }
for (x=0; x<largeur; x++) for (x=0; x<largeur; x++) {
{
r = rand() % (10 + (largeur-x) * 20); r = rand() % (10 + (largeur-x) * 20);
g = rand() % (10 + (largeur-x) * 10); g = rand() % (10 + (largeur-x) * 10);
b = rand() % (10 + (largeur-x) * 12); b = rand() % (10 + (largeur-x) * 12);
@ -90,10 +81,8 @@ for (y=0; y<im->height; y++)
} }
} }
for (x=0; x<im->width; x++) for (x=0; x<im->width; x++) {
{ for (y=0; y<largeur; y++) {
for (y=0; y<largeur; y++)
{
r = rand() % (10 + y * 10); r = rand() % (10 + y * 10);
g = rand() % (10 + y * 12); g = rand() % (10 + y * 12);
b = rand() % (10 + y * 20); b = rand() % (10 + y * 20);
@ -102,8 +91,7 @@ for (x=0; x<im->width; x++)
(im->Gpix[y])[x] = g; (im->Gpix[y])[x] = g;
(im->Bpix[y])[x] = b; (im->Bpix[y])[x] = b;
} }
for (y=0; y<largeur; y++) for (y=0; y<largeur; y++) {
{
r = rand() % (10 + (largeur-y) * 10); r = rand() % (10 + (largeur-y) * 10);
g = rand() % (10 + (largeur-y) * 12); g = rand() % (10 + (largeur-y) * 12);
b = rand() % (10 + (largeur-y) * 20); b = rand() % (10 + (largeur-y) * 20);
@ -192,8 +180,7 @@ return OLL_KORRECT;
/* /*
* this function was the successor of the 'C' cadre. Need a rename. * this function was the successor of the 'C' cadre. Need a rename.
*/ */
int int Image_cadre_bruit(Image_Desc *im, int r, int g, int b, int n)
Image_cadre_bruit(Image_Desc *im, int r, int g, int b, int n)
{ {
int x, y, x2, y2, ir, ig, ib; int x, y, x2, y2, ir, ig, ib;
float fx, fy; float fx, fy;
@ -211,8 +198,7 @@ fn = (float)(n*n);
x2 = im->width / 2; x2 = im->width / 2;
y2 = im->height / 2; y2 = im->height / 2;
for (y=0; y<im->height; y++) for (y=0; y<im->height; y++) {
{
/* /*
* distance au bord HAUT BAS le plus proche * distance au bord HAUT BAS le plus proche
*/ */
@ -220,8 +206,7 @@ for (y=0; y<im->height; y++)
else fy = (float)((im->height - y)-1); else fy = (float)((im->height - y)-1);
fy = fy*fy; fy = fy*fy;
for (x=0; x<im->width; x++) for (x=0; x<im->width; x++) {
{
/* /*
* distance au bord DROITE GAUCHE le plus proche * distance au bord DROITE GAUCHE le plus proche
*/ */
@ -232,15 +217,12 @@ for (y=0; y<im->height; y++)
if (fx < fy) d = fx; if (fx < fy) d = fx;
else d = fy; else d = fy;
if (d < fn) if (d < fn) {
{
level = (int)((d / fn) * 1000.0); level = (int)((d / fn) * 1000.0);
if ( (rand()%1000) < level ) if ( (rand()%1000) < level ) {
{
Image_getRGB(im, x, y, &ir, &ig, &ib); Image_getRGB(im, x, y, &ir, &ig, &ib);
} }
else else {
{
ir = r; ig = g; ib = b; ir = r; ig = g; ib = b;
} }
/* Image_plotRGB(im, x, y, ir, ig, ib); */ /* Image_plotRGB(im, x, y, ir, ig, ib); */
@ -255,14 +237,12 @@ return OLL_KORRECT;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* inventee pour blablanux :) */ /* inventee pour blablanux :) */
int int Image_cadre_E(Image_Desc *im, int v1, int v2, int v3, int dim)
Image_cadre_E(Image_Desc *im, int v1, int v2, int v3, int dim)
{ {
int foo, bar; int foo, bar;
Image_Rect rect; Image_Rect rect;
for (foo=0; foo<dim; foo++) for (foo=0; foo<dim; foo++) {
{
bar = 1 << (foo%8); bar = 1 << (foo%8);
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL > 1
fprintf(stderr, "cadre E: foo is %d, bar is 0x%x\n", foo, bar); fprintf(stderr, "cadre E: foo is %d, bar is 0x%x\n", foo, bar);
@ -274,32 +254,28 @@ for (foo=0; foo<dim; foo++)
Image_draw_rect(im, &rect, v1^bar, v2^bar, v3^bar); Image_draw_rect(im, &rect, v1^bar, v2^bar, v3^bar);
} }
return 0; return OLL_KORRECT;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* 5 Fev 2001 /* 5 Fev 2001
* pas de dégradé * pas de dégradé
*/ */
int int Image_cadre_pattern_0(Image_Desc *im, Image_Desc *pat, int larg)
Image_cadre_pattern_0(Image_Desc *im, Image_Desc *pat, int larg)
{ {
int x, y, r, g, b; int x, y, r, g, b;
/* /*
* Tiens, je la supposais plus facile a ecrire... * Tiens, je la supposais plus facile a ecrire...
*/ */
for (y=0; y<im->height; y++) for (y=0; y<im->height; y++) {
{ for (x=0; x<larg; x++) {
for (x=0; x<larg; x++)
{
Image_getRGB(pat, x%pat->width, y%pat->height, &r, &g, &b); Image_getRGB(pat, x%pat->width, y%pat->height, &r, &g, &b);
/* Image_plotRGB(im, x, y, r, g, b); */ /* Image_plotRGB(im, x, y, r, g, b); */
(im->Rpix[y])[x] = r; (im->Rpix[y])[x] = r;
(im->Gpix[y])[x] = g; (im->Gpix[y])[x] = g;
(im->Bpix[y])[x] = b; (im->Bpix[y])[x] = b;
} }
for (x=im->width-larg; x<im->width; x++) for (x=im->width-larg; x<im->width; x++) {
{
Image_getRGB(pat, x%pat->width, y%pat->height, &r, &g, &b); Image_getRGB(pat, x%pat->width, y%pat->height, &r, &g, &b);
/* Image_plotRGB(im, x, y, r, g, b); */ /* Image_plotRGB(im, x, y, r, g, b); */
(im->Rpix[y])[x] = r; (im->Rpix[y])[x] = r;
@ -308,18 +284,15 @@ for (y=0; y<im->height; y++)
} }
} }
for (x=0; x<im->width; x++) for (x=0; x<im->width; x++) {
{ for (y=0; y<larg; y++) {
for (y=0; y<larg; y++)
{
Image_getRGB(pat, x%pat->width, y%pat->height, &r, &g, &b); Image_getRGB(pat, x%pat->width, y%pat->height, &r, &g, &b);
/* Image_plotRGB(im, x, y, r, g, b); */ /* Image_plotRGB(im, x, y, r, g, b); */
(im->Rpix[y])[x] = r; (im->Rpix[y])[x] = r;
(im->Gpix[y])[x] = g; (im->Gpix[y])[x] = g;
(im->Bpix[y])[x] = b; (im->Bpix[y])[x] = b;
} }
for (y=im->height-larg; y<im->height; y++) for (y=im->height-larg; y<im->height; y++) {
{
Image_getRGB(pat, x%pat->width, y%pat->height, &r, &g, &b); Image_getRGB(pat, x%pat->width, y%pat->height, &r, &g, &b);
/* Image_plotRGB(im, x, y, r, g, b); */ /* Image_plotRGB(im, x, y, r, g, b); */
(im->Rpix[y])[x] = r; (im->Rpix[y])[x] = r;
@ -332,10 +305,9 @@ return OLL_KORRECT;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* 12 Feb 2001 /* 12 Feb 2001
* dégradé propotionnel à la distance * dégradé proportionnel à la distance
*/ */
int int Image_cadre_pattern_1(Image_Desc *im, Image_Desc *pat, int n)
Image_cadre_pattern_1(Image_Desc *im, Image_Desc *pat, int n)
{ {
int x, y, x2, y2, ir, ig, ib, jr, jg, jb, r, g, b; int x, y, x2, y2, ir, ig, ib, jr, jg, jb, r, g, b;
float fx, fy; float fx, fy;
@ -348,12 +320,11 @@ x2 = im->width / 2;
y2 = im->height / 2; y2 = im->height / 2;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "*** cadre pattern 1 : fn = %f\n", fn); fprintf(stderr, "*** %s: fn = %f\n", __func__, fn);
#endif #endif
lmax = 0; lmax = 0;
for (y=0; y<im->height; y++) for (y=0; y<im->height; y++) {
{
/* /*
* distance au bord HAUT BAS le plus proche * distance au bord HAUT BAS le plus proche
*/ */
@ -361,8 +332,7 @@ for (y=0; y<im->height; y++)
else fy = (float)((im->height - y)-1); else fy = (float)((im->height - y)-1);
fy = fy*fy; fy = fy*fy;
for (x=0; x<im->width; x++) for (x=0; x<im->width; x++) {
{
/* /*
* distance au bord DROITE GAUCHE le plus proche * distance au bord DROITE GAUCHE le plus proche
@ -377,11 +347,9 @@ for (y=0; y<im->height; y++)
if (fx < fy) d = fx; if (fx < fy) d = fx;
else d = fy; else d = fy;
if (d < fn) if (d < fn) {
{
level = (int)(100 * d / fn); level = (int)(100 * d / fn);
if (level > lmax) if (level > lmax) {
{
lmax = level; lmax = level;
} }
@ -405,8 +373,7 @@ fprintf(stderr, "cadre pattern 1 : lmax = %d\n", lmax);
return OLL_KORRECT; return OLL_KORRECT;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_cadre_pattern_2(Image_Desc *im, Image_Desc *pat, int n)
Image_cadre_pattern_2(Image_Desc *im, Image_Desc *pat, int n)
{ {
int x, y, x2, y2, ir, ig, ib; int x, y, x2, y2, ir, ig, ib;
int xp, yp; int xp, yp;
@ -425,15 +392,13 @@ fprintf(stderr, "*** cadre pat 2 : pat: %d x %d\n", pat->width, pat->height);
#endif #endif
lmax = 0; lmax = 0;
for (y=0; y<im->height; y++) for (y=0; y<im->height; y++) {
{
/* distance au bord HAUT BAS le plus proche */ /* distance au bord HAUT BAS le plus proche */
if (y < y2) fy = (float)y; if (y < y2) fy = (float)y;
else fy = (float)((im->height - y)-1); else fy = (float)((im->height - y)-1);
fy = fy*fy; fy = fy*fy;
for (x=0; x<im->width; x++) for (x=0; x<im->width; x++) {
{
/* distance au bord DROITE GAUCHE le plus proche */ /* distance au bord DROITE GAUCHE le plus proche */
if (x < x2) fx = (float)x; if (x < x2) fx = (float)x;
else fx = (float)((im->width - x)-1); else fx = (float)((im->width - x)-1);
@ -442,15 +407,12 @@ for (y=0; y<im->height; y++)
if (fx < fy) d = fx; if (fx < fy) d = fx;
else d = fy; else d = fy;
if (d < fn) if (d < fn) {
{
level = (int)((d / fn) * 1000.0); level = (int)((d / fn) * 1000.0);
if ( (rand()%1000) < level ) if ( (rand()%1000) < level ) {
{
Image_getRGB(im, x, y, &ir, &ig, &ib); Image_getRGB(im, x, y, &ir, &ig, &ib);
} }
else else {
{
xp = x % pat->width; xp = x % pat->width;
yp = y % pat->height; yp = y % pat->height;
Image_getRGB(pat, xp, yp, &ir, &ig, &ib); Image_getRGB(pat, xp, yp, &ir, &ig, &ib);
@ -468,7 +430,7 @@ return OLL_KORRECT;
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* nouveau : Mon 12 Sep 2022 10:47:18 PM CEST /* nouveau : Mon 12 Sep 2022 10:47:18 PM CEST
*/ */
int Image_cadre_std2(Image_Desc *im, int r, int g, int b, int nh, int nv) int Image_cadre_std2(Image_Desc *im, int r, int g, int b, int nx, int ny)
{ {
int x, y; int x, y;
@ -477,35 +439,29 @@ fprintf(stderr, ">>> %s ( %p %d %d %d %d %d )\n", __func__,
im, r, g, b, nh, nv); im, r, g, b, nh, nv);
#endif #endif
for (y=0; y<im->height; y++) for (y=0; y<im->height; y++) {
{ for (x=0; x<nx; x++) {
for (x=0; x<nv; x++)
{
(im->Rpix[y])[x] = r; (im->Rpix[y])[x] = r;
(im->Gpix[y])[x] = g; (im->Gpix[y])[x] = g;
(im->Bpix[y])[x] = b; (im->Bpix[y])[x] = b;
} }
for (x=0; x<nv; x++) for (x=0; x<nx; x++) {
{ (im->Rpix[y])[im->width-x-1] = r;
(im->Rpix[y])[im->width-x] = r; (im->Gpix[y])[im->width-x-1] = g;
(im->Gpix[y])[im->width-x] = g; (im->Bpix[y])[im->width-x-1] = b;
(im->Bpix[y])[im->width-x] = b;
} }
} }
for (x=0; x<im->width; x++) for (x=0; x<im->width; x++) {
{ for (y=0; y<ny; y++) {
for (y=0; y<nh; y++)
{
(im->Rpix[y])[x] = r; (im->Rpix[y])[x] = r;
(im->Gpix[y])[x] = g; (im->Gpix[y])[x] = g;
(im->Bpix[y])[x] = b; (im->Bpix[y])[x] = b;
} }
for (y=0; y<nh; y++) for (y=0; y<ny; y++) {
{ (im->Rpix[y+im->height-ny])[x] = r;
(im->Rpix[y+im->height-nh])[x] = r; (im->Gpix[y+im->height-ny])[x] = g;
(im->Gpix[y+im->height-nh])[x] = g; (im->Bpix[y+im->height-ny])[x] = b;
(im->Bpix[y+im->height-nh])[x] = b;
} }
} }

View File

@ -489,6 +489,8 @@ d->modified = 1;
return OLL_KORRECT; return OLL_KORRECT;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* what are the three magic constants *_COEF ?
*/
int Image_to_gray(Image_Desc *s, Image_Desc *d, int flag) int Image_to_gray(Image_Desc *s, Image_Desc *d, int flag)
{ {
int foo; int foo;

View File

@ -14,8 +14,7 @@
/* /*
Le coefficient K va de 0 a 10000 ! Le coefficient K va de 0 a 10000 !
*/ */
int int Image_mix(Image_Desc *a, Image_Desc *b, Image_Desc *c, int k)
Image_mix(Image_Desc *a, Image_Desc *b, Image_Desc *c, int k)
{ {
int x, y; int x, y;
int ra, rb, mk; int ra, rb, mk;
@ -25,7 +24,7 @@ int foo;
if ( (foo=Image_compare_desc(a, b)) || if ( (foo=Image_compare_desc(a, b)) ||
(foo=Image_compare_desc(a, c)) ) (foo=Image_compare_desc(a, c)) )
{ {
fprintf(stderr, "Image mix: images differentes %s\n", Image_err2str(foo)); fprintf(stderr, "%s: images differentes %s\n", __func__, Image_err2str(foo));
fprintf(stderr, " a %dx%d b %dx%d c %dx%d\n", fprintf(stderr, " a %dx%d b %dx%d c %dx%d\n",
a->width, a->height, a->width, a->height,
b->width, b->height, b->width, b->height,
@ -38,14 +37,12 @@ fprintf(stderr, "Mixing: %p and %p to %p, k=%d\n", a, b, c, k);
#endif #endif
mk = 10000 - k; mk = 10000 - k;
for (y=0; y<a->height; y++) for (y=0; y<a->height; y++) {
{
pra = a->Rpix[y]; prb = b->Rpix[y]; prk = c->Rpix[y]; pra = a->Rpix[y]; prb = b->Rpix[y]; prk = c->Rpix[y];
pga = a->Gpix[y]; pgb = b->Gpix[y]; pgk = c->Gpix[y]; pga = a->Gpix[y]; pgb = b->Gpix[y]; pgk = c->Gpix[y];
pba = a->Bpix[y]; pbb = b->Bpix[y]; pbk = c->Bpix[y]; pba = a->Bpix[y]; pbb = b->Bpix[y]; pbk = c->Bpix[y];
for (x=0; x<a->width; x++) for (x=0; x<a->width; x++) {
{
ra = pra[x]; ra = pra[x];
rb = prb[x]; rb = prb[x];
prk[x] = ((ra * k) + (rb * mk)) / 10000; prk[x] = ((ra * k) + (rb * mk)) / 10000;
@ -66,8 +63,7 @@ return 0;
/* new 6 nov 2001 /* new 6 nov 2001
Les coefficients K[rgb] vont de 0 a 10000 ! Les coefficients K[rgb] vont de 0 a 10000 !
*/ */
int int Image_mix_rgb(Image_Desc *a, Image_Desc *b, Image_Desc *c,
Image_mix_rgb(Image_Desc *a, Image_Desc *b, Image_Desc *c,
int kr, int kg, int kb) int kr, int kg, int kb)
{ {
int foo, x, y; int foo, x, y;

View File

@ -14,8 +14,7 @@
#define max(a,b) ((a)>(b)?(a):(b)) #define max(a,b) ((a)>(b)?(a):(b))
#endif #endif
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
static int static int iSign(int a)
iSign(int a)
{ {
if (a<0) return -1; if (a<0) return -1;
if (a>0) return 1; if (a>0) return 1;
@ -36,8 +35,7 @@ fprintf(stderr, "sym %d %d\n", x, y);
} }
/* le paramètre 'wrap' ne sert à rien */ /* le paramètre 'wrap' ne sert à rien */
int int Image_draw_circle(Image_Desc *i, int xc, int yc, int rayon, RGBA *q, int wrap)
Image_draw_circle(Image_Desc *i, int xc, int yc, int rayon, RGBA *q, int wrap)
{ {
int x, y, d; int x, y, d;
@ -48,16 +46,13 @@ fprintf(stderr, "%s : centre %d %d, rayon %d\n", __func__, xc, yc, rayon);
y = rayon; y = rayon;
d = 3 - 2 * rayon; d = 3 - 2 * rayon;
for ( x=0; x<y; ) for ( x=0; x<y; ) {
{
symmetry(x, y, xc, yc, q, i); symmetry(x, y, xc, yc, q, i);
if (d<0) if (d<0) {
{
d += 4 * x + 6; d += 4 * x + 6;
} }
else else {
{
d += 4 * (y - x) * 10; d += 4 * (y - x) * 10;
--y; --y;
} }
@ -71,8 +66,7 @@ return FUNC_NOT_FINISH;
* l'appel a la fonction isign devrait disparaitre pour optimiser * l'appel a la fonction isign devrait disparaitre pour optimiser
* la vitesse du bouzin. * la vitesse du bouzin.
*/ */
int int Image_draw_line(Image_Desc *i, int x1, int y1, int x2, int y2, RGBA *q)
Image_draw_line(Image_Desc *i, int x1, int y1, int x2, int y2, RGBA *q)
{ {
int dx, dy, ix, iy, inc; int dx, dy, ix, iy, inc;
int foo, plotx, ploty, x, y; int foo, plotx, ploty, x, y;
@ -94,29 +88,24 @@ plotx = x1;
ploty = y1; ploty = y1;
x = y = 0; x = y = 0;
for (foo=0; foo<=inc; ++foo) for (foo=0; foo<=inc; ++foo) {
{
x += ix; x += ix;
y += iy; y += iy;
plot = 0; plot = 0;
if (x > inc) if (x > inc) {
{
plot = 42; plot = 42;
x -= inc; x -= inc;
plotx += iSign(dx); plotx += iSign(dx);
} }
if (y > inc) if (y > inc) {
{
plot = 42; plot = 42;
y -= inc; y -= inc;
ploty += iSign(dy); ploty += iSign(dy);
} }
if (plot) if (plot) {
{
/* printf("%5d %5d %5d\n", foo, plotx, ploty ); */ /* printf("%5d %5d %5d\n", foo, plotx, ploty ); */
Image_plotRGB(i, plotx, ploty, q->r, q->g, q->b); Image_plotRGB(i, plotx, ploty, q->r, q->g, q->b);
} }
} }
return 0; return 0;
} }
@ -125,8 +114,7 @@ return 0;
* XXX si je veux remplacer 'plotRGB' par un accès direct * XXX si je veux remplacer 'plotRGB' par un accès direct
* XXX dans les buffers, il faut soigner les controles * XXX dans les buffers, il faut soigner les controles
*/ */
int int Image_paint_rect(Image_Desc *img, Image_Rect *rect, int r, int g, int b)
Image_paint_rect(Image_Desc *img, Image_Rect *rect, int r, int g, int b)
{ {
int xd, yd, xf, yf, x, y; int xd, yd, xf, yf, x, y;
@ -143,6 +131,7 @@ yf = min((img->height), (rect->y+rect->h));
* 24 Juin 2002: est-ce que le code ci-dessus a é sérieusement validé ? * 24 Juin 2002: est-ce que le code ci-dessus a é sérieusement validé ?
* 24 Avril 2008: NON ! * 24 Avril 2008: NON !
* 26 janvier 2014 : toujours non... * 26 janvier 2014 : toujours non...
* 19 septembre 2022 : je n'ai pas de certitude à ce sujet
*/ */
#if DEBUG_LEVEL > 2 #if DEBUG_LEVEL > 2
@ -150,10 +139,8 @@ fprintf(stderr, "Paint Rect: %4d < X < %4d %4d < Y < %4d\n",
xd, xf, yd, yf); xd, xf, yd, yf);
#endif #endif
for (x=xd; x<xf; x++) for (x=xd; x<xf; x++) {
{ for (y=yd; y<yf; y++) {
for (y=yd; y<yf; y++)
{
/* Image_plotRGB(img, x, y, r, g, b); */ /* Image_plotRGB(img, x, y, r, g, b); */
(img->Rpix[y])[x] = r; (img->Rpix[y])[x] = r;
(img->Gpix[y])[x] = g; (img->Gpix[y])[x] = g;
@ -167,9 +154,13 @@ return 0;
/* /*
* 27 Juin 2001: there was an off-by-one error in this func... * 27 Juin 2001: there was an off-by-one error in this func...
* See also 'drawpatt.c' for others things. * See also 'drawpatt.c' for others things.
###
### THERE IS A OFF-BY-ONE IN THIS FUNCTION !
###
*/ */
int int Image_draw_rect(Image_Desc *img, Image_Rect *rect, int r, int g, int b)
Image_draw_rect(Image_Desc *img, Image_Rect *rect, int r, int g, int b)
{ {
int foo; int foo;
int xd, yd, xf, yf; int xd, yd, xf, yf;
@ -185,16 +176,14 @@ fprintf(stderr, "Draw a Rect: xd:%4d yd:%4d xf:%4d yf:%4d\n",
xd, yd, xf, yf); xd, yd, xf, yf);
#endif #endif
for (foo=xd; foo<xf; foo++) for (foo=xd; foo<xf; foo++) {
{
/* if ( (rect->y >= 0) && (rect->y < img->height) ) */ /* if ( (rect->y >= 0) && (rect->y < img->height) ) */
Image_plotRGB(img, foo, rect->y, r, g, b); Image_plotRGB(img, foo, rect->y, r, g, b);
/* if ( (rect->y+rect->h >= 0) && (rect->y+rect->h < img->height) ) */ /* if ( (rect->y+rect->h >= 0) && (rect->y+rect->h < img->height) ) */
Image_plotRGB(img, foo, rect->y+rect->h-1, r, g, b); Image_plotRGB(img, foo, rect->y+rect->h-1, r, g, b);
} }
for (foo=yd; foo<yf; foo++) for (foo=yd; foo<yf; foo++) {
{
/* if ( (rect->x >= 0) && (rect->x < img->width) ) */ /* if ( (rect->x >= 0) && (rect->x < img->width) ) */
Image_plotRGB(img, rect->x, foo, r, g, b); Image_plotRGB(img, rect->x, foo, r, g, b);
/* if ( (rect->x+rect->w >= 0) && (rect->x+rect->w < img->width) ) */ /* if ( (rect->x+rect->w >= 0) && (rect->x+rect->w < img->width) ) */
@ -205,8 +194,7 @@ return 0;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* new 10 octobre 2008 - zone de Monredon (Betatech) */ /* new 10 octobre 2008 - zone de Monredon (Betatech) */
int int Image_noise_rect(Image_Desc *img, Image_Rect *rect, int r, int g, int b)
Image_noise_rect(Image_Desc *img, Image_Rect *rect, int r, int g, int b)
{ {
int xd, yd, xf, yf, x, y; int xd, yd, xf, yf, x, y;
@ -221,10 +209,8 @@ yf = min((img->height-1), (rect->y+rect->h));
fprintf(stderr, "%s: %d %d %d %d\n", __func__, xd, yd, xf, yf); fprintf(stderr, "%s: %d %d %d %d\n", __func__, xd, yd, xf, yf);
#endif #endif
for (x=xd; x<xf; x++) for (x=xd; x<xf; x++) {
{ for (y=yd; y<yf; y++) {
for (y=yd; y<yf; y++)
{
(img->Rpix[y])[x] = rand() % r; (img->Rpix[y])[x] = rand() % r;
(img->Gpix[y])[x] = rand() % g; (img->Gpix[y])[x] = rand() % g;
(img->Bpix[y])[x] = rand() % b; (img->Bpix[y])[x] = rand() % b;

View File

@ -9,8 +9,7 @@
#include "../tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
void void Image_filtre_display(FILE *ou, int *mat)
Image_filtre_display(FILE *ou, int *mat)
{ {
int cumul, foo; int cumul, foo;

View File

@ -145,8 +145,7 @@ return FUNC_IS_BETA;
/* /*
* Pour centrer la grille, il faut jouer sur 'ox' et 'oy' ? * Pour centrer la grille, il faut jouer sur 'ox' et 'oy' ?
*/ */
int int Image_grille(Image_Desc *im, int stx, int ox, int sty, int oy, RGBA *ink)
Image_grille(Image_Desc *im, int stx, int ox, int sty, int oy, RGBA *ink)
{ {
int x, y, foo; int x, y, foo;
RGBA encre; RGBA encre;
@ -167,16 +166,13 @@ if (ink == NULL) {
fprintf(stderr, "%s X: %d %d Y: %d %d\n", __func__, ox, stx, oy, sty); fprintf(stderr, "%s X: %d %d Y: %d %d\n", __func__, ox, stx, oy, sty);
#endif #endif
for (x=ox; x<im->width; x+=stx) for (x=ox; x<im->width; x+=stx) {
{
for (foo=0; foo<im->height; foo++) for (foo=0; foo<im->height; foo++)
Image_plotRGB(im, x, foo, ink->r, ink->g, ink->b); Image_plotRGB(im, x, foo, ink->r, ink->g, ink->b);
} }
for (y=oy; y<im->height; y+=sty) for (y=oy; y<im->height; y+=sty) {
{ for (foo=0; foo<im->width; foo++) {
for (foo=0; foo<im->width; foo++)
{
Image_plotRGB(im, foo, y, ink->r, ink->g, ink->b); Image_plotRGB(im, foo, y, ink->r, ink->g, ink->b);
} }
} }
@ -189,14 +185,12 @@ return FUNC_IS_BETA;
/* /*
* Pour centrer la grille, il faut jouer sur 'ox' et 'oy' ? * Pour centrer la grille, il faut jouer sur 'ox' et 'oy' ?
*/ */
int int Image_grille_xor(Image_Desc *im, int stx, int ox, int sty, int oy, RGBA *ink)
Image_grille_xor(Image_Desc *im, int stx, int ox, int sty, int oy, RGBA *ink)
{ {
int x, y, foo; int x, y, foo;
RGBA encre; RGBA encre;
if (ink == NULL) if (ink == NULL) {
{
fprintf(stderr, "%s is using default XOR values\n", __func__); fprintf(stderr, "%s is using default XOR values\n", __func__);
encre.r = encre.g = encre.b = encre.a = 0xff; encre.r = encre.g = encre.b = encre.a = 0xff;
ink = &encre; ink = &encre;
@ -206,18 +200,14 @@ if (ink == NULL)
fprintf(stderr, "%s X %d %d Y %d %d\n", __func__, ox, stx, oy, sty); fprintf(stderr, "%s X %d %d Y %d %d\n", __func__, ox, stx, oy, sty);
#endif #endif
for (x=ox; x<im->width; x+=stx) for (x=ox; x<im->width; x+=stx) {
{ for (foo=0; foo<im->height; foo++) {
for (foo=0; foo<im->height; foo++)
{
Image_XOR_pixel(im, x, foo, ink->r, ink->g, ink->b); Image_XOR_pixel(im, x, foo, ink->r, ink->g, ink->b);
} }
} }
for (y=oy; y<im->height; y+=sty) for (y=oy; y<im->height; y+=sty) {
{ for (foo=0; foo<im->width; foo++) {
for (foo=0; foo<im->width; foo++)
{
Image_XOR_pixel(im, foo, y, ink->r, ink->g, ink->b); Image_XOR_pixel(im, foo, y, ink->r, ink->g, ink->b);
} }
} }

View File

@ -7,6 +7,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <time.h> #include <time.h>
#include <math.h> #include <math.h>
#include "../tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
@ -15,25 +16,20 @@ int Image_mircol_0(Image_Desc *dst, char *txt, int flag)
int x, y; int x, y;
RGBA fond, encre; RGBA fond, encre;
if (dst->width < 512 || dst->height < 512) if (dst->width < 512 || dst->height < 512) {
{
fprintf(stderr, "Image mircol 0: image %p < 512x512\n", dst); fprintf(stderr, "Image mircol 0: image %p < 512x512\n", dst);
return IMAGE_TOO_SMALL; return IMAGE_TOO_SMALL;
} }
if (0 != flag) if (0 != flag) {
{ fprintf(stderr, "%s: flag is %d and must be 0\n", __func__, flag);
fprintf(stderr, "%s -> flag is %d and must be 0\n", __func__, flag);
} }
if (NULL != txt) if (NULL != txt) {
{ fprintf(stderr, "%s: txt is '%s'\n", __func__, txt);
fprintf(stderr, "%s : txt is '%s'\n", __func__, txt);
} }
for (x=0; x<256; x++) for (x=0; x<256; x++) {
{ for (y=0; y<256; y++) {
for (y=0; y<256; y++)
{
Image_plotRGB(dst, x, y, x, y, 0); Image_plotRGB(dst, x, y, x, y, 0);
Image_plotRGB(dst, x+256, y, x, 0, y); Image_plotRGB(dst, x+256, y, x, 0, y);
Image_plotRGB(dst, x, y+256, 0, x, y); Image_plotRGB(dst, x, y+256, 0, x, y);
@ -64,22 +60,19 @@ for (x=1; x<256; x++)
return FUNC_IS_BETA; return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* a quoi sert ce flag */ /* a quoi sert ce flag ? */
int Image_mircol_1(Image_Desc *dst, char *txt, int flag) int Image_mircol_1(Image_Desc *dst, char *txt, int flag)
{ {
RGBA fond, encre; RGBA fond, encre;
int x, y, r, g, b; int x, y, r, g, b;
if (dst->width < 512 || dst->height < 512) if (dst->width < 512 || dst->height < 512) {
{
fprintf(stderr, "Image mircol 1: image %p < 512x512\n", dst); fprintf(stderr, "Image mircol 1: image %p < 512x512\n", dst);
return IMAGE_TOO_SMALL; return IMAGE_TOO_SMALL;
} }
for (x=0; x<512; x++) for (x=0; x<512; x++) {
{ for (y=0; y<512; y++) {
for (y=0; y<512; y++)
{
r = x; r = x;
g = (x + y) / 2; g = (x + y) / 2;
b = y; b = y;
@ -109,8 +102,7 @@ float fx, fy, fd;
fprintf(stderr, ">>>> %s ( %p '%s' %d )\n", __func__, dst, txt, mode); fprintf(stderr, ">>>> %s ( %p '%s' %d )\n", __func__, dst, txt, mode);
#endif #endif
for (y=0; y<dst->height; y++) for (y=0; y<dst->height; y++) {
{
fy = (float)y / (float)dst->height; fy = (float)y / (float)dst->height;
ky = (int)(fy * 256.0); ky = (int)(fy * 256.0);
for (x=0; x<dst->width; x++) for (x=0; x<dst->width; x++)
@ -136,10 +128,10 @@ return FULL_NUCKED;
/* nouveau 6 fevrier 2010 */ /* nouveau 6 fevrier 2010 */
int Image_mircol_3(Image_Desc *dst, char *txt, int mode) int Image_mircol_3(Image_Desc *dst, char *txt, int mode)
{ {
int x, y, r, g, b; int x, y, r, g, b;
int *p1, *p2, *p3; int *p1, *p2, *p3;
float fx, fx2, fy, dist; float fx, fx2, fy, dist;
float mystk; float mystk;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>>> %s ( %p '%s' %d )\n", __func__, dst, txt, mode); fprintf(stderr, ">>>> %s ( %p '%s' %d )\n", __func__, dst, txt, mode);
@ -151,21 +143,15 @@ switch (mode) {
case 2: p1 = &b, p2 = &r, p3 = &g; break; case 2: p1 = &b, p2 = &r, p3 = &g; break;
default: default:
fprintf(stderr, "switch/case error in %s:%d\n", fprintf(stderr, "case error in %s:%d\n", __func__, __LINE__);
__func__, __LINE__); return BAD_PARAMETER;
#if FORCE_ABORT
abort();
#endif
break;
} }
mystk = 0.90; /* FIXME */ mystk = 0.90; /* FIXME */
for (y=0; y<dst->height; y++) for (y=0; y<dst->height; y++) {
{
fy = (float)y / (float)dst->height; fy = (float)y / (float)dst->height;
for (x=0; x<dst->width; x++) for (x=0; x<dst->width; x++) {
{
fx = (float)x / (float)dst->width; fx = (float)x / (float)dst->width;
*p1 = (int)((fx*fy) * 255); *p1 = (int)((fx*fy) * 255);
@ -189,7 +175,7 @@ for (y=0; y<dst->height; y++)
} }
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL > 1
fprintf(stderr, "%s : verifier le resultat, svp.\n", __func__); fprintf(stderr, "%s: verifier le resultat, svp.\n", __func__);
#endif #endif
return FUNC_IS_BETA; return FUNC_IS_BETA;
@ -206,8 +192,7 @@ float fx, fx2, fy, dist;
fprintf(stderr, ">>>> %s ( %p '%s' %d )\n", __func__, dst, txt, mode); fprintf(stderr, ">>>> %s ( %p '%s' %d )\n", __func__, dst, txt, mode);
#endif #endif
switch (mode) switch (mode) {
{
case 0: p1 = &r, p2 = &g, p3 = &b; break; case 0: p1 = &r, p2 = &g, p3 = &b; break;
case 1: p1 = &g, p2 = &b, p3 = &r; break; case 1: p1 = &g, p2 = &b, p3 = &r; break;
case 2: p1 = &b, p2 = &r, p3 = &g; break; case 2: p1 = &b, p2 = &r, p3 = &g; break;
@ -219,13 +204,11 @@ switch (mode)
break; break;
} }
for (y=0; y<dst->height; y++) for (y=0; y<dst->height; y++) {
{
fy = (float)y / (float)dst->height; fy = (float)y / (float)dst->height;
for (x=0; x<dst->width; x++) for (x=0; x<dst->width; x++) {
{
fx = (float)x / (float)dst->width; fx = (float)x / (float)dst->width;
/* FIXME TODO */ /* FIXME TODO OMG WTF XXX */
} }
} }
@ -261,22 +244,19 @@ return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* le bit 0 du flag controle l'ecriture des noms de composantes */ /* le bit 0 du flag controle l'ecriture des noms de composantes */
int int Image_decompose(Image_Desc *src, Image_Desc *dst, int flag)
Image_decompose(Image_Desc *src, Image_Desc *dst, int flag)
{ {
int foo, x, y, hx, hy; int foo, x, y, hx, hy;
Image_Desc *moitie; Image_Desc *moitie;
int r, g, b; int r, g, b;
if ( (foo=Image_compare_desc(src, dst)) ) if ( (foo=Image_compare_desc(src, dst)) ) {
{
fprintf(stderr, "%s: bad dimensions %d\n", __func__, foo); fprintf(stderr, "%s: bad dimensions %d\n", __func__, foo);
return foo; return foo;
} }
moitie = Image_MakeHalfSize(src, 1); moitie = Image_MakeHalfSize(src, 1);
if (moitie == NULL) if (moitie == NULL) {
{
fprintf(stderr, "Image Decompose: NO MEM\n"); fprintf(stderr, "Image Decompose: NO MEM\n");
exit(5); exit(5);
} }
@ -287,10 +267,8 @@ if (0 != flag)
hx = moitie->width; hx = moitie->width;
hy = moitie->height; hy = moitie->height;
for (x=0; x<moitie->width; x++) for (x=0; x<moitie->width; x++) {
{ for (y=0; y<moitie->height; y++) {
for (y=0; y<moitie->height; y++)
{
Image_getRGB(moitie, x, y, &r, &g, &b); Image_getRGB(moitie, x, y, &r, &g, &b);
Image_plotRGB(dst, x, y, r, r, r); Image_plotRGB(dst, x, y, r, r, r);
Image_plotRGB(dst, x+hx, y, g, g, g); Image_plotRGB(dst, x+hx, y, g, g, g);
@ -302,8 +280,7 @@ for (x=0; x<moitie->width; x++)
/* faire le menage */ /* faire le menage */
Image_DeAllocate(moitie); free(moitie); Image_DeAllocate(moitie); free(moitie);
if (flag & 1) if (flag & 1) {
{
RGBA ink, pap; /* hu ho ? local vars here ? */ RGBA ink, pap; /* hu ho ? local vars here ? */
Image_load_fnt8x8("libimage.fonte", NULL, 0); Image_load_fnt8x8("libimage.fonte", NULL, 0);
pap.a = 0; ink.a = 255; pap.a = 0; ink.a = 255;

View File

@ -52,8 +52,7 @@ return FUNC_IS_BETA;
/* /*
* fonction d'appel de test * fonction d'appel de test
*/ */
int int Image_pixeliz_X(Image_Desc *src, Image_Desc *dst)
Image_pixeliz_X(Image_Desc *src, Image_Desc *dst)
{ {
int foo; int foo;
@ -73,8 +72,7 @@ return foo;
/* /*
* fonction d'appel de test * fonction d'appel de test
*/ */
int int Image_pixeliz_Y(Image_Desc *src, Image_Desc *dst)
Image_pixeliz_Y(Image_Desc *src, Image_Desc *dst)
{ {
int foo; int foo;

View File

@ -129,7 +129,9 @@ seuil = param;
level = maxlevel = 0; level = maxlevel = 0;
foo = recursion(&rect); foo = recursion(&rect);
#if DEBUG_LEVEL
fprintf(stderr, "-> fin recursion: %d, maxlevel=%d\n", foo, maxlevel); fprintf(stderr, "-> fin recursion: %d, maxlevel=%d\n", foo, maxlevel);
#endif
dest->modified = 1; dest->modified = 1;

View File

@ -9,8 +9,7 @@
#include "../tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_TV_grink(Image_Desc *src, Image_Desc *dst, int yo)
Image_TV_grink(Image_Desc *src, Image_Desc *dst, int yo)
{ {
int foo; int foo;
int x, y, r, g, b; int x, y, r, g, b;
@ -28,10 +27,8 @@ fprintf(stderr, "Image TV grink: height %d reste Y %d\n", src->height, resteY);
#endif #endif
resteY /= 2; /* half for the top, half for the bottom */ resteY /= 2; /* half for the top, half for the bottom */
for (y=resteY; y<src->height-resteY-1; y+=3) for (y=resteY; y<src->height-resteY-1; y+=3) {
{ for (x=0; x<src->width; x++) {
for (x=0; x<src->width; x++)
{
r = ( Image_R_pixel(src, x, y) + r = ( Image_R_pixel(src, x, y) +
Image_R_pixel(src, x, y+1) + Image_R_pixel(src, x, y+1) +
Image_R_pixel(src, x, y+2) ) / 3; Image_R_pixel(src, x, y+2) ) / 3;
@ -42,13 +39,11 @@ for (y=resteY; y<src->height-resteY-1; y+=3)
Image_B_pixel(src, x, y+1) + Image_B_pixel(src, x, y+1) +
Image_B_pixel(src, x, y+2) ) / 3; Image_B_pixel(src, x, y+2) ) / 3;
Image_plotRGB(dst, x, y, r, g, b); Image_plotRGB(dst, x, y, r, g, b);
if (yo) if (yo) {
{
Image_plotRGB(dst, x, y+1, r, b, g); Image_plotRGB(dst, x, y+1, r, b, g);
Image_plotRGB(dst, x, y+2, r, g, b); Image_plotRGB(dst, x, y+2, r, g, b);
} }
else else {
{
Image_plotRGB(dst, x, y+2, r, b, g); Image_plotRGB(dst, x, y+2, r, b, g);
Image_plotRGB(dst, x, y+1, r, g, b); Image_plotRGB(dst, x, y+1, r, g, b);
} }
@ -58,22 +53,18 @@ for (y=resteY; y<src->height-resteY-1; y+=3)
return OLL_KORRECT; return OLL_KORRECT;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_TV_grok(Image_Desc *src, Image_Desc *dst, int yo)
Image_TV_grok(Image_Desc *src, Image_Desc *dst, int yo)
{ {
int foo, x, y; int foo, x, y;
int r, g, b; int r, g, b;
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;
} }
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++)
{
Image_getRGB(src, x, y, &r, &g, &b); Image_getRGB(src, x, y, &r, &g, &b);
if (yo) if (yo)
Image_plotRGB(dst, x, y, r&0xa0, g&0xa0, b&0xa0); Image_plotRGB(dst, x, y, r&0xa0, g&0xa0, b&0xa0);
@ -88,8 +79,7 @@ return FUNC_IS_BETA;
/* new 8 jan 2002 /* new 8 jan 2002
* le paramètre 'yo' ne sert à rien et doit être mis à 0 * le paramètre 'yo' ne sert à rien et doit être mis à 0
*/ */
int int Image_TV_gruud(Image_Desc *src, Image_Desc *dst, int yo)
Image_TV_gruud(Image_Desc *src, Image_Desc *dst, int yo)
{ {
int x, y, i, j; int x, y, i, j;
int r, g, b, rc, gc, bc; int r, g, b, rc, gc, bc;
@ -105,26 +95,20 @@ if ( (foo=Image_compare_desc(src, dst)) ) {
return foo; return foo;
} }
for (y=0; y<src->height-2; y+=3) for (y=0; y<src->height-2; y+=3) {
{ for (x=0; x<src->width-2; x+=3) {
for (x=0; x<src->width-2; x+=3)
{
rc = gc = bc = 0; rc = gc = bc = 0;
for (i=0; i<3; i++) for (i=0; i<3; i++) {
{ for (j=0; j<3; j++) {
for (j=0; j<3; j++)
{
Image_getRGB(src, x+i, y+j, &r, &g, &b); Image_getRGB(src, x+i, y+j, &r, &g, &b);
rc += r; rc += r;
gc += g; gc += g;
bc += b; bc += b;
} }
} }
rc /= 9; gc /= 9; bc /= 9; rc /= 9; gc /= 9; bc /= 9;
for (i=0; i<3; i++) for (i=0; i<3; i++) {
{
Image_plotRGB(dst, x, y+i, rc, 0, 0); Image_plotRGB(dst, x, y+i, rc, 0, 0);
Image_plotRGB(dst, x+1, y+i, 0, gc, 0); Image_plotRGB(dst, x+1, y+i, 0, gc, 0);
Image_plotRGB(dst, x+2, y+i, 0, 0, bc); Image_plotRGB(dst, x+2, y+i, 0, 0, bc);
@ -141,14 +125,12 @@ return FUNC_IS_BETA;
/* /*
* le paramètre 'yo' ne sert à rien et doit être mis à 0 * le paramètre 'yo' ne sert à rien et doit être mis à 0
*/ */
int int Image_TV_griiiz(Image_Desc *src, Image_Desc *dst, int yo)
Image_TV_griiiz(Image_Desc *src, Image_Desc *dst, int yo)
{ {
int foo, r, g, b, cr, cg, cb; int foo, r, g, b, cr, cg, cb;
int x, y, i, j, ox, oy; int x, y, i, j, ox, oy;
int mr[GRIIIZ_SIZE][GRIIIZ_SIZE] = int mr[GRIIIZ_SIZE][GRIIIZ_SIZE] = {
{
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 1, 4, 4, 4, 4, 4, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 1, 4, 4, 4, 4, 4, 4, 4, 4, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
@ -171,8 +153,7 @@ int mr[GRIIIZ_SIZE][GRIIIZ_SIZE] =
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
}; };
int mg[GRIIIZ_SIZE][GRIIIZ_SIZE] = int mg[GRIIIZ_SIZE][GRIIIZ_SIZE] = {
{
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, 3, 3, 3, 3, 3, 3, 1 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 3, 3, 3, 3, 3, 3, 3, 1 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 5, 5, 5, 5, 5, 5, 4, 3, 1 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 5, 5, 5, 5, 5, 5, 4, 3, 1 },
@ -195,8 +176,7 @@ int mg[GRIIIZ_SIZE][GRIIIZ_SIZE] =
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
}; };
int mb[GRIIIZ_SIZE][GRIIIZ_SIZE] = int mb[GRIIIZ_SIZE][GRIIIZ_SIZE] = {
{
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
@ -221,9 +201,8 @@ int mb[GRIIIZ_SIZE][GRIIIZ_SIZE] =
int kr, kg, kb; int kr, kg, kb;
if (yo != 0) if (yo != 0) {
{ fprintf(stderr, "%s: yo (%d) _must_ be 0\n", __func__, yo);
fprintf(stderr, "Image TV griiiz: yo (%d) _must_ be 0\n", yo);
return INVALID_PARAM; return INVALID_PARAM;
} }
@ -241,28 +220,22 @@ fprintf(stderr, "%s : X %d-%d Y %d-%d\n", __func__,
#endif #endif
kr = kg = kb = 0; kr = kg = kb = 0;
for (i=0; i<GRIIIZ_SIZE; i++) for (i=0; i<GRIIIZ_SIZE; i++) {
{ for (j=0; j<GRIIIZ_SIZE; j++) {
for (j=0; j<GRIIIZ_SIZE; j++)
{
kr += mr[i][j]; kr += mr[i][j];
kg += mg[i][j]; kg += mg[i][j];
kb += mb[i][j]; kb += mb[i][j];
} }
} }
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "Image TV griiiz: kr %d kg %d kb %d\n", kr, kg, kb); fprintf(stderr, "%s: kr %d kg %d kb %d\n", __func__, kr, kg, kb);
#endif #endif
for (x=ox; x<src->width-(ox+1); x+=GRIIIZ_SIZE) for (x=ox; x<src->width-(ox+1); x+=GRIIIZ_SIZE) {
{ for (y=oy; y<src->height-(oy+1); y+=GRIIIZ_SIZE) {
for (y=oy; y<src->height-(oy+1); y+=GRIIIZ_SIZE)
{
cr = cb = cg = 0; cr = cb = cg = 0;
for (i=0; i<GRIIIZ_SIZE; i++) for (i=0; i<GRIIIZ_SIZE; i++) {
{ for (j=0; j<GRIIIZ_SIZE; j++) {
for (j=0; j<GRIIIZ_SIZE; j++)
{
Image_getRGB(src, x+i, y+j, &r, &g, &b); Image_getRGB(src, x+i, y+j, &r, &g, &b);
cr += r; cr += r;
cg += g; cg += g;
@ -270,10 +243,8 @@ for (x=ox; x<src->width-(ox+1); x+=GRIIIZ_SIZE)
} }
} }
for (i=0; i<GRIIIZ_SIZE; i++) for (i=0; i<GRIIIZ_SIZE; i++) {
{ for (j=0; j<GRIIIZ_SIZE; j++) {
for (j=0; j<GRIIIZ_SIZE; j++)
{
r = (cr*mr[j][i] / kr) ; r = (cr*mr[j][i] / kr) ;
g = (cg*mg[j][i] / kg) ; g = (cg*mg[j][i] / kg) ;
b = (cb*mb[j][i] / kb) ; /* XXX / (GRIIIZ_SIZE*GRIIIZ_SIZE); */ b = (cb*mb[j][i] / kb) ; /* XXX / (GRIIIZ_SIZE*GRIIIZ_SIZE); */

View File

@ -25,6 +25,7 @@
#define T_FONTE 2048 #define T_FONTE 2048
static uint8_t priv_fonte[T_FONTE]; static uint8_t priv_fonte[T_FONTE];
static int font_is_loaded;
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
@ -57,7 +58,7 @@ if ( (fd=Image_must_open(nomfnt, O_RDONLY, 0)) < 0 ) {
foo = read(fd, priv_fonte, T_FONTE); foo = read(fd, priv_fonte, T_FONTE);
if ( foo != T_FONTE ) { if ( foo != T_FONTE ) {
fprintf(stderr, "%s: error when reading font datas\n", __func__); fprintf(stderr, "%s: read only %d bytes from font file\n", __func__, foo);
exit(5); exit(5);
} }
close(fd); close(fd);
@ -220,8 +221,7 @@ return 0;
* Don't forget to load a font, eg : * Don't forget to load a font, eg :
* Image_load_fnt8x8("8x8thin", NULL, 0); * Image_load_fnt8x8("8x8thin", NULL, 0);
*/ */
int int Image_trace_big_char_0(Image_Desc *im, int x, int y, int code, int kx, int ky)
Image_trace_big_char_0(Image_Desc *im, int x, int y, int code, int kx, int ky)
{ {
int foo, bar; int foo, bar;
uint8_t octet; uint8_t octet;
@ -236,19 +236,22 @@ fprintf(stderr, "%s ( %p %4d %4d %s %d %d )\n", __func__, im,
x, y, buff, kx, ky); x, y, buff, kx, ky);
#endif #endif
if ( (code < 0) || (code > 255)) if ( (code < 0) || (code > 255)) {
{
fprintf(stderr, "in %s, code (%d) is invalid\n", __func__, code); fprintf(stderr, "in %s, code (%d) is invalid\n", __func__, code);
return BAD_PARAMETER; return BAD_PARAMETER;
} }
Image_load_fnt8x8("8x8thin", NULL, 0); /* Image_load_fnt8x8("8x8thin", NULL, 0); */
paper.r = paper.g = paper.b = 0; paper.r = paper.g = paper.b = 0;
ink.r = ink.g = ink.b = 255; ink.r = ink.g = ink.b = 255;
rect.w = kx, rect.h = ky; rect.w = kx, rect.h = ky;
/*
* NEED BOUNDARY CHECK !
*/
for (foo=0; foo<8; foo++) /* 8 scan lines */ for (foo=0; foo<8; foo++) /* 8 scan lines */
{ {
octet = priv_fonte[(code*8)+foo]; octet = priv_fonte[(code*8)+foo];
@ -259,9 +262,6 @@ for (foo=0; foo<8; foo++) /* 8 scan lines */
rect.x = ((8-bar)*kx) + x; rect.x = ((8-bar)*kx) + x;
if (octet & 1) if (octet & 1)
{ {
#if DEBUG_LEVEL > 1
Image_plotRGB(im, x+8-bar, y+foo, 255, 255, 255);
#endif
Image_paint_rect(im, &rect, 255, 198, 0); Image_paint_rect(im, &rect, 255, 198, 0);
Image_draw_rect(im, &rect, 0, 0, 80); Image_draw_rect(im, &rect, 0, 0, 80);
} }

View File

@ -12,7 +12,7 @@
#include "../tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
#define LIBTGA_VERSION "0.2.41" #define LIBTGA_VERSION "0.2.42"
typedef struct { typedef struct {
uint8_t text_size; uint8_t text_size;
@ -27,8 +27,7 @@ typedef struct {
} Tga_file_header; } Tga_file_header;
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_TGA_write_header(FILE *fp, Tga_file_header *head)
Image_TGA_write_header(FILE *fp, Tga_file_header *head)
{ {
fwrite (&head->text_size, 1, 1, fp); fwrite (&head->text_size, 1, 1, fp);
fwrite (&head->is_color_map, 1, 1, fp); fwrite (&head->is_color_map, 1, 1, fp);
@ -45,18 +44,16 @@ fwrite (&head->o_flags, 1, 1, fp);
return 0; return 0;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
static void static void fatal_error(char *txt)
fatal_error(char *txt)
{ {
fprintf(stderr, "TGA: (pid:%d) FATAL ERROR: %s\n", getpid(), txt); fprintf(stderr, "TGA: (pid:%d) Fatal error: %s\n", getpid(), txt);
#if FORCE_ABORT #if FORCE_ABORT
abort(); abort();
#endif #endif
exit(10); exit(10);
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
static int static int tga_pack_line(void)
tga_pack_line(void)
{ {
/* /*
* ___TODO___ compressed targa file ! * ___TODO___ compressed targa file !
@ -73,8 +70,7 @@ return -1;
* - la compression ---> URGENT !!! * - la compression ---> URGENT !!!
* - les images a palettes * - les images a palettes
*/ */
int int Image_TGA_save(char *nom, Image_Desc *img, int compress)
Image_TGA_save(char *nom, Image_Desc *img, int compress)
{ {
int ltxt, line, foo; int ltxt, line, foo;
Tga_file_header head; Tga_file_header head;
@ -103,16 +99,15 @@ if (compress != 0) {
10 Aout 2000: si le nom est "-", alors on ecrit le fichier 10 Aout 2000: si le nom est "-", alors on ecrit le fichier
sur STDOUT ce qui permet(tra) de faire des CGI :) sur STDOUT ce qui permet(tra) de faire des CGI :)
*/ */
if (strcmp("-", nom)) if (strcmp("-", nom)) {
{
if ( (fp=fopen(nom, "wb")) == NULL ) if ( (fp=fopen(nom, "wb")) == NULL )
{ {
fprintf(stderr, "filename %s\n", nom); perror(nom);
fatal_error("save TGA image: error fopen"); return FILE_CREATE_ERR;
/* fatal_error("save TGA image: error fopen"); */
} }
} }
else else {
{
fp = stdout; fp = stdout;
} }
@ -136,11 +131,10 @@ head.o_flags = 0; /* XXX a preciser ... */
fprintf(stderr, "TGASAVE: img@ %p nb planes: %d\n", img, img->nb_planes); fprintf(stderr, "TGASAVE: img@ %p nb planes: %d\n", img, img->nb_planes);
#endif #endif
switch (img->nb_planes) switch (img->nb_planes) {
{
case 1: /* images en niveau de gris */ case 1: /* images en niveau de gris */
#if DEBUG_LEVEL #if DEBUG_LEVEL
fputs("*** saving gray level image\n", stderr); fprintf(stderr, "%s saving gray level image\n", __func__);
#endif #endif
head.type = 3; head.type = 3;
head.bits = 8; head.bits = 8;
@ -207,10 +201,8 @@ memset(buffer, 0x55, sizeof(uint8_t)*4*img->width);
*/ */
/* Ahem, now, write all the picture datas to the file... */ /* Ahem, now, write all the picture datas to the file... */
for (line=(img->height-1); line>=0; line--) for (line=(img->height-1); line>=0; line--) {
{ switch (img->nb_planes) {
switch (img->nb_planes)
{
case 1: case 1:
fwrite(img->Rpix[line], 1, img->width, fp); fwrite(img->Rpix[line], 1, img->width, fp);
break; break;
@ -220,8 +212,7 @@ for (line=(img->height-1); line>=0; line--)
Gptr = img->Gpix[line]; Gptr = img->Gpix[line];
Bptr = img->Bpix[line]; Bptr = img->Bpix[line];
ptr = buffer; ptr = buffer;
for (foo=0; foo<img->width; foo++) for (foo=0; foo<img->width; foo++) {
{
*ptr++ = Bptr[foo]; *ptr++ = Bptr[foo];
*ptr++ = Gptr[foo]; *ptr++ = Gptr[foo];
*ptr++ = Rptr[foo]; *ptr++ = Rptr[foo];
@ -235,8 +226,7 @@ for (line=(img->height-1); line>=0; line--)
Bptr = img->Bpix[line]; Bptr = img->Bpix[line];
Aptr = img->Apix[line]; Aptr = img->Apix[line];
ptr = buffer; ptr = buffer;
for (foo=0; foo<img->width; foo++) for (foo=0; foo<img->width; foo++) {
{
*ptr++ = Bptr[foo]; *ptr++ = Bptr[foo];
*ptr++ = Gptr[foo]; *ptr++ = Gptr[foo];
*ptr++ = Rptr[foo]; *ptr++ = Rptr[foo];
@ -265,13 +255,12 @@ return OLL_KORRECT;
* 1 mars 2002: in fact, it was a palettized 8 bits file * 1 mars 2002: in fact, it was a palettized 8 bits file
* *
*/ */
int int Image_TGA_save_component(char *nom, Image_Desc *img, char channel, int comp)
Image_TGA_save_component(char *nom, Image_Desc *img, char channel, int comp)
{ {
int ltxt, line, foo; int ltxt, line, foo;
FILE *fp; FILE *fp;
uint8_t colormap[256*3]; uint8_t colormap[256*3];
Tga_file_header head; Tga_file_header head;
if (img->magic != MAGIC_OF_IMAGE) { if (img->magic != MAGIC_OF_IMAGE) {
fprintf(stderr, "TGASAVE: need Dead Beef!\n"); fprintf(stderr, "TGASAVE: need Dead Beef!\n");
@ -283,8 +272,7 @@ if (comp != 0) {
return BAD_PARAMETER; return BAD_PARAMETER;
} }
if ( (fp=fopen(nom, "wb")) == NULL ) if ( (fp=fopen(nom, "wb")) == NULL ) {
{
fatal_error("save image: err fopen"); fatal_error("save image: err fopen");
} }
@ -320,8 +308,7 @@ fwrite (&head.o_flags, 1, 1, fp);
if (ltxt) fwrite(img->comment, 1, ltxt, fp); if (ltxt) fwrite(img->comment, 1, ltxt, fp);
/* now, populate the colormap */ /* now, populate the colormap */
for (foo=0; foo<256; foo++) for (foo=0; foo<256; foo++) {
{
colormap[foo*3+0] = foo; colormap[foo*3+0] = foo;
colormap[foo*3+1] = foo; colormap[foo*3+1] = foo;
colormap[foo*3+2] = foo; colormap[foo*3+2] = foo;
@ -329,10 +316,8 @@ for (foo=0; foo<256; foo++)
/* and write the colormap */ /* and write the colormap */
fwrite (colormap, 256, 3, fp); fwrite (colormap, 256, 3, fp);
for (line=(img->height-1); line>=0; line--) for (line=(img->height-1); line>=0; line--) {
{ switch (channel) {
switch (channel)
{
case 'r': case 'R': case 'r': case 'R':
fwrite(img->Rpix[line], 1, img->width, fp); fwrite(img->Rpix[line], 1, img->width, fp);
break; break;
@ -359,6 +344,7 @@ switch (type)
case 2: return "Uncomp RGB"; case 2: return "Uncomp RGB";
case 3: return "Uncomp Gray"; case 3: return "Uncomp Gray";
case 4: return "Uncomp RGB + alpha"; case 4: return "Uncomp RGB + alpha";
default: return "wtf?";
} }
return "Gni ?"; return "Gni ?";
@ -391,17 +377,15 @@ return 0;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* new 13 mars 2007 */ /* new 13 mars 2007 */
int int Image_TGA_read_header(FILE *fp, void *pvoid)
Image_TGA_read_header(FILE *fp, void *pvoid)
{ {
Tga_file_header *phead; Tga_file_header *phead;
int foo; int foo;
phead = (Tga_file_header *)pvoid; phead = (Tga_file_header *)pvoid;
foo = fread(&phead->text_size, 1, 1, fp); foo = fread(&phead->text_size, 1, 1, fp);
if (foo != 1) if (foo != 1) {
{
fprintf(stderr, "TGA READ HEAD: err read first byte of header\n"); fprintf(stderr, "TGA READ HEAD: err read first byte of header\n");
return VERY_STRANGE; return VERY_STRANGE;
} }
@ -417,8 +401,7 @@ Image_basicIO_read_I_short(fp, &phead->y_start);
phead->width = phead->height = -1; phead->width = phead->height = -1;
Image_basicIO_read_I_short(fp, &phead->width); Image_basicIO_read_I_short(fp, &phead->width);
Image_basicIO_read_I_short(fp, &phead->height); Image_basicIO_read_I_short(fp, &phead->height);
if ( (phead->width<1) || (phead->width<1) ) if ( (phead->width<1) || (phead->width<1) ) {
{
fprintf(stderr, "HEAD TGA: dimension < 1: %d %d\n", fprintf(stderr, "HEAD TGA: dimension < 1: %d %d\n",
phead->width, phead->height); phead->width, phead->height);
return VERY_STRANGE; return VERY_STRANGE;
@ -438,12 +421,11 @@ return OLL_KORRECT;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* new 1er mai 2007 (la france qui bosse tout le temps) */ /* new 1er mai 2007 (la france qui bosse tout le temps) */
int int Image_TGA_show_header(char *filename, int flag)
Image_TGA_show_header(char *filename, int flag)
{ {
FILE *fp; FILE *fp;
Tga_file_header header; Tga_file_header header;
int foo; int foo;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s ( %p 0x%04x )\n", __func__, filename, flag); fprintf(stderr, "%s ( %p 0x%04x )\n", __func__, filename, flag);
@ -468,8 +450,7 @@ return FUNC_NOT_FINISH;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* new 13 mars 2007 */ /* new 13 mars 2007 */
int int Image_TGA_get_dims(char *path, int *pwidth, int *pheight)
Image_TGA_get_dims(char *path, int *pwidth, int *pheight)
{ {
FILE *fp; FILE *fp;
Tga_file_header head; Tga_file_header head;
@ -477,9 +458,8 @@ int foo;
*pwidth = *pheight = 0; *pwidth = *pheight = 0;
if ( (fp=fopen(path, "rb")) == NULL ) if ( (fp=fopen(path, "rb")) == NULL ) {
{ fprintf(stderr, "%s: file '%s' is not readable\n", __func__, path);
fprintf(stderr, "TGA READ HEADER: file '%s' is not readable\n", path);
return FILE_NOT_FOUND; return FILE_NOT_FOUND;
} }

View File

@ -13,8 +13,7 @@
/* /*
* WARNING! this function is not re-entrant! * WARNING! this function is not re-entrant!
*/ */
void void Image_pacifier(char *texte, int div)
Image_pacifier(char *texte, int div)
{ {
static int compteur; static int compteur;
int foo; int foo;
@ -30,23 +29,19 @@ printf("%c\r", batons[foo&0x03]); fflush(stdout);
#define NB_CHRONOS 42 #define NB_CHRONOS 42
static struct static struct {
{
int in_use; int in_use;
time_t debut; time_t debut;
time_t fin; time_t fin;
} chronos[NB_CHRONOS]; } chronos[NB_CHRONOS];
int int Image_start_chrono(char *texte, int num)
Image_start_chrono(char *texte, int num)
{ {
if (num< 0 || num>= NB_CHRONOS) if (num< 0 || num>= NB_CHRONOS) {
{
return BAD_CHRONO; return BAD_CHRONO;
} }
if (NULL != texte) if (NULL != texte) {
{
fprintf(stderr, ">>> start chrono(%d) %s\n", num, texte); fprintf(stderr, ">>> start chrono(%d) %s\n", num, texte);
} }
@ -55,13 +50,11 @@ chronos[num].in_use = 1;
return OLL_KORRECT; return OLL_KORRECT;
} }
long long Image_stop_chrono(char *texte, int num)
Image_stop_chrono(char *texte, int num)
{ {
long delta_t; long delta_t;
if (num < 0 || num >= NB_CHRONOS) if (num < 0 || num >= NB_CHRONOS) {
{
return -1L; return -1L;
} }
time(&chronos[num].fin); time(&chronos[num].fin);
@ -73,14 +66,12 @@ if (texte != NULL)
return delta_t; return delta_t;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_dump_colormap(RGB_map *map, int verbose)
Image_dump_colormap(RGB_map *map, int verbose)
{ {
int foo; int foo;
if (map == NULL) if (map == NULL) {
{ fprintf(stderr, "%s: 'map' ptr is NULL\n", __func__);
fprintf(stderr, "Dump ColorMap: 'map' ptr is NULL\n");
return NULL_DESCRIPTOR; return NULL_DESCRIPTOR;
} }
@ -89,10 +80,8 @@ printf("| nom de la palette : %s\n", map->name);
printf("| nombre de couleurs : %d\n", map->nbre); printf("| nombre de couleurs : %d\n", map->nbre);
printf("+---------------------------\n"); printf("+---------------------------\n");
if (verbose) if (verbose) {
{ for (foo=0; foo<map->nbre; foo++) {
for (foo=0; foo<map->nbre; foo++)
{
printf("%3d: %3d %3d %3d\n", foo, printf("%3d: %3d %3d %3d\n", foo,
map->red[foo], map->green[foo], map->blue[foo]); map->red[foo], map->green[foo], map->blue[foo]);
} }
@ -101,8 +90,7 @@ if (verbose)
return 0; return 0;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_dump_descriptor(Image_Desc *im, char *text)
Image_dump_descriptor(Image_Desc *im, char *text)
{ {
fflush(stdout); fflush(stdout);
printf("/-------- Descriptor Dump (lib v=%s) -----------\n", printf("/-------- Descriptor Dump (lib v=%s) -----------\n",
@ -110,13 +98,11 @@ printf("/-------- Descriptor Dump (lib v=%s) -----------\n",
printf("| why text: %s\n", text); printf("| why text: %s\n", text);
printf("| main pointer: %p\n", im); printf("| main pointer: %p\n", im);
if ( im==NULL ) if ( im==NULL ) {
{
printf("!\t\tthis is a null descriptor, good luck, Sir...\n"); printf("!\t\tthis is a null descriptor, good luck, Sir...\n");
return NULL_DESCRIPTOR; return NULL_DESCRIPTOR;
} }
else else {
{
printf("| name: %s\n", im->name); printf("| name: %s\n", im->name);
printf("| comment: %s\n", im->comment); printf("| comment: %s\n", im->comment);
printf("| magic: 0x%08lx\n", im->magic); printf("| magic: 0x%08lx\n", im->magic);
@ -136,8 +122,7 @@ fflush(stdout);
return 0; return 0;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_dump_rect(Image_Rect *rect, char *texte, int flag)
Image_dump_rect(Image_Rect *rect, char *texte, int flag)
{ {
printf("Rect: '%s'\n\t%5d %5d %5d %5d $%08lx\n", texte, printf("Rect: '%s'\n\t%5d %5d %5d %5d $%08lx\n", texte,
rect->x, rect->y, rect->w, rect->h, rect->reserved); rect->x, rect->y, rect->w, rect->h, rect->reserved);
@ -190,8 +175,7 @@ ligne_char(caractere, len+10);
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_print_rgba(char *txt, RGBA *rgba, int hexa)
Image_print_rgba(char *txt, RGBA *rgba, int hexa)
{ {
char *fmtd = "%-20s: RGBA %4d %4d %4d %4d\n"; char *fmtd = "%-20s: RGBA %4d %4d %4d %4d\n";
char *fmth = "%-20s: 0xRGBA %02x %02x %02x %02x\n"; char *fmth = "%-20s: 0xRGBA %02x %02x %02x %02x\n";
@ -211,19 +195,16 @@ return OLL_KORRECT;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* affichage d'un descripteur de DF3 - new 28feb2008 - ave St Exupery */ /* affichage d'un descripteur de DF3 - new 28feb2008 - ave St Exupery */
int int Image_print_DF3head(DensityF3Head *h, char *txt, int flag)
Image_print_DF3head(DensityF3Head *h, char *txt, int flag)
{ {
int retval = 0; int retval = 0;
int foo; int foo;
if (NULL == h) if (NULL == h) {
{
fprintf(stderr, "%s: null pointer\n", __func__); fprintf(stderr, "%s: null pointer\n", __func__);
return 666; return 666;
} }
if (h->control != MAGIC_OF_DF3) if (h->control != MAGIC_OF_DF3) {
{
fprintf(stderr, "%s: bad magic value\n", __func__); fprintf(stderr, "%s: bad magic value\n", __func__);
return 666; return 666;
} }
@ -236,13 +217,11 @@ printf("| dims: %d %d %d\n", h->xdim, h->ydim, h->zdim);
foo = h->nbrbytes; foo = h->nbrbytes;
printf("| nbr bytes: %d ", foo); printf("| nbr bytes: %d ", foo);
if ( (foo!=1) && (foo!=2) && (foo!=4) ) if ( (foo!=1) && (foo!=2) && (foo!=4) ) {
{
printf("**ERROR**\n"); printf("**ERROR**\n");
retval++; retval++;
} }
else else {
{
printf("\n"); printf("\n");
} }
@ -254,24 +233,19 @@ printf("+------------------------------------\n");
return FUNC_IS_ALPHA; return FUNC_IS_ALPHA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_Overlay_Palette(Image_Desc *im, int xo, int yo)
Image_Overlay_Palette(Image_Desc *im, int xo, int yo)
{ {
int x, y, xx, yy, code; int x, y, xx, yy, code;
int r, g, b; int r, g, b;
/* No boundchecking here ? */ /* No boundchecking here ? */
for (y=0; y<128; y++) for (y=0; y<128; y++) {
{
yy = y + yo; yy = y + yo;
if ( (yy >= 0) && (yy<im->height) ) if ( (yy >= 0) && (yy<im->height) ) {
{ for (x=0; x<256; x++) {
for (x=0; x<256; x++)
{
xx = x + xo; xx = x + xo;
if ( (xx >= 0) && (xx<im->width) ) if ( (xx >= 0) && (xx<im->width) ) {
{
code = (y<<8) | x; code = (y<<8) | x;
r = (code & 0x1f) * 4; r = (code & 0x1f) * 4;
@ -292,8 +266,7 @@ return 0;
* this function need more security controls * this function need more security controls
* see also: mircol.c * see also: mircol.c
*/ */
int int Image_fabrique_une_mire(Image_Desc *im, RGB_map *map)
Image_fabrique_une_mire(Image_Desc *im, RGB_map *map)
{ {
int foo, bar; int foo, bar;
@ -303,17 +276,14 @@ fprintf(stderr, "%s : %p %p\n", __func__, im, map);
if ( (im->width < 320) || (im->width<200) ) if ( (im->width < 320) || (im->width<200) )
return IMAGE_TOO_SMALL; return IMAGE_TOO_SMALL;
if (NULL != map) if (NULL != map) {
{
fprintf(stderr, "%s:%s map must be null\n", __FILE__, __func__); fprintf(stderr, "%s:%s map must be null\n", __FILE__, __func__);
exit(5); exit(5);
} }
Image_Overlay_Palette(im, 50, 10); Image_Overlay_Palette(im, 50, 10);
for (foo=0; foo<256; foo++) for (foo=0; foo<256; foo++) {
{ for (bar=0; bar<10; bar++) {
for (bar=0; bar<10; bar++)
{
Image_plotRGB(im, foo, bar, foo, foo, foo); Image_plotRGB(im, foo, bar, foo, foo, foo);
Image_plotRGB(im, foo, 190+bar, 256-foo, 256-foo, 256-foo); Image_plotRGB(im, foo, 190+bar, 256-foo, 256-foo, 256-foo);
} }
@ -326,8 +296,7 @@ return OLL_KORRECT;
/* /*
* This func make a grid over an image, and need a lot of work. * This func make a grid over an image, and need a lot of work.
*/ */
int int Image_Grille(Image_Desc *im, int stepx, int stepy, int rgb)
Image_Grille(Image_Desc *im, int stepx, int stepy, int rgb)
{ {
int foo, bar; int foo, bar;
int r, g, b; int r, g, b;
@ -341,14 +310,12 @@ else {
r = g = b = rgb; r = g = b = rgb;
} }
for (foo=0; foo<im->width; foo+=stepx) for (foo=0; foo<im->width; foo+=stepx) {
{
for (bar=0; bar<im->height; bar++) for (bar=0; bar<im->height; bar++)
Image_plotRGB(im, foo, bar, r, g, b); Image_plotRGB(im, foo, bar, r, g, b);
} }
for (foo=0; foo<im->height; foo+=stepy) for (foo=0; foo<im->height; foo+=stepy) {
{
for (bar=0; bar<im->width; bar++) for (bar=0; bar<im->width; bar++)
Image_plotRGB(im, bar, foo, r, g, b); Image_plotRGB(im, bar, foo, r, g, b);
} }
@ -357,8 +324,7 @@ im->modified = 1;
return OLL_KORRECT; return OLL_KORRECT;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_print_minmax(Image_Desc *img)
Image_print_minmax(Image_Desc *img)
{ {
int res[8], foo; int res[8], foo;
@ -376,9 +342,9 @@ int Image_xy_inside(Image_Desc *img, int x, int y)
{ {
/* /*
* 1er mars 2010 : this func need a g77 binding * 1er mars 2010 : this func need a g77 binding
* ???
*/ */
if ( (x<0) || (y<0) || (x>=img->width) || (y>=img->height) ) if ( (x<0) || (y<0) || (x>=img->width) || (y>=img->height) ) {
{
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL > 1
fprintf(stderr, "%s : %p %6d %6d --> FAIL\n", __func__, img, x, y); fprintf(stderr, "%s : %p %6d %6d --> FAIL\n", __func__, img, x, y);
#endif #endif

View File

@ -16,20 +16,19 @@ HTML_DIR=$(DESTDIR)/html
# but this files can't be loaded by Xv... # but this files can't be loaded by Xv...
# pour coredumper dans les situations graves: -DABORT=1 # pour coredumper dans les situations graves: -DABORT=1
# #
# --> see file 'PORTING.txt' for porting tips on misc
# architextures (just sparc64 for now)
#
# use -Wmissing-prototypes ? # use -Wmissing-prototypes ?
LIBIMG_OPT=-DFORCE_ABORT=1 -DDEBUG_LEVEL=0 -DIMGCOMMENT=0 LIBIMG_OPT=-DFORCE_ABORT=0 -DDEBUG_LEVEL=0 -DIMGCOMMENT=0
CC_OPTS=-Wall -W -g -pg -ansi -O3 -fPIC -no-pie CC_OPTS=-Wall -W -g -ansi -O3 -fPIC -no-pie
CC_HACKS=-DNEED_ALLOCA_H CC_HACKS=-DNEED_ALLOCA_H
CFLAGS= $(CC_OPTS) \ CFLAGS= $(CC_OPTS) \
$(LIBIMG_OPT) \ $(LIBIMG_OPT) \
$(CC_HACKS) \ $(CC_HACKS) \
-DDESTDIR=\"$(DESTDIR)\" \ -DDESTDIR=\"$(DESTDIR)\" \
-DSHAREDIR=\"$(SHARED_FILES)\" \ -DSHAREDIR=\"$(SHARED_FILES)\" \
-DCC_OPTS=\"'$(CC_OPTS)'\" -DCC_OPTS=\"'$(CC_OPTS)'\"
LINKOPT=-lm LINKOPT=-lm
RANLIB=wc -c RANLIB=wc -c

View File

@ -63,16 +63,14 @@ fprintf(stderr, "%s:%d %s ( %s, %d )\n", __FILE__, __LINE__,
__func__, filename, flags); __func__, filename, flags);
#endif #endif
foo = Image_TGA_get_dims(filename, &width, &height); foo = Image_TGA_get_dims(filename, &width, &height);
if (foo) 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; return foo;
} }
foo = 0; foo = 0;
switch(flags) switch(flags) {
{
case 0: case 0:
printf("%8d %8d\n", width, height); break; printf("%8d %8d\n", width, height); break;
case 1: case 1:

View File

@ -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 28" #define IMAGE_VERSION_STRING "0.4.51 pl 32"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
@ -875,8 +875,8 @@ int Image_BMP_save_24(char *filename, Image_Desc *img, int flag);
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* module tga.c */ /* module tga.c */
int Image_TGA_save(char *nom, Image_Desc *img, int compress); int Image_TGA_save(char *nom, Image_Desc *img, int compress);
int Image_TGA_save_component(char *nom, Image_Desc *img, char chanl, int comp); int Image_TGA_save_component(char *nom, Image_Desc *img, char chanl, int comp);
/* int Image_TGA_print_header(void *ph); XXX */ /* int Image_TGA_print_header(void *ph); XXX */
int Image_TGA_read_header(FILE *fpin, void *phead); int Image_TGA_read_header(FILE *fpin, void *phead);
int Image_TGA_show_header(char *filename, int flag); int Image_TGA_show_header(char *filename, int flag);