2022-06-26 11:06:35 +02:00
|
|
|
/*
|
|
|
|
dither3.c
|
|
|
|
---------
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2022-06-27 00:48:18 +02:00
|
|
|
#include "../tthimage.h"
|
2022-06-26 11:06:35 +02:00
|
|
|
|
|
|
|
/*::------------------------------------------------------------------::*/
|
2023-09-30 03:01:07 +02:00
|
|
|
int Image_dither_atkinson(Image_Desc *s, Image_Desc *d, int uh)
|
2022-06-26 11:06:35 +02:00
|
|
|
{
|
|
|
|
int x, y, r, g, b;
|
|
|
|
int foo, sr, sg, sb;
|
|
|
|
int old, new;
|
|
|
|
|
|
|
|
if ( (foo=Image_compare_desc(s, d)) )
|
|
|
|
{
|
|
|
|
fprintf(stderr, "%s : images are differents %d\n", __func__, foo);
|
|
|
|
return foo;
|
|
|
|
}
|
|
|
|
|
|
|
|
Image_clear(d, 0, 0, 0);
|
|
|
|
r = g = b = sr = sg = sb = 0;
|
|
|
|
|
2023-09-30 03:01:07 +02:00
|
|
|
for (y=0; y<s->height; y++) {
|
|
|
|
for (x=0; x<s->width; x++) {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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 */
|
2022-06-26 11:06:35 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return FUNC_NOT_FINISH;
|
|
|
|
}
|
|
|
|
/*::------------------------------------------------------------------::*/
|
2023-09-30 03:01:07 +02:00
|
|
|
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");
|
2023-11-18 19:56:25 +01:00
|
|
|
for(foo=0; foo<256; foo++) {
|
2023-09-30 03:01:07 +02:00
|
|
|
((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;
|
|
|
|
}
|
|
|
|
/*::------------------------------------------------------------------::*/
|
|
|
|
|