merged two files

This commit is contained in:
tTh 2023-09-30 03:01:07 +02:00
parent 2594cabf94
commit 56250127bc
4 changed files with 81 additions and 103 deletions

View File

@ -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 \

View File

@ -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; y<s->height; y++)
{
for (x=0; x<s->width; x++)
{
for (y=0; y<s->height; y++) {
for (x=0; x<s->width; x++) {
}
}
@ -35,3 +32,78 @@ for (y=0; y<s->height; 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; y<s->height; y++) {
for (x=0; x<s->width; 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; foo<shuff; foo++) { /* magic number ? */
m = rand() & 0xff;
n = rand() & 0xff;
itmp = ((uint16_t *)matrice)[n];
((uint16_t *)matrice)[n] = ((uint16_t *)matrice)[m];
((uint16_t *)matrice)[m] = itmp;
}
for (y=0; y<s->height; y++) {
for (x=0; x<s->width; 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;
}
/*::------------------------------------------------------------------::*/

View File

@ -1,91 +0,0 @@
/*
dither4.c
---------
*/
#include <stdio.h>
#include <stdlib.h>
#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; y<s->height; y++)
{
for (x=0; x<s->width; 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; foo<shuff; foo++) /* magic number ? */
{
m = rand() & 0xff;
n = rand() & 0xff;
itmp = ((uint16_t *)matrice)[n];
((uint16_t *)matrice)[n] = ((uint16_t *)matrice)[m];
((uint16_t *)matrice)[m] = itmp;
}
for (y=0; y<s->height; y++)
{
for (x=0; x<s->width; 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;
}
/*::------------------------------------------------------------------::*/

View File

@ -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);