another big clean

This commit is contained in:
tTh
2022-09-21 00:06:11 +02:00
parent 1175eece63
commit a4e3d073f5
17 changed files with 261 additions and 438 deletions

View File

@@ -7,6 +7,7 @@
#include <stdlib.h>
#include <time.h>
#include <math.h>
#include "../tthimage.h"
/*::------------------------------------------------------------------::*/
@@ -15,25 +16,20 @@ int Image_mircol_0(Image_Desc *dst, char *txt, int flag)
int x, y;
RGBA fond, encre;
if (dst->width < 512 || dst->height < 512)
{
if (dst->width < 512 || dst->height < 512) {
fprintf(stderr, "Image mircol 0: image %p < 512x512\n", dst);
return IMAGE_TOO_SMALL;
}
if (0 != flag)
{
fprintf(stderr, "%s -> flag is %d and must be 0\n", __func__, flag);
if (0 != flag) {
fprintf(stderr, "%s: flag is %d and must be 0\n", __func__, flag);
}
if (NULL != txt)
{
fprintf(stderr, "%s : txt is '%s'\n", __func__, txt);
if (NULL != txt) {
fprintf(stderr, "%s: txt is '%s'\n", __func__, txt);
}
for (x=0; x<256; x++)
{
for (y=0; y<256; y++)
{
for (x=0; x<256; x++) {
for (y=0; y<256; y++) {
Image_plotRGB(dst, x, y, x, y, 0);
Image_plotRGB(dst, x+256, y, x, 0, y);
Image_plotRGB(dst, x, y+256, 0, x, y);
@@ -64,22 +60,19 @@ for (x=1; x<256; x++)
return FUNC_IS_BETA;
}
/*::------------------------------------------------------------------::*/
/* a quoi sert ce flag */
/* a quoi sert ce flag ? */
int Image_mircol_1(Image_Desc *dst, char *txt, int flag)
{
RGBA fond, encre;
int x, y, r, g, b;
if (dst->width < 512 || dst->height < 512)
{
if (dst->width < 512 || dst->height < 512) {
fprintf(stderr, "Image mircol 1: image %p < 512x512\n", dst);
return IMAGE_TOO_SMALL;
}
for (x=0; x<512; x++)
{
for (y=0; y<512; y++)
{
for (x=0; x<512; x++) {
for (y=0; y<512; y++) {
r = x;
g = (x + y) / 2;
b = y;
@@ -109,8 +102,7 @@ float fx, fy, fd;
fprintf(stderr, ">>>> %s ( %p '%s' %d )\n", __func__, dst, txt, mode);
#endif
for (y=0; y<dst->height; y++)
{
for (y=0; y<dst->height; y++) {
fy = (float)y / (float)dst->height;
ky = (int)(fy * 256.0);
for (x=0; x<dst->width; x++)
@@ -136,10 +128,10 @@ return FULL_NUCKED;
/* nouveau 6 fevrier 2010 */
int Image_mircol_3(Image_Desc *dst, char *txt, int mode)
{
int x, y, r, g, b;
int *p1, *p2, *p3;
float fx, fx2, fy, dist;
float mystk;
int x, y, r, g, b;
int *p1, *p2, *p3;
float fx, fx2, fy, dist;
float mystk;
#if DEBUG_LEVEL
fprintf(stderr, ">>>> %s ( %p '%s' %d )\n", __func__, dst, txt, mode);
@@ -151,21 +143,15 @@ switch (mode) {
case 2: p1 = &b, p2 = &r, p3 = &g; break;
default:
fprintf(stderr, "switch/case error in %s:%d\n",
__func__, __LINE__);
#if FORCE_ABORT
abort();
#endif
break;
fprintf(stderr, "case error in %s:%d\n", __func__, __LINE__);
return BAD_PARAMETER;
}
mystk = 0.90; /* FIXME */
for (y=0; y<dst->height; y++)
{
for (y=0; y<dst->height; y++) {
fy = (float)y / (float)dst->height;
for (x=0; x<dst->width; x++)
{
for (x=0; x<dst->width; x++) {
fx = (float)x / (float)dst->width;
*p1 = (int)((fx*fy) * 255);
@@ -189,7 +175,7 @@ for (y=0; y<dst->height; y++)
}
#if DEBUG_LEVEL > 1
fprintf(stderr, "%s : verifier le resultat, svp.\n", __func__);
fprintf(stderr, "%s: verifier le resultat, svp.\n", __func__);
#endif
return FUNC_IS_BETA;
@@ -206,8 +192,7 @@ float fx, fx2, fy, dist;
fprintf(stderr, ">>>> %s ( %p '%s' %d )\n", __func__, dst, txt, mode);
#endif
switch (mode)
{
switch (mode) {
case 0: p1 = &r, p2 = &g, p3 = &b; break;
case 1: p1 = &g, p2 = &b, p3 = &r; break;
case 2: p1 = &b, p2 = &r, p3 = &g; break;
@@ -219,13 +204,11 @@ switch (mode)
break;
}
for (y=0; y<dst->height; y++)
{
for (y=0; y<dst->height; y++) {
fy = (float)y / (float)dst->height;
for (x=0; x<dst->width; x++)
{
for (x=0; x<dst->width; x++) {
fx = (float)x / (float)dst->width;
/* FIXME TODO */
/* FIXME TODO OMG WTF XXX */
}
}
@@ -261,22 +244,19 @@ return FUNC_IS_BETA;
}
/*::------------------------------------------------------------------::*/
/* le bit 0 du flag controle l'ecriture des noms de composantes */
int
Image_decompose(Image_Desc *src, Image_Desc *dst, int flag)
int Image_decompose(Image_Desc *src, Image_Desc *dst, int flag)
{
int foo, x, y, hx, hy;
Image_Desc *moitie;
int r, g, b;
if ( (foo=Image_compare_desc(src, dst)) )
{
if ( (foo=Image_compare_desc(src, dst)) ) {
fprintf(stderr, "%s: bad dimensions %d\n", __func__, foo);
return foo;
}
moitie = Image_MakeHalfSize(src, 1);
if (moitie == NULL)
{
if (moitie == NULL) {
fprintf(stderr, "Image Decompose: NO MEM\n");
exit(5);
}
@@ -287,10 +267,8 @@ if (0 != flag)
hx = moitie->width;
hy = moitie->height;
for (x=0; x<moitie->width; x++)
{
for (y=0; y<moitie->height; y++)
{
for (x=0; x<moitie->width; x++) {
for (y=0; y<moitie->height; y++) {
Image_getRGB(moitie, x, y, &r, &g, &b);
Image_plotRGB(dst, x, y, r, r, r);
Image_plotRGB(dst, x+hx, y, g, g, g);
@@ -302,8 +280,7 @@ for (x=0; x<moitie->width; x++)
/* faire le menage */
Image_DeAllocate(moitie); free(moitie);
if (flag & 1)
{
if (flag & 1) {
RGBA ink, pap; /* hu ho ? local vars here ? */
Image_load_fnt8x8("libimage.fonte", NULL, 0);
pap.a = 0; ink.a = 255;