From 56250127bc6673a29e8de49a47c7516775fc2ae9 Mon Sep 17 00:00:00 2001 From: tTh Date: Sat, 30 Sep 2023 03:01:07 +0200 Subject: [PATCH] merged two files --- Lib/Makefile | 3 +- Lib/dither3.c | 84 +++++++++++++++++++++++++++++++++++++++++++---- Lib/dither4.c | 91 --------------------------------------------------- tthimage.h | 6 ++-- 4 files changed, 81 insertions(+), 103 deletions(-) delete mode 100644 Lib/dither4.c diff --git a/Lib/Makefile b/Lib/Makefile index 894a1a2..0ed24dc 100644 --- a/Lib/Makefile +++ b/Lib/Makefile @@ -51,7 +51,6 @@ distances.o: distances.c $(DEPS) dither.o: dither.c $(DEPS) dither2.o: dither2.c $(DEPS) dither3.o: dither3.c $(DEPS) -dither4.o: dither4.c $(DEPS) doublesz.o: doublesz.c $(DEPS) drawalpha.o: drawalpha.c $(DEPS) drawing.o: drawing.c $(DEPS) @@ -150,7 +149,7 @@ OBJECTS = 7seg.o \ combine6.o combine_rnd.o \ contrast.o \ detect.o distances.o \ - dither.o dither2.o dither3.o dither4.o \ + dither.o dither2.o dither3.o \ doublesz.o drawalpha.o drawing.o drawpatt.o \ effects.o effects2.o effects3.o extractbits.o \ filtadapt.o filtres.o \ diff --git a/Lib/dither3.c b/Lib/dither3.c index 40fc257..4b43d1a 100644 --- a/Lib/dither3.c +++ b/Lib/dither3.c @@ -8,8 +8,7 @@ #include "../tthimage.h" /*::------------------------------------------------------------------::*/ -int -Image_dither_atkinson(Image_Desc *s, Image_Desc *d, int uh) +int Image_dither_atkinson(Image_Desc *s, Image_Desc *d, int uh) { int x, y, r, g, b; int foo, sr, sg, sb; @@ -24,10 +23,8 @@ if ( (foo=Image_compare_desc(s, d)) ) Image_clear(d, 0, 0, 0); r = g = b = sr = sg = sb = 0; -for (y=0; yheight; y++) - { - for (x=0; xwidth; x++) - { +for (y=0; yheight; y++) { + for (x=0; xwidth; x++) { } } @@ -35,3 +32,78 @@ for (y=0; yheight; y++) return FUNC_NOT_FINISH; } /*::------------------------------------------------------------------::*/ +/*::------------------------------------------------------------------::*/ +int Image_dither_4x4_0(Image_Desc *s, Image_Desc *d, int uh) +{ +int x, y, r, g, b; +int foo, sr, sg, sb; + +fprintf(stderr, "* Image_dither_4x4_0 (%s) is experimental\n", __FILE__); +fprintf(stderr, "* Image_dither_4x4_0 le parametre est %d\n", uh); + +if ( (foo=Image_compare_desc(s, d)) ) { + fprintf(stderr, "dither 4x4 0: images are differents %d\n", foo); + return foo; + } + +Image_clear(d, 0, 0, 0); + +for (y=0; yheight; y++) { + for (x=0; xwidth; x++) { + + /* XXX */ + + } + } + +return FUNC_NOT_FINISH; +} +/*::------------------------------------------------------------------::*/ +int Image_dither_bayer8x8rnd(Image_Desc *s, Image_Desc *d, int shuff, int mono) +{ +uint16_t matrice[16][16]; +int foo, itmp, m, n; +int x, y, r, g, b, pix; + +fprintf(stderr, "%s ( %p %p %d %d )\n", __func__, s, d, shuff, mono); + +/* remplissage de la matrice */ +fprintf(stderr, " init matrice\n"); +for(foo=0; foo<256; foo++) + { + ((uint16_t *)matrice)[foo] = foo; + } +/* brasssage de la matrice */ +fprintf(stderr, " shuffle matrice %d\n", shuff); +for (foo=0; fooheight; y++) { + for (x=0; xwidth; x++) { + r = s->Rpix[y][x]; + g = s->Gpix[y][x]; + b = s->Bpix[y][x]; + if (mono) { + pix = (r + g +b) / 3; + d->Rpix[y][x] = d->Gpix[y][x] = d->Bpix[y][x] = \ + (pix > matrice[x%16][y%16]) * 255; + } + else { + d->Rpix[y][x] = (r > matrice[x%16][y%16]) * 255; + d->Gpix[y][x] = (g > matrice[x%16][y%16]) * 255; + d->Bpix[y][x] = (b > matrice[x%16][y%16]) * 255; + } + } + } + +fprintf(stderr, " done\n"); + +return FULL_NUCKED; +} +/*::------------------------------------------------------------------::*/ + diff --git a/Lib/dither4.c b/Lib/dither4.c deleted file mode 100644 index ebfa8de..0000000 --- a/Lib/dither4.c +++ /dev/null @@ -1,91 +0,0 @@ -/* - dither4.c - --------- -*/ - -#include -#include -#include "../tthimage.h" - -/*::------------------------------------------------------------------::*/ -int -Image_dither_4x4_0(Image_Desc *s, Image_Desc *d, int uh) -{ -int x, y, r, g, b; -int foo, sr, sg, sb; - -fprintf(stderr, "* Image_dither_4x4_0 (%s) is experimental\n", __FILE__); -fprintf(stderr, "* Image_dither_4x4_0 le parametre est %d\n", uh); - -if ( (foo=Image_compare_desc(s, d)) ) - { - fprintf(stderr, "dither 4x4 0: images are differents %d\n", foo); - return foo; - } - -Image_clear(d, 0, 0, 0); - -for (y=0; yheight; y++) - { - for (x=0; xwidth; x++) - { - - } - } - -return FUNC_NOT_FINISH; -} -/*::------------------------------------------------------------------::*/ -int -Image_dither_bayer8x8rnd(Image_Desc *s, Image_Desc *d, int shuff, int mono) -{ -uint16_t matrice[16][16]; -int foo, itmp, m, n; -int x, y, r, g, b, pix; - -fprintf(stderr, "%s ( %p %p %d %d )\n", __func__, s, d, shuff, mono); - -/* remplissage de la matrice */ -fprintf(stderr, " init matrice\n"); -for(foo=0; foo<256; foo++) - { - ((uint16_t *)matrice)[foo] = foo; - } -/* brasssage de la matrice */ -fprintf(stderr, " shuffle matrice %d\n", shuff); -for (foo=0; fooheight; y++) - { - for (x=0; xwidth; x++) - { - r = s->Rpix[y][x]; - g = s->Gpix[y][x]; - b = s->Bpix[y][x]; - if (mono) - { - pix = (r + g +b) / 3; - d->Rpix[y][x] = d->Gpix[y][x] = d->Bpix[y][x] = \ - (pix > matrice[x%16][y%16]) * 255; - } - else - { - d->Rpix[y][x] = (r > matrice[x%16][y%16]) * 255; - d->Gpix[y][x] = (g > matrice[x%16][y%16]) * 255; - d->Bpix[y][x] = (b > matrice[x%16][y%16]) * 255; - } - } - } - -fprintf(stderr, " done\n"); - -return FULL_NUCKED; -} -/*::------------------------------------------------------------------::*/ diff --git a/tthimage.h b/tthimage.h index 546176c..a7f2a6f 100644 --- a/tthimage.h +++ b/tthimage.h @@ -4,7 +4,7 @@ http://la.buvette.org/devel/libimage/ */ #ifndef IMAGE_VERSION_STRING - #define IMAGE_VERSION_STRING "0.4.51 pl 57" + #define IMAGE_VERSION_STRING "0.4.51 pl 59" /*::------------------------------------------------------------------::*/ /* @@ -596,7 +596,7 @@ int Image_asciiart_2(Image_Desc *src, char *pattern, int param); /*::------------------------------------------------------------------::*/ /* module calculs.c */ -int Image_clamp_pixel(int value); +int Image_clamp_pixel(int value); /* XXX must be a macro ? */ /* param 'res' is a 8 elements array */ int Image_minmax_RGB(Image_Desc *img, int *res); @@ -919,8 +919,6 @@ int Image_dither_3x3_3(Image_Desc *s, Image_Desc *d, int uh); /* module dither3.c */ int Image_dither_atkinson(Image_Desc *s, Image_Desc *d, int uh); - -/* module dither4.c */ int Image_dither_4x4_0(Image_Desc *s, Image_Desc *d, int uh); int Image_dither_bayer8x8rnd(Image_Desc *s, Image_Desc *d, int uh, int m);