cosmetic
This commit is contained in:
parent
54e6a7e58a
commit
8fae30abc7
81
Lib/bitblt.c
81
Lib/bitblt.c
@ -20,30 +20,34 @@
|
|||||||
* et les parametres x et y disent ou recopier les pixels dans l'image
|
* et les parametres x et y disent ou recopier les pixels dans l'image
|
||||||
* de destination.
|
* de destination.
|
||||||
*/
|
*/
|
||||||
int
|
int Image_get_rect(Image_Desc *s, Image_Rect *z, Image_Desc *d, int x, int y)
|
||||||
Image_get_rect(Image_Desc *s, Image_Rect *z, Image_Desc *d, int x, int y)
|
|
||||||
{
|
{
|
||||||
int xfoo, yfoo; /* oh! des 'foo' 2D :-) */
|
int xfoo, yfoo; /* oh! des 'foo' 2D :-) */
|
||||||
int xs, ys;
|
int xs, ys;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %p %d %d )\n", __func__, s, z, d, x, y);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
* NEED MORE EXPLANATION XXX !
|
||||||
|
*/
|
||||||
#if DEBUG_LEVEL > 1
|
#if DEBUG_LEVEL > 1
|
||||||
fprintf(stderr, "GET RECT src %p %4d, %4d, %4d, %4d\n",
|
fprintf(stderr, "GET RECT src %p %4d, %4d, %4d, %4d\n",
|
||||||
s, z->x, z->y, z->w, z->h);
|
s, z->x, z->y, z->w, z->h);
|
||||||
fprintf(stderr, " dst %p %4d, %4d\n", d, x, y);
|
fprintf(stderr, " dst %p %4d, %4d\n", d, x, y);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( (z->w > d->width) || (z->h > d->height) )
|
if ( (z->w > d->width) || (z->h > d->height) ) {
|
||||||
{
|
fprintf(stderr, "%s: oups, bad rect\n", __func__);
|
||||||
return 666;
|
return 666;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (yfoo=0; yfoo<z->h; yfoo++)
|
for (yfoo=0; yfoo<z->h; yfoo++) {
|
||||||
{
|
|
||||||
ys = yfoo + z->y;
|
ys = yfoo + z->y;
|
||||||
if (ys<0 || ys>s->height-1)
|
if (ys<0 || ys>s->height-1)
|
||||||
continue;
|
continue;
|
||||||
for (xfoo=0; xfoo<z->w; xfoo++)
|
for (xfoo=0; xfoo<z->w; xfoo++) {
|
||||||
{
|
|
||||||
xs = xfoo + z->x;
|
xs = xfoo + z->x;
|
||||||
if (xs<0 || xs>s->width-1)
|
if (xs<0 || xs>s->width-1)
|
||||||
continue;
|
continue;
|
||||||
@ -55,23 +59,27 @@ return 0;
|
|||||||
}
|
}
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
/*
|
/*
|
||||||
|
* 2023-09-30: je comprend rien a ce truc !
|
||||||
|
*
|
||||||
* recopie d'un rectangle d'une image source par dessus
|
* recopie d'un rectangle d'une image source par dessus
|
||||||
* une image destination.
|
* une image destination.
|
||||||
*/
|
*/
|
||||||
int
|
int Image_put_rect(Image_Desc *s, Image_Rect *z, Image_Desc *d, int x, int y)
|
||||||
Image_put_rect(Image_Desc *s, Image_Rect *z, Image_Desc *d, int x, int y)
|
|
||||||
{
|
{
|
||||||
int xfoo, yfoo;
|
int xfoo, yfoo;
|
||||||
int xs, ys, xd, yd;
|
int xs, ys, xd, yd;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %p %d %d )\n", __func__, s, z, d, x, y);
|
||||||
|
#endif
|
||||||
|
|
||||||
#if DEBUG_LEVEL > 1
|
#if DEBUG_LEVEL > 1
|
||||||
fprintf(stderr, "PUT RECT src %p %4d, %4d, %4d, %4d\n",
|
fprintf(stderr, "PUT RECT src %p %4d, %4d, %4d, %4d\n",
|
||||||
s, z->x, z->y, z->w, z->h);
|
s, z->x, z->y, z->w, z->h);
|
||||||
fprintf(stderr, " dst %p %4d, %4d\n", d, x, y);
|
fprintf(stderr, " dst %p %4d, %4d\n", d, x, y);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (yfoo=0; yfoo<z->h; yfoo++)
|
for (yfoo=0; yfoo<z->h; yfoo++) {
|
||||||
{
|
|
||||||
ys = yfoo + z->y;
|
ys = yfoo + z->y;
|
||||||
if (ys<0 || ys>s->height-1)
|
if (ys<0 || ys>s->height-1)
|
||||||
continue;
|
continue;
|
||||||
@ -80,8 +88,7 @@ for (yfoo=0; yfoo<z->h; yfoo++)
|
|||||||
if (yd<0 || yd>d->height-1)
|
if (yd<0 || yd>d->height-1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (xfoo=0; xfoo<z->w; xfoo++)
|
for (xfoo=0; xfoo<z->w; xfoo++) {
|
||||||
{
|
|
||||||
xs = xfoo + z->x;
|
xs = xfoo + z->x;
|
||||||
if (xs<0 || xs>s->width-1)
|
if (xs<0 || xs>s->width-1)
|
||||||
continue;
|
continue;
|
||||||
@ -94,33 +101,27 @@ for (yfoo=0; yfoo<z->h; yfoo++)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return FUNC_IS_ALPHA;
|
return FUNC_IS_ALPHA; /* AH BRAVO */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
/*
|
/*
|
||||||
* coredumper dlmkt !
|
* coredumper dlmkt !
|
||||||
*/
|
*/
|
||||||
int
|
int Image_copy_rect(Image_Desc *s, Image_Rect *z, Image_Desc *d, int x, int y)
|
||||||
Image_copy_rect(Image_Desc *s, Image_Rect *z, Image_Desc *d, int x, int y)
|
|
||||||
{
|
{
|
||||||
int xs, ys, xd, yd, xx, yy;
|
int xs, ys, xd, yd, xx, yy;
|
||||||
int foo;
|
int foo;
|
||||||
|
|
||||||
#if DEBUG_LEVEL > 1
|
fprintf(stderr, ">>> %s ( %p %p %p %d %d )\n", __func__, s, z, d, x, y );
|
||||||
fprintf(stderr, "%s s=%p z=%p d=%p x,y=%d,%d\n", __func__,
|
|
||||||
s, z, d, x, y);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (d->magic != MAGIC_OF_IMAGE)
|
if (d->magic != MAGIC_OF_IMAGE) {
|
||||||
{
|
|
||||||
fprintf(stderr, "%s: need Dead Beef\n", __func__);
|
fprintf(stderr, "%s: need Dead Beef\n", __func__);
|
||||||
return NOT_AN_IMAGE_DESC;
|
return NOT_AN_IMAGE_DESC;
|
||||||
}
|
}
|
||||||
|
|
||||||
foo = 0;
|
foo = 0;
|
||||||
for (yy=0; yy<z->h; yy++)
|
for (yy=0; yy<z->h; yy++) {
|
||||||
{
|
|
||||||
ys = yy + z->y;
|
ys = yy + z->y;
|
||||||
if (ys<0 || ys>=s->height)
|
if (ys<0 || ys>=s->height)
|
||||||
continue;
|
continue;
|
||||||
@ -129,8 +130,7 @@ for (yy=0; yy<z->h; yy++)
|
|||||||
if (yd<0 || yd>=d->height)
|
if (yd<0 || yd>=d->height)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
for (xx=0; xx<z->w; xx++)
|
for (xx=0; xx<z->w; xx++) {
|
||||||
{
|
|
||||||
xs = xx + z->x;
|
xs = xx + z->x;
|
||||||
if (xs<0 || xs>=s->width)
|
if (xs<0 || xs>=s->width)
|
||||||
continue;
|
continue;
|
||||||
@ -154,22 +154,21 @@ return FUNC_IS_BETA;
|
|||||||
* 23 dec 01 found a coredump if src image is too small
|
* 23 dec 01 found a coredump if src image is too small
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Image_Desc *
|
Image_Desc *Image_create_subimg(Image_Desc *src, Image_Rect *r, int gray)
|
||||||
Image_create_subimg(Image_Desc *src, Image_Rect *r, int gray)
|
|
||||||
{
|
{
|
||||||
Image_Desc *clone;
|
Image_Desc *clone;
|
||||||
int x,y,xs, ys;
|
int x,y,xs, ys;
|
||||||
|
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, r, gray);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* sanities controls...
|
* sanities controls...
|
||||||
*/
|
*/
|
||||||
if (src->type != IMAGE_RGB)
|
if (src->type != IMAGE_RGB) {
|
||||||
{
|
|
||||||
fprintf(stderr, "'%s' work only on RGB images\n", __func__);
|
fprintf(stderr, "'%s' work only on RGB images\n", __func__);
|
||||||
exit(5);
|
exit(5);
|
||||||
}
|
}
|
||||||
if ( (r->x<0) || (r->y<0) )
|
if ( (r->x<0) || (r->y<0) ) {
|
||||||
{
|
|
||||||
fprintf(stderr, "create_subimg, rect(%d,%d,%d,%d) iznotgoud\n",
|
fprintf(stderr, "create_subimg, rect(%d,%d,%d,%d) iznotgoud\n",
|
||||||
r->x, r->y, r->w, r->h);
|
r->x, r->y, r->w, r->h);
|
||||||
exit(5);
|
exit(5);
|
||||||
@ -180,34 +179,28 @@ if ( (r->x<0) || (r->y<0) )
|
|||||||
* now, we allocate the new image...
|
* now, we allocate the new image...
|
||||||
*/
|
*/
|
||||||
clone = Image_alloc(r->w, r->h, src->type);
|
clone = Image_alloc(r->w, r->h, src->type);
|
||||||
if (clone == NULL)
|
if (clone == NULL) {
|
||||||
{
|
|
||||||
fprintf(stderr, "CreateSubImage: can't alloc memory...\n");
|
fprintf(stderr, "CreateSubImage: can't alloc memory...\n");
|
||||||
exit(5);
|
exit(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (x=0; x<r->w; x++)
|
for (x=0; x<r->w; x++) {
|
||||||
{
|
|
||||||
xs = x + r->x;
|
xs = x + r->x;
|
||||||
for (y=0; y<r->h; y++)
|
for (y=0; y<r->h; y++) {
|
||||||
{
|
|
||||||
ys = y + r->y;
|
ys = y + r->y;
|
||||||
/*printf("dst %4d %4d ", x, y); */
|
/*printf("dst %4d %4d ", x, y); */
|
||||||
/*printf("src %4d %4d ", xs, ys); */
|
/*printf("src %4d %4d ", xs, ys); */
|
||||||
|
|
||||||
if (ys<0 || ys>src->width)
|
if (ys<0 || ys>src->width) {
|
||||||
{
|
|
||||||
Image_plotRGB(clone, x, y, gray, gray, gray);
|
Image_plotRGB(clone, x, y, gray, gray, gray);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
/* XXX calling this func is a nasty cpu sucker,
|
/* XXX calling this func is a nasty cpu sucker,
|
||||||
* so we have to go to a nasty optimize trick */
|
* so we have to go to a nasty optimize trick */
|
||||||
/* XXX Image_pixel_copy(src, xs, ys, clone, x, y); */
|
/* XXX Image_pixel_copy(src, xs, ys, clone, x, y); */
|
||||||
(clone->Rpix[y])[x] = (src->Rpix[ys])[xs];
|
(clone->Rpix[y])[x] = (src->Rpix[ys])[xs];
|
||||||
(clone->Gpix[y])[x] = (src->Gpix[ys])[xs];
|
(clone->Gpix[y])[x] = (src->Gpix[ys])[xs];
|
||||||
(clone->Bpix[y])[x] = (src->Bpix[ys])[xs];
|
(clone->Bpix[y])[x] = (src->Bpix[ys])[xs];
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,103 +17,87 @@
|
|||||||
#include "../tthimage.h"
|
#include "../tthimage.h"
|
||||||
|
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
int
|
int Image_calclut_lin(int *lut, int v0, int v255)
|
||||||
Image_calclut_lin(int *lut, int v0, int v255)
|
|
||||||
{
|
{
|
||||||
int foo, quux, delta;
|
int foo, quux, delta;
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, "calclut lin: v0 = %d v255 = %d\n", v0, v255);
|
fprintf(stderr, ">>> %s ( %p %d %d )\n", __func__, lut, v0, v255);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
delta = v255 - v0;
|
delta = v255 - v0;
|
||||||
if (delta == 0)
|
if (delta == 0) {
|
||||||
{
|
|
||||||
return DIVISOR_IS_0;
|
return DIVISOR_IS_0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, "calclut lin: delta = %d\n", delta);
|
fprintf(stderr, " calclut lin: delta = %d\n", delta);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (foo=0; foo<256; foo++)
|
for (foo=0; foo<256; foo++) {
|
||||||
{
|
|
||||||
quux = (foo * delta / 255) + v0;
|
quux = (foo * delta / 255) + v0;
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL > 1
|
||||||
printf("lut(%d) = %d\n", foo, quux);
|
printf("lut(%d) = %d\n", foo, quux);
|
||||||
#endif
|
#endif
|
||||||
lut[foo] = quux;
|
lut[foo] = quux;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FUNC_IS_ALPHA;
|
return FUNC_IS_BETA;
|
||||||
}
|
}
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
int
|
int Image_calclut_foo(int *lut, int v0, int v255)
|
||||||
Image_calclut_foo(int *lut, int v0, int v255)
|
|
||||||
{
|
{
|
||||||
fprintf(stderr, "%s ( %p %d %d )\n", __func__, lut, v0, v255);
|
fprintf(stderr, ">>> %s ( %p %d %d )\n", __func__, lut, v0, v255);
|
||||||
|
|
||||||
return FUNC_IS_ALPHA;
|
return FUNC_IS_ALPHA;
|
||||||
}
|
}
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
int
|
int Image_print_lut(int *lut, char *fname, int flag)
|
||||||
Image_print_lut(int *lut, char *fname, int flag)
|
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int foo;
|
int foo;
|
||||||
|
|
||||||
if (strcmp(fname, "-"))
|
if (strcmp(fname, "-")) fp = fopen(fname, "w");
|
||||||
fp = fopen(fname, "w");
|
else fp = stdout;
|
||||||
else
|
|
||||||
fp = stdout;
|
|
||||||
|
|
||||||
for (foo=0; foo<256; foo++)
|
for (foo=0; foo<256; foo++) {
|
||||||
{
|
if (flag) printf("%4d ", foo);
|
||||||
if (flag)
|
printf(" %4d\n", lut[foo]);
|
||||||
printf("%d ", foo);
|
|
||||||
printf("%d\n", lut[foo]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fp!=stdout)
|
if (fp!=stdout) fclose(fp);
|
||||||
fclose(fp);
|
|
||||||
|
|
||||||
return FUNC_IS_ALPHA;
|
return FUNC_IS_BETA;
|
||||||
}
|
}
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
int
|
int Image_load_lut(int *lut, char *fname, int flag)
|
||||||
Image_load_lut(int *lut, char *fname, int flag)
|
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
int value, foo, idx;
|
int value, foo, idx;
|
||||||
|
|
||||||
|
#if DEBUG_LEVEL
|
||||||
|
fprintf(stderr, ">>> %s ( %p '%s' )\n", __func__, fname, lut);
|
||||||
|
#endif
|
||||||
|
|
||||||
if (flag) {
|
if (flag) {
|
||||||
fprintf(stderr, "in %s, flag must be O, was %d\n", __func__, flag);
|
fprintf(stderr, "in %s, flag must be O, was %d\n", __func__, flag);
|
||||||
return WRONG_FLAG;
|
return WRONG_FLAG;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
if (NULL==(fp=fopen(fname, "r"))) {
|
||||||
fprintf(stderr, "load_lut %s in %p\n", fname, lut);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (NULL==(fp=fopen(fname, "r")))
|
|
||||||
{
|
|
||||||
fprintf(stderr, "%s can't fopen %s\n", __func__, fname);
|
fprintf(stderr, "%s can't fopen %s\n", __func__, fname);
|
||||||
return 666;
|
return 666;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* WARNING : very crude code here (4 nov 1999) */
|
/* WARNING : very crude code here (4 nov 1999) */
|
||||||
for (idx=0; idx<256; idx++)
|
for (idx=0; idx<256; idx++) {
|
||||||
{
|
|
||||||
foo = fscanf(fp, "%d", &value);
|
foo = fscanf(fp, "%d", &value);
|
||||||
#if DEBUG_LEVEL
|
|
||||||
fprintf(stderr, "load lut %3d %3d %d\n", idx, foo, value);
|
|
||||||
#endif
|
|
||||||
if (1==foo) lut[idx] = value;
|
if (1==foo) lut[idx] = value;
|
||||||
else lut[idx] = -1;
|
else lut[idx] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
||||||
return FUNC_IS_ALPHA;
|
return FUNC_IS_BETA;
|
||||||
}
|
}
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include "../tthimage.h"
|
#include "../tthimage.h"
|
||||||
|
|
||||||
@ -71,6 +72,10 @@ int Image_combine_columns(Image_Desc *s1, Image_Desc *s2, Image_Desc *d,
|
|||||||
{
|
{
|
||||||
int foo, x, y, mx, r, g, b;
|
int foo, x, y, mx, r, g, b;
|
||||||
|
|
||||||
|
if (zak) {
|
||||||
|
fprintf(stderr, "in %s, zak is not 0\n", __func__);
|
||||||
|
}
|
||||||
|
|
||||||
if (sx == 0) {
|
if (sx == 0) {
|
||||||
fprintf(stderr, "Combine Columns: sx is zer0\n");
|
fprintf(stderr, "Combine Columns: sx is zer0\n");
|
||||||
return DIVISOR_IS_ZERO;
|
return DIVISOR_IS_ZERO;
|
||||||
@ -246,8 +251,12 @@ int foo;
|
|||||||
int x, y, r, g, b;
|
int x, y, r, g, b;
|
||||||
int vertical, offset;
|
int vertical, offset;
|
||||||
|
|
||||||
|
if ( p1 || p2 ) {
|
||||||
|
fprintf(stderr, "in %s bad p1 %d or bad p2 %d\n", __func__, p1, p2);
|
||||||
|
}
|
||||||
|
|
||||||
if ( (foo=Image_compare_desc(s1, s2)) ) {
|
if ( (foo=Image_compare_desc(s1, s2)) ) {
|
||||||
fprintf(stderr, "Combine Diagonale: differents sources (%d)\n", foo);
|
fprintf(stderr, "%s: differents sources (%d)\n", __func__, foo);
|
||||||
return foo;
|
return foo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ int Image_XOR(Image_Desc *s1, Image_Desc *s2, Image_Desc *d, int k)
|
|||||||
int foo, x, y;
|
int foo, x, y;
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, "---> %s ( %p %p %p %d)\n", __func__, s1, s2, d, k);
|
fprintf(stderr, ">>> %s ( %p %p %p %d)\n", __func__, s1, s2, d, k);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ( (foo=Image_compare_desc(s1, s2)) )
|
if ( (foo=Image_compare_desc(s1, s2)) )
|
||||||
|
98
Lib/dither.c
98
Lib/dither.c
@ -12,11 +12,12 @@
|
|||||||
en entree, on doit avoir une image RGB, sinon, "segfault"
|
en entree, on doit avoir une image RGB, sinon, "segfault"
|
||||||
le parametre 'uh' represente l'intensite de la couleur 'on'
|
le parametre 'uh' represente l'intensite de la couleur 'on'
|
||||||
*/
|
*/
|
||||||
int
|
int Image_dither_Bayer_0(Image_Desc *s, Image_Desc *d, int uh)
|
||||||
Image_dither_Bayer_0(Image_Desc *s, Image_Desc *d, int uh)
|
|
||||||
{
|
{
|
||||||
int dx, dy, x, y, r, g, b;
|
int dx, dy, x, y, r, g, b;
|
||||||
|
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, s, d, uh);
|
||||||
|
|
||||||
/* directement copie de la page 389 de "Bitmapped graphics" de
|
/* directement copie de la page 389 de "Bitmapped graphics" de
|
||||||
Steve Rimmer. */
|
Steve Rimmer. */
|
||||||
|
|
||||||
@ -57,18 +58,17 @@ return OLL_KORRECT;
|
|||||||
* 19 Juin 2000: dithering on a 2x2 matrice.
|
* 19 Juin 2000: dithering on a 2x2 matrice.
|
||||||
* 15 Nov 2001: 'uh' parameter is _now_ working ;-}
|
* 15 Nov 2001: 'uh' parameter is _now_ working ;-}
|
||||||
*/
|
*/
|
||||||
int
|
int Image_dither_crude(Image_Desc *s, Image_Desc *d, int uh)
|
||||||
Image_dither_crude(Image_Desc *s, Image_Desc *d, int uh)
|
|
||||||
{
|
{
|
||||||
int x, y, r, g, b;
|
int x, y, r, g, b;
|
||||||
int som;
|
int som;
|
||||||
|
|
||||||
Image_clear(d, 0, 0, 0);
|
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, s, d, uh);
|
||||||
|
|
||||||
for (x=0; x<(s->width-1); x+=2)
|
if (s != d) Image_clear(d, 0, 0, 0);
|
||||||
{
|
|
||||||
for (y=0; y<(s->height-1); y+=2)
|
for (x=0; x<(s->width-1); x+=2) {
|
||||||
{
|
for (y=0; y<(s->height-1); y+=2) {
|
||||||
r = g = b = 0;
|
r = g = b = 0;
|
||||||
r += Image_R_pixel(s, x, y);
|
r += Image_R_pixel(s, x, y);
|
||||||
r += Image_R_pixel(s, x+1, y);
|
r += Image_R_pixel(s, x+1, y);
|
||||||
@ -96,14 +96,8 @@ for (x=0; x<(s->width-1); x+=2)
|
|||||||
|
|
||||||
som = r + g + b;
|
som = r + g + b;
|
||||||
|
|
||||||
if (som < 2048)
|
if (som < 2048) Image_plotRGB(d, x+1, y+1, 0, 0, 0);
|
||||||
{
|
else Image_plotRGB(d, x+1, y+1, uh, uh, uh);
|
||||||
Image_plotRGB(d, x+1, y+1, 0, 0, 0);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Image_plotRGB(d, x+1, y+1, uh, uh, uh);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,25 +107,24 @@ return OLL_KORRECT;
|
|||||||
/*
|
/*
|
||||||
* ça ne marche pas très fort, ce truc...
|
* ça ne marche pas très fort, ce truc...
|
||||||
*/
|
*/
|
||||||
int
|
int Image_dither_2x2(Image_Desc *s, Image_Desc *d, int uh)
|
||||||
Image_dither_2x2(Image_Desc *s, Image_Desc *d, int uh)
|
|
||||||
{
|
{
|
||||||
int x, y, xm, ym;
|
int x, y, xm, ym;
|
||||||
int r, g, b, v;
|
int r, g, b, v;
|
||||||
|
|
||||||
|
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, s, d, uh);
|
||||||
|
|
||||||
x = s->width; xm = (x&1) ? (x-1) : x;
|
x = s->width; xm = (x&1) ? (x-1) : x;
|
||||||
y = s->height; ym = (y&1) ? (y-1) : y;
|
y = s->height; ym = (y&1) ? (y-1) : y;
|
||||||
|
|
||||||
Image_clear(d, 0, 0, 0);
|
if (s != d) Image_clear(d, 0, 0, 0);
|
||||||
|
|
||||||
#if DEBUG_LEVEL
|
#if DEBUG_LEVEL
|
||||||
fprintf(stderr, "dither 2x2: %d %d %d %d\n", x, xm, y, ym);
|
fprintf(stderr, "dither 2x2: %d %d %d %d\n", x, xm, y, ym);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (x=0; x<xm; x+=2)
|
for (x=0; x<xm; x+=2) {
|
||||||
{
|
for (y=0; y<ym; y+=2) {
|
||||||
for (y=0; y<ym; y+=2)
|
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
* bon sang, mais que faire ici ?
|
* bon sang, mais que faire ici ?
|
||||||
*/
|
*/
|
||||||
@ -155,24 +148,22 @@ for (x=0; x<xm; x+=2)
|
|||||||
return FUNC_IS_ALPHA;
|
return FUNC_IS_ALPHA;
|
||||||
}
|
}
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
int
|
int Image_dither_seuil_random(Image_Desc *s, Image_Desc *d, int uh)
|
||||||
Image_dither_seuil_random(Image_Desc *s, Image_Desc *d, int uh)
|
|
||||||
{
|
{
|
||||||
int x, y, r, g, b;
|
int x, y, r, g, b;
|
||||||
int foo;
|
int foo;
|
||||||
|
|
||||||
if ( (foo=Image_compare_desc(s, d)) )
|
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, s, d, uh);
|
||||||
{
|
|
||||||
fprintf(stderr, "dither seuil random: images are differents %d\n", foo);
|
if ( (foo=Image_compare_desc(s, d)) ) {
|
||||||
|
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
|
||||||
return foo;
|
return foo;
|
||||||
}
|
}
|
||||||
|
|
||||||
Image_clear(d, 0, 0, 0);
|
if (s != d) Image_clear(d, 0, 0, 0);
|
||||||
|
|
||||||
for (y=0; y<s->height; y++)
|
for (y=0; y<s->height; y++) {
|
||||||
{
|
for (x=0; x<s->width; x++) {
|
||||||
for (x=0; x<s->width; x++)
|
|
||||||
{
|
|
||||||
if (s->Rpix[y][x] < rand() % 256) r = 0;
|
if (s->Rpix[y][x] < rand() % 256) r = 0;
|
||||||
else r = uh;
|
else r = uh;
|
||||||
|
|
||||||
@ -195,35 +186,31 @@ return OLL_KORRECT;
|
|||||||
*
|
*
|
||||||
* subtle bug: uh _must_ be 255 ?
|
* subtle bug: uh _must_ be 255 ?
|
||||||
*/
|
*/
|
||||||
int
|
int Image_dither_simple_error(Image_Desc *s, Image_Desc *d, int uh)
|
||||||
Image_dither_simple_error(Image_Desc *s, Image_Desc *d, int uh)
|
|
||||||
{
|
{
|
||||||
int x, y, xa, xb, inc, errR, errG, errB;
|
int x, y, xa, xb, inc, errR, errG, errB;
|
||||||
int r, g, b, dr, dg, db;
|
int r, g, b, dr, dg, db;
|
||||||
int foo;
|
int foo;
|
||||||
|
|
||||||
if ( (foo=Image_compare_desc(s, d)) )
|
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, s, d, uh);
|
||||||
{
|
|
||||||
fprintf(stderr, "dither simple error: images are differents %d\n", foo);
|
if ( (foo=Image_compare_desc(s, d)) ) {
|
||||||
|
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
|
||||||
return foo;
|
return foo;
|
||||||
}
|
}
|
||||||
|
|
||||||
Image_clear(d, 0, 0, 0);
|
if (s != d) Image_clear(d, 0, 0, 0);
|
||||||
errR = errG = errB = 0;
|
errR = errG = errB = 0;
|
||||||
|
|
||||||
for (y=0; y<s->height; y++)
|
for (y=0; y<s->height; y++) {
|
||||||
{
|
if (y & 1) {
|
||||||
if (y & 1)
|
|
||||||
{
|
|
||||||
xa = 0; xb = s->width - 1; inc = 1;
|
xa = 0; xb = s->width - 1; inc = 1;
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
xa = s->width - 1; xb = 0; inc = -1;
|
xa = s->width - 1; xb = 0; inc = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (x=xa; x!=xb; x+=inc)
|
for (x=xa; x!=xb; x+=inc) {
|
||||||
{
|
|
||||||
r = (s->Rpix[y])[x];
|
r = (s->Rpix[y])[x];
|
||||||
if ( (r + errR) > 127 ) dr = uh;
|
if ( (r + errR) > 127 ) dr = uh;
|
||||||
else dr = 0;
|
else dr = 0;
|
||||||
@ -253,26 +240,21 @@ return OLL_KORRECT;
|
|||||||
* 29 Jan 2002: may be I can buid a func for automagically
|
* 29 Jan 2002: may be I can buid a func for automagically
|
||||||
* computing of right values ?
|
* computing of right values ?
|
||||||
*/
|
*/
|
||||||
int
|
int Image_dither_double_seuil(Image_Desc *s, Image_Desc *d, int sa, int sb, int uh)
|
||||||
Image_dither_double_seuil(Image_Desc *s, Image_Desc *d, int sa, int sb, int uh)
|
|
||||||
{
|
{
|
||||||
int x, y, r, g, b, foo;
|
int x, y, r, g, b, foo;
|
||||||
|
|
||||||
if ( (foo=Image_compare_desc(s, d)) )
|
if ( (foo=Image_compare_desc(s, d)) ) {
|
||||||
{
|
|
||||||
fprintf(stderr, "dither double seuil: images are differents %d\n", foo);
|
fprintf(stderr, "dither double seuil: images are differents %d\n", foo);
|
||||||
return foo;
|
return foo;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( sa >= sb )
|
if ( sa >= sb ) {
|
||||||
{
|
|
||||||
fprintf(stderr, "dither double seuil: lo %d > hi %d !\n", sa, sb);
|
fprintf(stderr, "dither double seuil: lo %d > hi %d !\n", sa, sb);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (y=0; y<s->height; y++)
|
for (y=0; y<s->height; y++) {
|
||||||
{
|
for (x=0; x<s->width; x++) {
|
||||||
for (x=0; x<s->width; x++)
|
|
||||||
{
|
|
||||||
r = (s->Rpix[y])[x];
|
r = (s->Rpix[y])[x];
|
||||||
if (r < sa) r = 0;
|
if (r < sa) r = 0;
|
||||||
else if (r > sb) r = uh;
|
else if (r > sb) r = uh;
|
||||||
|
@ -64,6 +64,7 @@ printf("RGBA : %5ld\n", sizeof(RGBA));
|
|||||||
printf("A_BitPlane : %5ld\n", sizeof(A_BitPlane));
|
printf("A_BitPlane : %5ld\n", sizeof(A_BitPlane));
|
||||||
printf("RGB_map : %5ld\n", sizeof(RGB_map));
|
printf("RGB_map : %5ld\n", sizeof(RGB_map));
|
||||||
printf("Image_Point : %5ld\n", sizeof(Image_Point));
|
printf("Image_Point : %5ld\n", sizeof(Image_Point));
|
||||||
|
printf("RGB LUTs : %5ld\n", sizeof(Image_LUTs));
|
||||||
|
|
||||||
}
|
}
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
|
14
Lib/tools.c
14
Lib/tools.c
@ -26,7 +26,9 @@ foo = (compteur++) / div;
|
|||||||
printf("%c\r", batons[foo&0x03]); fflush(stdout);
|
printf("%c\r", batons[foo&0x03]); fflush(stdout);
|
||||||
}
|
}
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
|
/*
|
||||||
|
* I think that the 'chrono' system is full broken
|
||||||
|
*/
|
||||||
#define NB_CHRONOS 42
|
#define NB_CHRONOS 42
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
@ -98,7 +100,7 @@ printf("/-------- Descriptor Dump (lib v=%s) -----------\n",
|
|||||||
|
|
||||||
printf("| why text: %s\n", text);
|
printf("| why text: %s\n", text);
|
||||||
printf("| main pointer: %p\n", im);
|
printf("| main pointer: %p\n", im);
|
||||||
if ( im==NULL ) {
|
if ( NULL == im ) {
|
||||||
printf("!\t\tthis is a null descriptor, good luck, Sir...\n");
|
printf("!\t\tthis is a null descriptor, good luck, Sir...\n");
|
||||||
return NULL_DESCRIPTOR;
|
return NULL_DESCRIPTOR;
|
||||||
}
|
}
|
||||||
@ -124,11 +126,11 @@ return 0;
|
|||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
int Image_dump_rect(Image_Rect *rect, char *texte, int flag)
|
int Image_dump_rect(Image_Rect *rect, char *texte, int flag)
|
||||||
{
|
{
|
||||||
printf("Rect: '%s'\n\t%5d %5d %5d %5d $%08lx\n", texte,
|
printf("Rect: '%s'\n\t%5d %5d %5d %5d $%04lx\n", texte,
|
||||||
rect->x, rect->y, rect->w, rect->h, rect->reserved);
|
rect->x, rect->y, rect->w, rect->h, rect->reserved);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
printf(" coin bas/droite %5d %5d\n", rect->x+rect->w, rect->y+rect->h);
|
printf(" lower right %5d %5d\n", rect->x+rect->w, rect->y+rect->h);
|
||||||
printf(" surface %8ld\n", (long)rect->w * (long)rect->h);
|
printf(" surface %8ld\n", (long)rect->w * (long)rect->h);
|
||||||
}
|
}
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
|
||||||
@ -185,7 +187,7 @@ if (*txt == '-') {
|
|||||||
fp = stdout;
|
fp = stdout;
|
||||||
txt++; /* skip the '-' */
|
txt++; /* skip the '-' */
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
fp = stderr;
|
fp = stderr;
|
||||||
}
|
}
|
||||||
fprintf(fp, hexa ? fmth : fmtd, txt, rgba->r, rgba->g, rgba->b, rgba->a);
|
fprintf(fp, hexa ? fmth : fmtd, txt, rgba->r, rgba->g, rgba->b, rgba->a);
|
||||||
|
Loading…
Reference in New Issue
Block a user