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
[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
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
* ne doit pas changer, car d'autres fonctions en dependent.
*/
int
Image_cadre_A(Image_Desc *im)
int Image_cadre_A(Image_Desc *im)
{
int x, y;
int a, b;
a = 0; b = 255;
for (x=0; x<im->width; x++)
{
for (x=0; x<im->width; x++) {
(im->Rpix[0])[x] = a;
(im->Gpix[0])[x] = a;
(im->Bpix[0])[x] = 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->Gpix[y])[0] = a;
(im->Bpix[y])[0] = 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->Gpix[1])[x] = b;
(im->Bpix[1])[x] = 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->Gpix[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 :)
*/
int
Image_cadre_cracra(Image_Desc *im, int largeur, int k)
int Image_cadre_cracra(Image_Desc *im, int largeur, int k)
{
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);
#endif
for (y=0; y<im->height; y++)
{
for (x=0; x<largeur; x++)
{
for (y=0; y<im->height; y++) {
for (x=0; x<largeur; x++) {
r = rand() % (10 + x * 20);
g = rand() % (11 + x * 10);
b = rand() % (10 + x * 12);
@ -81,8 +73,7 @@ for (y=0; y<im->height; y++)
(im->Gpix[y])[x] = g;
(im->Bpix[y])[x] = b;
}
for (x=0; x<largeur; x++)
{
for (x=0; x<largeur; x++) {
r = rand() % (10 + (largeur-x) * 20);
g = rand() % (10 + (largeur-x) * 10);
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 (y=0; y<largeur; y++)
{
for (x=0; x<im->width; x++) {
for (y=0; y<largeur; y++) {
r = rand() % (10 + y * 10);
g = rand() % (10 + y * 12);
b = rand() % (10 + y * 20);
@ -102,8 +91,7 @@ for (x=0; x<im->width; x++)
(im->Gpix[y])[x] = g;
(im->Bpix[y])[x] = b;
}
for (y=0; y<largeur; y++)
{
for (y=0; y<largeur; y++) {
r = rand() % (10 + (largeur-y) * 10);
g = rand() % (10 + (largeur-y) * 12);
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.
*/
int
Image_cadre_bruit(Image_Desc *im, int r, int g, int b, int n)
int Image_cadre_bruit(Image_Desc *im, int r, int g, int b, int n)
{
int x, y, x2, y2, ir, ig, ib;
float fx, fy;
@ -211,8 +198,7 @@ fn = (float)(n*n);
x2 = im->width / 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
*/
@ -220,8 +206,7 @@ for (y=0; y<im->height; y++)
else fy = (float)((im->height - y)-1);
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
*/
@ -232,15 +217,12 @@ for (y=0; y<im->height; y++)
if (fx < fy) d = fx;
else d = fy;
if (d < fn)
{
if (d < fn) {
level = (int)((d / fn) * 1000.0);
if ( (rand()%1000) < level )
{
if ( (rand()%1000) < level ) {
Image_getRGB(im, x, y, &ir, &ig, &ib);
}
else
{
else {
ir = r; ig = g; ib = b;
}
/* Image_plotRGB(im, x, y, ir, ig, ib); */
@ -255,14 +237,12 @@ return OLL_KORRECT;
}
/*::------------------------------------------------------------------::*/
/* inventee pour blablanux :) */
int
Image_cadre_E(Image_Desc *im, int v1, int v2, int v3, int dim)
int Image_cadre_E(Image_Desc *im, int v1, int v2, int v3, int dim)
{
int foo, bar;
Image_Rect rect;
for (foo=0; foo<dim; foo++)
{
for (foo=0; foo<dim; foo++) {
bar = 1 << (foo%8);
#if DEBUG_LEVEL > 1
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);
}
return 0;
return OLL_KORRECT;
}
/*::------------------------------------------------------------------::*/
/* 5 Fev 2001
* pas de dégradé
*/
int
Image_cadre_pattern_0(Image_Desc *im, Image_Desc *pat, int larg)
int Image_cadre_pattern_0(Image_Desc *im, Image_Desc *pat, int larg)
{
int x, y, r, g, b;
/*
* Tiens, je la supposais plus facile a ecrire...
*/
for (y=0; y<im->height; y++)
{
for (x=0; x<larg; x++)
{
for (y=0; y<im->height; y++) {
for (x=0; x<larg; x++) {
Image_getRGB(pat, x%pat->width, y%pat->height, &r, &g, &b);
/* Image_plotRGB(im, x, y, r, g, b); */
(im->Rpix[y])[x] = r;
(im->Gpix[y])[x] = g;
(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_plotRGB(im, x, y, r, g, b); */
(im->Rpix[y])[x] = r;
@ -308,18 +284,15 @@ for (y=0; y<im->height; y++)
}
}
for (x=0; x<im->width; x++)
{
for (y=0; y<larg; y++)
{
for (x=0; x<im->width; x++) {
for (y=0; y<larg; y++) {
Image_getRGB(pat, x%pat->width, y%pat->height, &r, &g, &b);
/* Image_plotRGB(im, x, y, r, g, b); */
(im->Rpix[y])[x] = r;
(im->Gpix[y])[x] = g;
(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_plotRGB(im, x, y, r, g, b); */
(im->Rpix[y])[x] = r;
@ -332,10 +305,9 @@ return OLL_KORRECT;
}
/*::------------------------------------------------------------------::*/
/* 12 Feb 2001
* dégradé propotionnel à la distance
* dégradé proportionnel à la distance
*/
int
Image_cadre_pattern_1(Image_Desc *im, Image_Desc *pat, int n)
int 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;
float fx, fy;
@ -348,12 +320,11 @@ x2 = im->width / 2;
y2 = im->height / 2;
#if DEBUG_LEVEL
fprintf(stderr, "*** cadre pattern 1 : fn = %f\n", fn);
fprintf(stderr, "*** %s: fn = %f\n", __func__, fn);
#endif
lmax = 0;
for (y=0; y<im->height; y++)
{
for (y=0; y<im->height; y++) {
/*
* 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);
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
@ -377,11 +347,9 @@ for (y=0; y<im->height; y++)
if (fx < fy) d = fx;
else d = fy;
if (d < fn)
{
if (d < fn) {
level = (int)(100 * d / fn);
if (level > lmax)
{
if (level > lmax) {
lmax = level;
}
@ -405,8 +373,7 @@ fprintf(stderr, "cadre pattern 1 : lmax = %d\n", lmax);
return OLL_KORRECT;
}
/*::------------------------------------------------------------------::*/
int
Image_cadre_pattern_2(Image_Desc *im, Image_Desc *pat, int n)
int Image_cadre_pattern_2(Image_Desc *im, Image_Desc *pat, int n)
{
int x, y, x2, y2, ir, ig, ib;
int xp, yp;
@ -425,15 +392,13 @@ fprintf(stderr, "*** cadre pat 2 : pat: %d x %d\n", pat->width, pat->height);
#endif
lmax = 0;
for (y=0; y<im->height; y++)
{
for (y=0; y<im->height; y++) {
/* distance au bord HAUT BAS le plus proche */
if (y < y2) fy = (float)y;
else fy = (float)((im->height - y)-1);
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 */
if (x < x2) fx = (float)x;
else fx = (float)((im->width - x)-1);
@ -442,15 +407,12 @@ for (y=0; y<im->height; y++)
if (fx < fy) d = fx;
else d = fy;
if (d < fn)
{
if (d < fn) {
level = (int)((d / fn) * 1000.0);
if ( (rand()%1000) < level )
{
if ( (rand()%1000) < level ) {
Image_getRGB(im, x, y, &ir, &ig, &ib);
}
else
{
else {
xp = x % pat->width;
yp = y % pat->height;
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
*/
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;
@ -477,35 +439,29 @@ fprintf(stderr, ">>> %s ( %p %d %d %d %d %d )\n", __func__,
im, r, g, b, nh, nv);
#endif
for (y=0; y<im->height; y++)
{
for (x=0; x<nv; x++)
{
for (y=0; y<im->height; y++) {
for (x=0; x<nx; x++) {
(im->Rpix[y])[x] = r;
(im->Gpix[y])[x] = g;
(im->Bpix[y])[x] = b;
}
for (x=0; x<nv; x++)
{
(im->Rpix[y])[im->width-x] = r;
(im->Gpix[y])[im->width-x] = g;
(im->Bpix[y])[im->width-x] = b;
for (x=0; x<nx; x++) {
(im->Rpix[y])[im->width-x-1] = r;
(im->Gpix[y])[im->width-x-1] = g;
(im->Bpix[y])[im->width-x-1] = b;
}
}
for (x=0; x<im->width; x++)
{
for (y=0; y<nh; y++)
{
for (x=0; x<im->width; x++) {
for (y=0; y<ny; y++) {
(im->Rpix[y])[x] = r;
(im->Gpix[y])[x] = g;
(im->Bpix[y])[x] = b;
}
for (y=0; y<nh; y++)
{
(im->Rpix[y+im->height-nh])[x] = r;
(im->Gpix[y+im->height-nh])[x] = g;
(im->Bpix[y+im->height-nh])[x] = b;
for (y=0; y<ny; y++) {
(im->Rpix[y+im->height-ny])[x] = r;
(im->Gpix[y+im->height-ny])[x] = g;
(im->Bpix[y+im->height-ny])[x] = b;
}
}

View File

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

View File

@ -14,8 +14,7 @@
/*
Le coefficient K va de 0 a 10000 !
*/
int
Image_mix(Image_Desc *a, Image_Desc *b, Image_Desc *c, int k)
int Image_mix(Image_Desc *a, Image_Desc *b, Image_Desc *c, int k)
{
int x, y;
int ra, rb, mk;
@ -25,7 +24,7 @@ int foo;
if ( (foo=Image_compare_desc(a, b)) ||
(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",
a->width, a->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
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];
pga = a->Gpix[y]; pgb = b->Gpix[y]; pgk = c->Gpix[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];
rb = prb[x];
prk[x] = ((ra * k) + (rb * mk)) / 10000;
@ -66,8 +63,7 @@ return 0;
/* new 6 nov 2001
Les coefficients K[rgb] vont de 0 a 10000 !
*/
int
Image_mix_rgb(Image_Desc *a, Image_Desc *b, Image_Desc *c,
int Image_mix_rgb(Image_Desc *a, Image_Desc *b, Image_Desc *c,
int kr, int kg, int kb)
{
int foo, x, y;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -25,6 +25,7 @@
#define T_FONTE 2048
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);
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);
}
close(fd);
@ -220,8 +221,7 @@ return 0;
* Don't forget to load a font, eg :
* Image_load_fnt8x8("8x8thin", NULL, 0);
*/
int
Image_trace_big_char_0(Image_Desc *im, int x, int y, int code, int kx, int ky)
int Image_trace_big_char_0(Image_Desc *im, int x, int y, int code, int kx, int ky)
{
int foo, bar;
uint8_t octet;
@ -236,19 +236,22 @@ fprintf(stderr, "%s ( %p %4d %4d %s %d %d )\n", __func__, im,
x, y, buff, kx, ky);
#endif
if ( (code < 0) || (code > 255))
{
if ( (code < 0) || (code > 255)) {
fprintf(stderr, "in %s, code (%d) is invalid\n", __func__, code);
return BAD_PARAMETER;
}
Image_load_fnt8x8("8x8thin", NULL, 0);
/* Image_load_fnt8x8("8x8thin", NULL, 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;
/*
* NEED BOUNDARY CHECK !
*/
for (foo=0; foo<8; foo++) /* 8 scan lines */
{
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;
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_draw_rect(im, &rect, 0, 0, 80);
}

View File

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

View File

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

View File

@ -16,20 +16,19 @@ HTML_DIR=$(DESTDIR)/html
# but this files can't be loaded by Xv...
# 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 ?
LIBIMG_OPT=-DFORCE_ABORT=1 -DDEBUG_LEVEL=0 -DIMGCOMMENT=0
CC_OPTS=-Wall -W -g -pg -ansi -O3 -fPIC -no-pie
LIBIMG_OPT=-DFORCE_ABORT=0 -DDEBUG_LEVEL=0 -DIMGCOMMENT=0
CC_OPTS=-Wall -W -g -ansi -O3 -fPIC -no-pie
CC_HACKS=-DNEED_ALLOCA_H
CFLAGS= $(CC_OPTS) \
$(LIBIMG_OPT) \
$(CC_HACKS) \
-DDESTDIR=\"$(DESTDIR)\" \
-DSHAREDIR=\"$(SHARED_FILES)\" \
-DCC_OPTS=\"'$(CC_OPTS)'\"
LINKOPT=-lm
RANLIB=wc -c

View File

@ -63,16 +63,14 @@ fprintf(stderr, "%s:%d %s ( %s, %d )\n", __FILE__, __LINE__,
__func__, filename, flags);
#endif
foo = Image_TGA_get_dims(filename, &width, &height);
if (foo)
{
if (foo) {
fprintf(stderr, "something is bad with %s : %d\n", filename, foo);
Image_print_error("explanation", foo);
return foo;
}
foo = 0;
switch(flags)
{
switch(flags) {
case 0:
printf("%8d %8d\n", width, height); break;
case 1:

View File

@ -4,7 +4,7 @@
http:///la.buvette.org/devel/libimage/
*/
#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 */
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(char *nom, Image_Desc *img, int compress);
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_read_header(FILE *fpin, void *phead);
int Image_TGA_show_header(char *filename, int flag);