more clean

This commit is contained in:
tTh 2023-09-28 23:50:23 +02:00
parent 21de0960e8
commit 2594cabf94
15 changed files with 68 additions and 47 deletions

View File

@ -3,3 +3,9 @@
Ugly software born around 1995 on a MS-Dos 286 computer.
Look at the `Makefile` for no more explanations.
## Text primitives
Big rewrite in progress, the actual version is a mess.

View File

@ -246,14 +246,13 @@ return OLL_KORRECT;
}
/*::------------------------------------------------------------------::*/
int
Image_LUT_mono(Image_Desc *src, Image_Desc *dst, int *lut)
int Image_LUT_mono(Image_Desc *src, Image_Desc *dst, int *lut)
{
int x, y, foo;
if ( (foo=Image_compare_desc(src, dst)) )
{
fprintf(stderr, "Image_LUT_mono: images differentes %d\n", foo);
fprintf(stderr, "%s: images differentes %d\n", __func__, foo);
return foo;
}
@ -267,7 +266,7 @@ for (y=0; y<src->height; y++)
}
}
return 0;
return OLL_KORRECT;
}
/*::------------------------------------------------------------------::*/
/* et en parlant de LUTs, il n'y aurait pas un truc pour les LUTs

View File

@ -76,7 +76,7 @@ if (xa > xb) { ix=xa, xa=xb, xb=ix; }
for (ix=xa; ix<xb; ix++) {
Image_plotRGB(i, ix, ypos, col->r, col->g, col->b);
}
return FUNC_IS_ALPHA;
return FUNC_IS_BETA;
}
/*::------------------------------------------------------------------::*/
/*

View File

@ -37,7 +37,7 @@ if (NULL==(dst=Image_clone(src, 0))) {
}
foo = Image_tampon_alpha_0(src, NULL, dst);
if (foo) Image_print_error(__func__, foo);
if (foo) Image_print_error(fname, foo);
Image_TGA_save("Pictures/aaaa-tampon.tga", dst, 0);
@ -331,7 +331,9 @@ if ( NULL == (nucked=Image_clone(origine, 1)) ) {
}
foo = Image_essai_zoom(origine, nucked, 1.18, 0.42, 0);
if (foo) {
fprintf(stderr, "In %s, essai zoom -> %d\n", foo);
}
Image_TGA_save("Pictures/aaaa-zoom.tga", nucked, 0);
Image_DeAllocate(nucked); free(nucked);
@ -442,6 +444,8 @@ static int datas_prewitt[] =
-1, -1, -1,
1, 128
};
#if 0
/* WHAT THE HELL is this data thing ? */
static struct offxy
{ int x, y; } offsets[] = {
{ 1, 0 },
@ -453,6 +457,7 @@ static struct offxy
{ 0, 1 },
{ 0, 0 }
};
#endif
printf("========= Filtrage directionnel sur %s =======\n", srcname);

View File

@ -74,7 +74,8 @@ return OLL_KORRECT;
int main(int argc, char *argv[])
{
int foo;
fprintf(stderr, "*** %s is running\n", argv[0]);
essai_gradients();

View File

@ -105,7 +105,7 @@ return FULL_NUCKED;
}
/*::------------------------------------------------------------------::*/
/*
* attr,yion parametres bizarres
* attention parametres bizarres
*/
int Image_gadrct_poke_from_tga(char *namesrc, Image_Rect *fromrect,
Image_Desc *dst, int xdst, int ydst, int flags)

View File

@ -29,9 +29,9 @@ switch (code)
abort();
break;
}
#if DEBUG_LEVEL
fprintf(stderr, "%s -> %d\n", __func__, foo);
#endif
if (foo) {
fprintf(stderr, "%s got a %d\n", __func__, foo);
}
return FULL_NUCKED;
}
@ -53,9 +53,9 @@ for (nbre=0; nbre<k; nbre++)
{
x = rand() % src->width;
y = rand() % src->height;
d = rand() & 3;
Image_getRGB(src, x, y, &r, &g, &b);
d = rand() & 3;
switch (d)
{
case 0:

View File

@ -38,12 +38,10 @@ Image_marque_1(Image_Desc *img, char *texte, int flags)
RGBA papier, encre;
int len;
#if DEBUG_LEVEL
if (flags)
{
fprintf(stderr, "*** %s 'flags' must be ZERO ***\n", __func__);
}
#endif
len = strlen(texte);
if (len < 1) return FULL_NUCKED;
@ -110,22 +108,19 @@ fprintf(stderr, "%s: '%s' %s\n", __func__, texte, ptr);
#endif
papier.r = papier.g = papier.b = papier.a = 0;
if (rgba == NULL)
{
if (NULL == rgba) {
encre.r = encre.g = encre.b = 90, encre.a = 255;
rgba = &encre;
}
if (flags & 1)
{
if (flags & 1) {
rect.x = rect.y = 3;
rect.h = 11; rect.w = l1*8+2;
Image_paint_rect(img, &rect, 255, 255, 255);
}
Image_trace_chaine_1(img, texte, 5, 6, "libimage.fonte", &papier, rgba);
if (flags & 1)
{
if (flags & 1) {
rect.x = 3; rect.y = 16;
rect.h = 11; rect.w = l2*8+2;
Image_paint_rect(img, &rect, 255, 255, 255);
@ -133,10 +128,6 @@ if (flags & 1)
Image_trace_chaine_1(img, ptr, 5, 18, NULL, &papier, rgba);
#if DEBUG_LEVEL
fprintf(stderr, "done %s\n", __func__);
#endif
img->modified = 1;
return FUNC_IS_BETA;

View File

@ -27,6 +27,8 @@ return FULL_NUCKED;
int Image_rot_pixel(Image_Desc *img, int x, int y, int r, int g, int b)
{
fprintf(stderr, "%s is wtf\n", __func__);
if ( (x<0) || (y<0) || (x>=img->width) || (y>=img->height) )
{
fprintf(stderr, "%s : out of pic (%d, %d)\n", __func__, x, y);

View File

@ -35,7 +35,7 @@ int Image_load_fnt8x8(char *nomfnt, uint8_t *ou, int flags)
{
int fd, foo;
#if DEBUG_LEVEL > -1
#if DEBUG_LEVEL > 1
fprintf(stderr, ">>> %s ( '%s' %p %d )\n", __func__, nomfnt, ou, flags);
#endif
@ -47,7 +47,9 @@ if (0 != flags)
/* patch du 24 septembre 2015 */
if (NULL == nomfnt) {
nomfnt = "libimage.fonte";
fprintf(stderr, "%s : using default font '%s'\n", __func__, nomfnt);
#if DEBUG_LEVEL
fprintf(stderr, " using default font '%s'\n", nomfnt);
#endif
}
/* on pourrait aussi mettre la fonte par ddefaut dans l'environ */
@ -56,6 +58,10 @@ if ( (fd=Image_must_open(nomfnt, O_RDONLY, 0)) < 0 ) {
exit(5);
}
/*
* Maybe add a check on the size of the file ?
*/
foo = read(fd, priv_fonte, T_FONTE);
if ( foo != T_FONTE ) {
fprintf(stderr, "%s: read only %d bytes from font file\n", __func__, foo);
@ -67,6 +73,8 @@ close(fd);
fprintf(stderr, "%s : font '%s' loaded\n", __func__, nomfnt);
#endif
font_is_loaded = 1;
return OLL_KORRECT;
}
/*::------------------------------------------------------------------::*/
@ -154,6 +162,7 @@ int foo;
fprintf(stderr, "THE FUNCTION '%s' IS OBSOLETE\n", __func__);
if (0 != flags)
fprintf(stderr, "in %s, 'flags' (%d) must be 0\n", __func__, flags);
foo = Image_trace_chaine_1(im, txt, x, y, "libimage.fonte", paper, ink);
return foo;
@ -171,9 +180,14 @@ int posx, posy, t_texte, foo;
int octet;
uint8_t *ptrtxt;
RGBA blanc = { 255, 255, 255, 255, 0, 0 };
RGBA noir = { 0, 0, 0, 64, 0, 0 };
RGBA noir = { 0, 0, 0, 64, 0, 0 };
if (nomfonte==NULL) {
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p '%s' %d %d '%s' %p %p\n", __func__,
im, txt, x, y, nomfonte, paper, ink);
#endif
if (NULL == nomfonte) {
#if DEBUG_LEVEL > 1
fprintf(stderr, "trace chaine 1: using loaded font\n");
#endif
@ -188,7 +202,7 @@ else {
if (NULL==paper) paper = &blanc;
if (NULL==ink) ink = &noir;
#if DEBUG_LEVEL > 1
#if DEBUG_LEVEL
Image_print_rgba("encre", ink, 0);
Image_print_rgba("papier", paper, 0);
#endif

View File

@ -87,9 +87,9 @@ for (idx=0; idx<len; idx++)
idx, txt[idx], xpos);
#endif
foo = Image_trace_big_char_0(im, xpos, y, txt[idx], xf, yf);
#if DEBUG_LEVEL
fprintf(stderr, "Image_trace_big_char_0 -> %d\n", foo);
#endif
if (foo) {
fprintf(stderr, "Image_trace_big_char_0 -> %d\n", foo);
}
xpos += (xf * 8);
}

View File

@ -169,9 +169,9 @@ fprintf(stderr, "%s : ligne 1 = %s\n", __func__, lig1);
fprintf(stderr, "%s : ligne 2 = %s\n", __func__, lig2);
#endif
ligne_char(caractere, len+10);
ligne_space(caractere, len+10);
ligne_char(caractere, len+10);
ligne_char(caractere, len+10+k);
ligne_space(caractere, len+10+k);
ligne_char(caractere, len+10+k);
}
/*::------------------------------------------------------------------::*/
@ -209,7 +209,7 @@ if (h->control != MAGIC_OF_DF3) {
return 666;
}
printf("+--- DF3head @ %p -- %s --\n", h, txt);
printf("+--- DF3head @ %p -- %s -- %c\n", h, txt, flag ? 'X' : 'O');
printf("| magic: %08lx\n", h->control);
printf("| name: %s\n", h->name);
printf("| dims: %d %d %d\n", h->xdim, h->ydim, h->zdim);

View File

@ -12,14 +12,13 @@
int
Image_turtle_infos(Image_Desc *img, int flags)
{
int foo;
#if DEBUG_LEVEL
fprintf(stderr, "Image turtle infos: flags = %04x\n", flags);
#endif
if ( flags & 1 )
foo = Image_dump_descriptor(img, "turtle infos");
Image_dump_descriptor(img, "turtle infos");
return FUNC_IS_ALPHA;
}
@ -46,6 +45,8 @@ Image_turtle_move(Image_Desc *img, double xt, double yt)
img->xt = xt;
img->yt = yt;
fprintf(stderr, ">>> %s ( %p %f %f )\n", __func__, img, xt, yt);
return FUNC_NOT_FINISH;
}
/*::------------------------------------------------------------------::*/
@ -53,7 +54,7 @@ int
Image_turtle_draw(Image_Desc *img, double xt, double yt)
{
(void)img;
fprintf(stderr, ">>> %s ( %p %f %f )\n", __func__, img, xt, yt);
return FUNC_NOT_FINISH;

View File

@ -19,7 +19,7 @@ HTML_DIR=$(DESTDIR)/html
# use -Wmissing-prototypes ?
LIBIMG_OPT=-DFORCE_ABORT=0 -DDEBUG_LEVEL=0 -DIMGCOMMENT=0
CC_OPTS=-Wall -W -g -ansi -O3 -fPIC -no-pie
CC_OPTS=-Wall -W -g -ansi -O3 -fPIC -no-pie
CC_HACKS=-DNEED_ALLOCA_H
CFLAGS= $(CC_OPTS) \

View File

@ -4,7 +4,7 @@
http://la.buvette.org/devel/libimage/
*/
#ifndef IMAGE_VERSION_STRING
#define IMAGE_VERSION_STRING "0.4.51 pl 50"
#define IMAGE_VERSION_STRING "0.4.51 pl 57"
/*::------------------------------------------------------------------::*/
/*
@ -294,9 +294,11 @@ void Image_print_version(int verbose);
Image_Desc *Image_alloc(int width, int height, int type);
Image_Desc *Image_clone(Image_Desc *src, int copy);
int Image_clear( Image_Desc *image, int r, int v, int b );
int Image_set_rgb(Image_Desc *img, RGBA *rgba);
int Image_copy(Image_Desc *src, Image_Desc *dst);
int Image_set_comment(Image_Desc *image, char *text);
int Image_copy_comment(Image_Desc *s, Image_Desc *d);
int Image_DeAllocate( Image_Desc *im ); /* nice coredumper */
int Image_plot_gray(Image_Desc *img, int x, int y, int v);
@ -317,7 +319,6 @@ int Image_pixel_copy(Image_Desc *s, int x, int y, Image_Desc *d, int i, int j);
int Image_compare_desc(Image_Desc *a, Image_Desc *b);
int Image_DeAllocate( Image_Desc *im ); /* nice coredumper */
/*::------------------------------------------------------------------::*/
/* module pixels.c */
@ -1012,10 +1013,11 @@ int Image_2x2_shiftUL(Image_Desc *src, Image_Desc *dst);
module de trace de primitives. (drawing.c)
*/
int Image_draw_circle(Image_Desc *i, int xc, int yc, int ray, RGBA *q, int m);
int Image_draw_line(Image_Desc *i, int x1, int y1, int x2, int y2, RGBA *q);
int Image_paint_rect(Image_Desc *, Image_Rect *, int, int, int);
int Image_noise_rect(Image_Desc *, Image_Rect *, int, int, int);
int Image_draw_rect(Image_Desc *, Image_Rect *, int, int, int);
int Image_H_line(Image_Desc *i, int xa, int xb, int ypos, RGBA *col);
int Image_draw_line (Image_Desc *i, int x1, int y1, int x2, int y2, RGBA *q);
int Image_paint_rect (Image_Desc *, Image_Rect *, int, int, int);
int Image_noise_rect (Image_Desc *, Image_Rect *, int, int, int);
int Image_draw_rect (Image_Desc *, Image_Rect *, int, int, int);
/*
* la meme chose, avec le canal alpha (draw_alpha.c)