Compare commits

...

5 Commits

Author SHA1 Message Date
tTh 63b0bce081 cosmetic 2022-09-23 13:41:58 +02:00
tTh 2f1f51671c cosmetic 2022-09-23 13:28:02 +02:00
tTh 7679fabae9 oups! 2022-09-21 18:24:03 +02:00
tTh 5bee2ac73c add a second 8x8 font 2022-09-21 18:22:32 +02:00
tTh c73a361120 alway run a compil under DEBUG_LEVEL=1 2022-09-21 18:16:55 +02:00
7 changed files with 60 additions and 72 deletions

BIN
Datas/8x8std Normal file

Binary file not shown.

View File

@ -436,7 +436,7 @@ int x, y;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d %d %d %d %d )\n", __func__, fprintf(stderr, ">>> %s ( %p %d %d %d %d %d )\n", __func__,
im, r, g, b, nh, nv); im, r, g, b, nx, ny);
#endif #endif
for (y=0; y<im->height; y++) { for (y=0; y<im->height; y++) {

View File

@ -108,11 +108,10 @@ int Image_luminance(Image_Desc *src, Image_Desc *dst, int factor)
int foo; int foo;
int x, y; int x, y;
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, dst, factor); fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, dst, factor);
#endif
fprintf(stderr, "luminance factor: %d %f\n", factor, (float)factor / 256.0); fprintf(stderr, "luminance factor: %d %f\n", factor, (float)factor / 256.0);
#endif
if ( (foo=Image_compare_desc(src, dst)) ) { if ( (foo=Image_compare_desc(src, dst)) ) {
fprintf(stderr, "%s: images are differents %d\n", __func__, foo); fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
@ -154,11 +153,11 @@ int *cumlr, *cumlg, *cumlb;
long cr, cg, cb, s; long cr, cg, cb, s;
if (yoyo != 0) { if (yoyo != 0) {
fprintf(stderr, "%s: yoyo is %d\n", __func__, yoyo); fprintf(stderr, "%s: yoyo is %d ?\n", __func__, yoyo);
} }
if ( (foo=Image_compare_desc(src, dst)) ) { if ( (foo=Image_compare_desc(src, dst)) ) {
fprintf(stderr, "Image Egalise RGB: images are differents %d\n", foo); fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
return foo; return foo;
} }
@ -178,7 +177,7 @@ cr = cg = cb = 0L;
s = (src->width * src->height); s = (src->width * src->height);
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "Image Egalise 0: surface = %ld\n", s); fprintf(stderr, "%s: surface = %ld\n", __func__, s);
#endif #endif
for (foo=0; foo<256; foo++) { for (foo=0; foo<256; foo++) {

View File

@ -20,8 +20,7 @@
/* /*
* do not use in production !-) * do not use in production !-)
*/ */
int int Image_scale_simple(Image_Desc *src, Image_Desc *dst, int k)
Image_scale_simple(Image_Desc *src, Image_Desc *dst, int k)
{ {
float coefX, coefY, fx, fy; float coefX, coefY, fx, fy;
int xd, yd, xs, ys; int xd, yd, xs, ys;
@ -49,10 +48,8 @@ fprintf(stderr, "coefficients: X %f y %f\n", coefX, coefY);
* bon, pour les interpolations, il faut que je trouve * bon, pour les interpolations, il faut que je trouve
* un peu de doc... mais ou ? * un peu de doc... mais ou ?
*/ */
for (yd=0; yd<dst->height; yd++) for (yd=0; yd<dst->height; yd++) {
{ for (xd=0; xd<dst->width; xd++) {
for (xd=0; xd<dst->width; xd++)
{
fx = (float)xd / coefX; fx = (float)xd / coefX;
fy = (float)yd / coefY; fy = (float)yd / coefY;
xs = (int)fx; xs = (int)fx;
@ -70,9 +67,12 @@ return FUNC_IS_ALPHA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* new 2 nov 2009 - ave StEx */ /* new 2 nov 2009 - ave StEx */
/* I've lost all my mathematical concepts so I'm going to make /*
some approximations\dots */ I've lost all my mathematical concepts so I'm going to make
some approximations\dots
this function is PRIVATE, see 'Image_getpix_bilin' for public interface
*/
static int getpix_bilin(Image_Desc *src, double fx, double fy, static int getpix_bilin(Image_Desc *src, double fx, double fy,
int *pr, int *pg, int *pb) int *pr, int *pg, int *pb)
{ {
@ -95,12 +95,8 @@ drw = fx - x11; drh = fy - y11;
xx = (int)x11; yy = (int)y11; xx = (int)x11; yy = (int)y11;
#if DEBUG_LEVEL > 2 #if DEBUG_LEVEL > 2
if ( ! (rand() % 40000) ) printf("X %10.3f %10.3f %10.3f %10.3f %4d\n", fx, x11, x22, drw, xx);
printf("X %10.3f %10.3f %10.3f %10.3f %4d\n", printf("Y %10.3f %10.3f %10.3f %10.3f %4d\n", fy, y11, y22, drh, yy);
fx, x11, x22, drw, xx);
if ( ! (rand() % 40000) )
printf("Y %10.3f %10.3f %10.3f %10.3f %4d\n",
fy, y11, y22, drh, yy);
#endif #endif
if ( ! Image_xy_inside(src, xx, yy) ) if ( ! Image_xy_inside(src, xx, yy) )
@ -203,7 +199,7 @@ int nw, nh, foo;
Image_Desc *dst; Image_Desc *dst;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "image\t%d %d, scale %f %f\n", fprintf(stderr, "%s: image\t%d %d, scale %f %f\n", __func__,
src->width, src->height, scaleX, scaleY); src->width, src->height, scaleX, scaleY);
#endif #endif
@ -223,9 +219,8 @@ fprintf(stderr, "\t%f %f\n", fx, fy);
fprintf(stderr, "\tnew dims: %d x %d\n", nw, nh); fprintf(stderr, "\tnew dims: %d x %d\n", nw, nh);
#endif #endif
if ( (dst = Image_alloc(nw, nh, 3)) == NULL ) if ( (dst = Image_alloc(nw, nh, 3)) == NULL ) {
{ fprintf(stderr, "%s: no memory\n", __func__);
fprintf(stderr, "Image new/scale: no memory\n");
return NULL; return NULL;
} }

View File

@ -14,16 +14,19 @@
/* /*
* comme au bon vieux temps... * comme au bon vieux temps...
*/ */
int int Image_TV_old(Image_Desc *src, Image_Desc *dst, int p1, int p2, int p3)
Image_TV_old(Image_Desc *src, Image_Desc *dst, int p1, int p2, int p3)
{ {
int foo; int foo;
int x, y, v1, v2; int x, y, v1, v2;
int resteY; int resteY;
int sigma; int sigma;
if ( (foo=Image_compare_desc(src, dst)) ) #if DEBUG_LEVEL
{ fprintf(stderr, ">>> %s ( %p %p %d %d %d )\n", __func__,
src, dst, p1, p2, p3);
#endif
if ( (foo=Image_compare_desc(src, dst)) ) {
fprintf(stderr, "%s: images are differents %d\n", __func__, foo); fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
return foo; return foo;
} }
@ -36,13 +39,11 @@ resteY /= 2; /* half for the top, half for the bottom */
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s : height %d reste Y %d\n", __func__, src->height, resteY); fprintf(stderr, "%s : height %d reste Y %d\n", __func__, src->height, resteY);
fprintf(stderr, "%s : %d %d %d -> %d\n", __func__, p1, p2, p3, sigma); fprintf(stderr, "%s : %d %d %d -> %d\n", __func__, p1, p2, p3, sigma);
#endif #endif
for (y=resteY; y<src->height-resteY-1; y+=3) for (y=resteY; y<src->height-resteY-1; y+=3) {
{ for (x=0; x<src->width; x++) {
for (x=0; x<src->width; x++)
{
v1 = ( Image_R_pixel(src, x, y) + v1 = ( Image_R_pixel(src, x, y) +
Image_R_pixel(src, x, y+1) + Image_R_pixel(src, x, y+1) +
Image_R_pixel(src, x, y+2) + Image_R_pixel(src, x, y+2) +
@ -68,20 +69,17 @@ return FUNC_IS_BETA;
/* /*
* this is juste a wrapper function - need more work... * this is juste a wrapper function - need more work...
*/ */
int int Image_TV_veryold(Image_Desc *src, Image_Desc *dst, int p1, int p2, int p3)
Image_TV_veryold(Image_Desc *src, Image_Desc *dst, int p1, int p2, int p3)
{ {
int foo; int foo;
/* 15 janvier 2007: chasse au coredump... */ /* 15 janvier 2007: chasse au coredump... */
if ( (src->magic!=MAGIC_OF_IMAGE) || (dst->magic!=MAGIC_OF_IMAGE) ) if ( (src->magic!=MAGIC_OF_IMAGE) || (dst->magic!=MAGIC_OF_IMAGE) ) {
{
fprintf(stderr, "Image TV veryold: bad image descriptor\n"); fprintf(stderr, "Image TV veryold: bad image descriptor\n");
abort(); abort();
} }
if ( (foo=Image_compare_desc(src, dst)) ) if ( (foo=Image_compare_desc(src, dst)) ) {
{
fprintf(stderr, "Image TV veryold: images are differents %d\n", foo); fprintf(stderr, "Image TV veryold: images are differents %d\n", foo);
return foo; return foo;
} }
@ -95,16 +93,19 @@ return FUNC_IS_ALPHA;
/* /*
* new 10 novembre 2013, in mixart-myrys * new 10 novembre 2013, in mixart-myrys
*/ */
int int Image_TV_pix_0(Image_Desc *src, Image_Desc *dst, int w, int h, int grey)
Image_TV_pix_0(Image_Desc *src, Image_Desc *dst, int w, int h, int grey)
{ {
int foo, ox, oy; int foo, ox, oy;
int x, y, r, g, b; int x, y, r, g, b;
int xmax, ymax; int xmax, ymax;
Image_Rect zone; Image_Rect zone;
if ( (foo=Image_compare_desc(src, dst)) ) #if DEBUG_LEVEL
{ fprintf(stderr, ">>> %s ( %p %p %d %d %d )\n", __func__,
src, dst, w, h, grey);
#endif
if ( (foo=Image_compare_desc(src, dst)) ) {
fprintf(stderr, "%s: images are differents %d\n", __func__, foo); fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
return foo; return foo;
} }
@ -113,8 +114,7 @@ if ( (foo=Image_compare_desc(src, dst)) )
fprintf(stderr, "%s : w %d h %d grey %d\n", __func__, w, h, grey); fprintf(stderr, "%s : w %d h %d grey %d\n", __func__, w, h, grey);
#endif #endif
if (0==h || 0==w) if (0==h || 0==w) {
{
return BAD_PARAMETER; return BAD_PARAMETER;
} }
@ -127,11 +127,9 @@ fprintf(stderr, "%s : offsets = %d %d\n", __func__, ox, oy);
#endif #endif
Image_clear(dst, grey, grey, grey); Image_clear(dst, grey, grey, grey);
for (x=ox; x<xmax; x+=w) for (x=ox; x<xmax; x+=w) {
{
zone.x = x + (w/2); zone.x = x + (w/2);
for (y=oy; y<ymax; y+=h) for (y=oy; y<ymax; y+=h) {
{
zone.y = y + (h/2); zone.y = y + (h/2);
r = src->Rpix[y][x] & 0xfe; r = src->Rpix[y][x] & 0xfe;
g = src->Gpix[y][x] & 0xfe; g = src->Gpix[y][x] & 0xfe;
@ -154,8 +152,12 @@ int x, y, v1, v2, r, g, b;
int xmax, ymax; int xmax, ymax;
Image_Rect zone; Image_Rect zone;
if ( (foo=Image_compare_desc(src, dst)) ) #if DEBUG_LEVEL
{ fprintf(stderr, ">>> %s ( %p %p %d %d %d )\n", __func__,
src, dst, w, h, p3);
#endif
if ( (foo=Image_compare_desc(src, dst)) ) {
fprintf(stderr, "%s: images are differents %d\n", __func__, foo); fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
return foo; return foo;
} }
@ -164,8 +166,7 @@ if ( (foo=Image_compare_desc(src, dst)) )
fprintf(stderr, "%s : w %d h %d g%d\n", __func__, w, h, p3); fprintf(stderr, "%s : w %d h %d g%d\n", __func__, w, h, p3);
#endif #endif
if ((0==h) || (0==w)) if ((0==h) || (0==w)) {
{
return BAD_PARAMETER; return BAD_PARAMETER;
} }
@ -175,11 +176,9 @@ xmax = src->width - w;
ymax = src->height - h; ymax = src->height - h;
v1 = v2 = 0; v1 = v2 = 0;
for (x=0; x<xmax; x+=w) for (x=0; x<xmax; x+=w) {
{
zone.x = x; zone.x = x;
for (y=0; y<ymax; y+=h) for (y=0; y<ymax; y+=h) {
{
zone.y = y; zone.y = y;
r = src->Rpix[y][x]; r = src->Rpix[y][x];
g = src->Gpix[y][x]; g = src->Gpix[y][x];
@ -221,8 +220,7 @@ fprintf(stderr, "%s: largeur %d, taille %d\n", __func__, src->width, taille);
Image_gray_noise_0(dst, 20, 60); Image_gray_noise_0(dst, 20, 60);
for (y=0; y<src->height; y++) for (y=0; y<src->height; y++) {
{
switch (rand()%3) { switch (rand()%3) {
case 0 : case 0 :
memcpy((dst->Rpix[y]), src->Rpix[y], taille); memcpy((dst->Rpix[y]), src->Rpix[y], taille);
@ -262,8 +260,7 @@ Image_clear(dst, 60, 60, 60); /* XXX necessaire ? */
idx = rand() % 42; idx = rand() % 42;
for (y=0; y<src->height; y++) for (y=0; y<src->height; y++) {
{
if (0==mode) { if (0==mode) {
tri = (idx + y) % 3; tri = (idx + y) % 3;
} }
@ -273,8 +270,7 @@ for (y=0; y<src->height; y++)
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL > 1
fprintf(stderr, " %5d -> %d\n", y, tri); fprintf(stderr, " %5d -> %d\n", y, tri);
#endif #endif
switch (tri) switch (tri) {
{
case 0: case 0:
for (x=0; x<(src->width)-1; x++) { for (x=0; x<(src->width)-1; x++) {
v = (src->Rpix[y][x] + src->Rpix[y][x+1]); v = (src->Rpix[y][x] + src->Rpix[y][x+1]);

View File

@ -11,8 +11,7 @@
/* /*
* Rotation d'image. le parametre 'angle' est en degres. * Rotation d'image. le parametre 'angle' est en degres.
*/ */
int int Image_center_rotate(Image_Desc *src, Image_Desc *dst, double angle)
Image_center_rotate(Image_Desc *src, Image_Desc *dst, double angle)
{ {
int xs, ys, xd, yd; int xs, ys, xd, yd;
double arad, fxs, fys, fxd, fyd; double arad, fxs, fys, fxd, fyd;
@ -66,8 +65,7 @@ return FUNC_IS_BETA;
* *
* reste plus qu'à coder... * reste plus qu'à coder...
*/ */
int int Image_center_rotate_xy(Image_Desc *src, Image_Desc *dst, double angle,
Image_center_rotate_xy(Image_Desc *src, Image_Desc *dst, double angle,
double x, double y) double x, double y)
{ {
int foo, xd, yd; int foo, xd, yd;

View File

@ -1,15 +1,15 @@
#!/bin/bash #!/bin/bash
echo "warning: $0 is an ugly installer" echo "XXXXXXX warning: $0 is an ugly installer"
DESTDIR="/usr/local/" DESTDIR="/usr/local"
install -d $DESTDIR/lib/ install -d $DESTDIR/lib/
install -m 0644 libtthimage.a $DESTDIR/lib/libtthimage.a install -m 0644 libtthimage.a $DESTDIR/lib/libtthimage.a
install -m 0644 tthimage.h $DESTDIR/include/tthimage.h install -m 0644 tthimage.h $DESTDIR/include/tthimage.h
cp -v Datas/8x8thin Datas/16x24thin $DESTDIR/share/libimage/ cp -v Datas/8x8thin Datas/16x24thin $DESTDIR/share/libimage/
cp -v Datas/16x24gruik $DESTDIR/share/libimage/ cp -v Datas/8x8std Datas/16x24gruik $DESTDIR/share/libimage/
liste="genplot2 tga_cadre tga_effects tga_filtres tga_remap tga_tools \ liste="genplot2 tga_cadre tga_effects tga_filtres tga_remap tga_tools \
tga_combine tga_television tga_dither tga_applymap tga_makehf15 \ tga_combine tga_television tga_dither tga_applymap tga_makehf15 \