Compare commits

..

No commits in common. "2594cabf94c59a797a3a36b92b4bbc4cc92f7b71" and "ba7ba3d66638dc85b2e066ecb57852a8716cb587" have entirely different histories.

17 changed files with 57 additions and 113 deletions

View File

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

View File

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

View File

@ -14,9 +14,8 @@
*/ */
int Image_egalise_cos01(Image_Desc *source, Image_Desc *but, int k) int Image_egalise_cos01(Image_Desc *source, Image_Desc *but, int k)
{ {
int lut[256], uc; unsigned char lut[256], uc;
int idx, foo; int idx, x, y, pix, foo;
/* int x, y, pix; */
float fidx; float fidx;
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__,
@ -34,9 +33,6 @@ for (idx=0; idx<256; idx++) {
/* printf("%7d %7d\n", idx, uc); */ /* printf("%7d %7d\n", idx, uc); */
} }
/*
* old original code, replaced...
*
for (y=0; y<source->height; y++) { for (y=0; y<source->height; y++) {
for (x=0; x<source->width; x++) { for (x=0; x<source->width; x++) {
@ -49,12 +45,8 @@ for (y=0; y<source->height; y++) {
} }
} }
*
* ... by a func from 'calculs.c'
*/
Image_LUT_mono(source, but, lut);
return FUNC_IS_BETA; return FULL_NUCKED;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -13,24 +13,25 @@
#include "../tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
void Image_print_version(int flag) void
Image_print_version(int flag)
{ {
char *ptr; char *ptr;
fflush(stdout); fflush(stdout);
fprintf(stderr, "-+- This is the `tthimage' library v%s (wtfyw 2023) tTh\n", printf("-+- This is the `tthimage' library v%s (wtfyw 2022) tTh\n",
IMAGE_VERSION_STRING); IMAGE_VERSION_STRING);
if (flag) if (flag)
{ {
/* this information is only correct IF you touch image.c before /* this information is only correct IF you touch image.c before
* running 'make' utility */ * running 'make' utility */
fprintf(stderr, " + compiled : %s, %s\n", __DATE__, __TIME__); printf(" + compiled : %s, %s\n", __DATE__, __TIME__);
} }
if (flag > 1) if (flag > 1)
{ {
fprintf(stderr, " + DESTDIR = %s\n", DESTDIR); printf(" + DESTDIR = %s\n", DESTDIR);
fprintf(stderr, " + SHAREDIR = %s\n", SHAREDIR); printf(" + SHAREDIR = %s\n", SHAREDIR);
fprintf(stderr, " + CC OPTS = %s\n", CC_OPTS); printf(" + CC OPTS = %s\n", CC_OPTS);
} }
fflush(stdout); fflush(stdout);
@ -289,34 +290,6 @@ fprintf(stderr, "%s : invalid image type %d : %s\n", __func__,
return IMAGE_BAD_TYPE; return IMAGE_BAD_TYPE;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* new: Sat Sep 23 19:07:03 UTC 2023
*
*/
int Image_set_rgb(Image_Desc *img, RGBA *rgba)
{
int x, y;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p ) %d %d %d\n", __func__, img,
rgba, rgba->r, rgba->g, rgba->b);
#endif
if (IMAGE_RGB != img->type) {
fprintf(stderr, "%s : invalid image type %d : %s\n", __func__,
img->type, Image_type2str(img->type));
return IMAGE_BAD_TYPE;
}
for (y=0; y<img->height; y++) {
for (x=0; x<img->width; x++) {
(img->Rpix[y])[x] = rgba->r;
(img->Gpix[y])[x] = rgba->g;
(img->Bpix[y])[x] = rgba->b;
}
}
return FUNC_IS_BETA;
}
/*::------------------------------------------------------------------::*/
/* /*
* every image in memory have a comment field, who is writen * every image in memory have a comment field, who is writen
* in TGA and PNM file when image is saved. * in TGA and PNM file when image is saved.

View File

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

View File

@ -27,8 +27,6 @@ return FULL_NUCKED;
int Image_rot_pixel(Image_Desc *img, int x, int y, int r, int g, int b) 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) ) if ( (x<0) || (y<0) || (x>=img->width) || (y>=img->height) )
{ {
fprintf(stderr, "%s : out of pic (%d, %d)\n", __func__, x, y); 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; int fd, foo;
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL > -1
fprintf(stderr, ">>> %s ( '%s' %p %d )\n", __func__, nomfnt, ou, flags); fprintf(stderr, ">>> %s ( '%s' %p %d )\n", __func__, nomfnt, ou, flags);
#endif #endif
@ -47,9 +47,7 @@ if (0 != flags)
/* patch du 24 septembre 2015 */ /* patch du 24 septembre 2015 */
if (NULL == nomfnt) { if (NULL == nomfnt) {
nomfnt = "libimage.fonte"; nomfnt = "libimage.fonte";
#if DEBUG_LEVEL fprintf(stderr, "%s : using default font '%s'\n", __func__, nomfnt);
fprintf(stderr, " using default font '%s'\n", nomfnt);
#endif
} }
/* on pourrait aussi mettre la fonte par ddefaut dans l'environ */ /* on pourrait aussi mettre la fonte par ddefaut dans l'environ */
@ -58,10 +56,6 @@ if ( (fd=Image_must_open(nomfnt, O_RDONLY, 0)) < 0 ) {
exit(5); exit(5);
} }
/*
* Maybe add a check on the size of the file ?
*/
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: read only %d bytes from font file\n", __func__, foo); fprintf(stderr, "%s: read only %d bytes from font file\n", __func__, foo);
@ -73,8 +67,6 @@ close(fd);
fprintf(stderr, "%s : font '%s' loaded\n", __func__, nomfnt); fprintf(stderr, "%s : font '%s' loaded\n", __func__, nomfnt);
#endif #endif
font_is_loaded = 1;
return OLL_KORRECT; return OLL_KORRECT;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
@ -162,7 +154,6 @@ int foo;
fprintf(stderr, "THE FUNCTION '%s' IS OBSOLETE\n", __func__); fprintf(stderr, "THE FUNCTION '%s' IS OBSOLETE\n", __func__);
if (0 != flags) if (0 != flags)
fprintf(stderr, "in %s, 'flags' (%d) must be 0\n", __func__, 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); foo = Image_trace_chaine_1(im, txt, x, y, "libimage.fonte", paper, ink);
return foo; return foo;
@ -182,12 +173,7 @@ uint8_t *ptrtxt;
RGBA blanc = { 255, 255, 255, 255, 0, 0 }; 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 DEBUG_LEVEL if (nomfonte==NULL) {
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 #if DEBUG_LEVEL > 1
fprintf(stderr, "trace chaine 1: using loaded font\n"); fprintf(stderr, "trace chaine 1: using loaded font\n");
#endif #endif
@ -202,7 +188,7 @@ else {
if (NULL==paper) paper = &blanc; if (NULL==paper) paper = &blanc;
if (NULL==ink) ink = &noir; if (NULL==ink) ink = &noir;
#if DEBUG_LEVEL #if DEBUG_LEVEL > 1
Image_print_rgba("encre", ink, 0); Image_print_rgba("encre", ink, 0);
Image_print_rgba("papier", paper, 0); Image_print_rgba("papier", paper, 0);
#endif #endif

View File

@ -87,9 +87,9 @@ for (idx=0; idx<len; idx++)
idx, txt[idx], xpos); idx, txt[idx], xpos);
#endif #endif
foo = Image_trace_big_char_0(im, xpos, y, txt[idx], xf, yf); foo = Image_trace_big_char_0(im, xpos, y, txt[idx], xf, yf);
if (foo) { #if DEBUG_LEVEL
fprintf(stderr, "Image_trace_big_char_0 -> %d\n", foo); fprintf(stderr, "Image_trace_big_char_0 -> %d\n", foo);
} #endif
xpos += (xf * 8); 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); fprintf(stderr, "%s : ligne 2 = %s\n", __func__, lig2);
#endif #endif
ligne_char(caractere, len+10+k); ligne_char(caractere, len+10);
ligne_space(caractere, len+10+k); ligne_space(caractere, len+10);
ligne_char(caractere, len+10+k); ligne_char(caractere, len+10);
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
@ -209,7 +209,7 @@ if (h->control != MAGIC_OF_DF3) {
return 666; return 666;
} }
printf("+--- DF3head @ %p -- %s -- %c\n", h, txt, flag ? 'X' : 'O'); printf("+--- DF3head @ %p -- %s --\n", h, txt);
printf("| magic: %08lx\n", h->control); printf("| magic: %08lx\n", h->control);
printf("| name: %s\n", h->name); printf("| name: %s\n", h->name);
printf("| dims: %d %d %d\n", h->xdim, h->ydim, h->zdim); printf("| dims: %d %d %d\n", h->xdim, h->ydim, h->zdim);

View File

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

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 57" #define IMAGE_VERSION_STRING "0.4.51 pl 50"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
@ -294,11 +294,9 @@ void Image_print_version(int verbose);
Image_Desc *Image_alloc(int width, int height, int type); Image_Desc *Image_alloc(int width, int height, int type);
Image_Desc *Image_clone(Image_Desc *src, int copy); Image_Desc *Image_clone(Image_Desc *src, int copy);
int Image_clear( Image_Desc *image, int r, int v, int b ); 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_copy(Image_Desc *src, Image_Desc *dst);
int Image_set_comment(Image_Desc *image, char *text); int Image_set_comment(Image_Desc *image, char *text);
int Image_copy_comment(Image_Desc *s, Image_Desc *d); 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); int Image_plot_gray(Image_Desc *img, int x, int y, int v);
@ -319,6 +317,7 @@ 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_compare_desc(Image_Desc *a, Image_Desc *b);
int Image_DeAllocate( Image_Desc *im ); /* nice coredumper */
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* module pixels.c */ /* module pixels.c */
@ -1013,7 +1012,6 @@ int Image_2x2_shiftUL(Image_Desc *src, Image_Desc *dst);
module de trace de primitives. (drawing.c) 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_circle(Image_Desc *i, int xc, int yc, int ray, RGBA *q, int m);
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_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_paint_rect(Image_Desc *, Image_Rect *, int, int, int);
int Image_noise_rect(Image_Desc *, Image_Rect *, int, int, int); int Image_noise_rect(Image_Desc *, Image_Rect *, int, int, int);