garbage collecting again

This commit is contained in:
tth 2022-07-07 12:52:00 +02:00
parent 6455be4d5b
commit 95beee167d
43 changed files with 343 additions and 341 deletions

1
.gitignore vendored
View File

@ -11,6 +11,7 @@ Lib/t_t16x24
Lib/testbmp Lib/testbmp
Tests/*.tga Tests/*.tga
Tests/t_t16x24
Tools/genplot2 Tools/genplot2
Tools/tga_alpha Tools/tga_alpha

View File

@ -16,9 +16,11 @@ all: foo testtga
alpha.o: alpha.c $(DEPS) alpha.o: alpha.c $(DEPS)
alpha2.o: alpha2.c $(DEPS) alpha2.o: alpha2.c $(DEPS)
anamorphose.o: anamorphose.c $(DEPS)
basic_io.o: basic_io.c $(DEPS) basic_io.o: basic_io.c $(DEPS)
bitblt.o: bitblt.c $(DEPS) bitblt.o: bitblt.c $(DEPS)
bitplanes.o: bitplanes.c $(DEPS)
bmp.o: bmp.c $(DEPS) bmp.h bmp.o: bmp.c $(DEPS) bmp.h
cadres.o: cadres.c $(DEPS) cadres.o: cadres.c $(DEPS)
@ -89,6 +91,7 @@ patterns2.o: patterns2.c $(DEPS)
patterns3.o: patterns3.c $(DEPS) patterns3.o: patterns3.c $(DEPS)
patterns4.o: patterns4.c $(DEPS) patterns4.o: patterns4.c $(DEPS)
photomaton.o: photomaton.c $(DEPS) photomaton.o: photomaton.c $(DEPS)
pcx.o: pcx.c $(DEPS)
pht.o: pht.c $(DEPS) pht.o: pht.c $(DEPS)
pixeliz.o: pixeliz.c $(DEPS) pixeliz.o: pixeliz.c $(DEPS)
pixels.o: pixels.c $(DEPS) pixels.o: pixels.c $(DEPS)
@ -104,6 +107,8 @@ pov_hf15f.o: pov_hf15f.c $(DEPS)
pov_synth.o: pov_synth.c $(DEPS) pov_synth.o: pov_synth.c $(DEPS)
ptlist.o: ptlist.c $(DEPS) ptlist.o: ptlist.c $(DEPS)
quadpics.o: quadpics.c $(DEPS)
recurse.o: recurse.c $(DEPS) recurse.o: recurse.c $(DEPS)
rgbmask.o: rgbmask.c $(DEPS) rgbmask.o: rgbmask.c $(DEPS)
@ -119,6 +124,7 @@ text1.o: text1.c $(DEPS)
text16x24.o: text16x24.c $(DEPS) text16x24.o: text16x24.c $(DEPS)
tga.o: tga.c $(DEPS) tga.o: tga.c $(DEPS)
tools.o: tools.c $(DEPS) tools.o: tools.c $(DEPS)
turtle.o: turtle.c $(DEPS)
vignetize.o: vignetize.c $(DEPS) vignetize.o: vignetize.c $(DEPS)
@ -132,11 +138,11 @@ zoom.o: zoom.c $(DEPS)
#----------------------------------------------------------------- #-----------------------------------------------------------------
OBJECTS = 7seg.o \ OBJECTS = 7seg.o \
alpha.o alpha2.o \ alpha.o alpha2.o anamorphose.o \
basic_io.o bitblt.o bmp.o \ basic_io.o bitblt.o bitplanes.o bmp.o \
cadres2.o cadres3.o cadres4.o cadres84.o cadresbox.o \ cadres2.o cadres3.o cadres4.o cadres84.o cadresbox.o \
cadres.o \ cadres.o \
calculs.o classif.o \ calcluts.o calculs.o classif.o \
col4bits.o colors.o colors2.o col_reduc.o col_xyz.o \ col4bits.o colors.o colors2.o col_reduc.o col_xyz.o \
combine.o combine2.o combine3.o combine4.o combine5.o \ combine.o combine2.o combine3.o combine4.o combine5.o \
combine6.o combine_rnd.o \ combine6.o combine_rnd.o \
@ -155,22 +161,24 @@ OBJECTS = 7seg.o \
operat.o op2x2.o \ operat.o op2x2.o \
palettes.o \ palettes.o \
patterns.o patterns2.o patterns3.o patterns4.o \ patterns.o patterns2.o patterns3.o patterns4.o \
pcx.o \
photomaton.o pht.o pixeliz.o pixels.o plotteur.o \ photomaton.o pht.o pixeliz.o pixels.o plotteur.o \
pnm.o png.o \ pnm.o png.o \
pov_hf15a.o pov_hf15b.o pov_hf15c.o pov_hf15d.o \ pov_hf15a.o pov_hf15b.o pov_hf15c.o pov_hf15d.o \
pov_hf15e.o pov_hf15e.o pov_hf15f.o pov_synth.o \ pov_hf15e.o pov_hf15e.o pov_hf15f.o pov_synth.o \
ptlist.o \ ptlist.o \
quadpics.o \
recurse.o rgbmask.o \ recurse.o rgbmask.o \
scale.o sobel4.o stereo.o \ scale.o sobel4.o stereo.o \
tamppool.o tele_2.o television.o \ tamppool.o tele_2.o television.o \
text0.o text1.o text16x24.o \ text0.o text1.o text16x24.o \
tga.o tools.o \ tga.o tools.o turtle.o \
vignetize.o \ vignetize.o \
warp0.o warp1.o warp2.o warp3.o \ warp0.o warp1.o warp2.o warp3.o \
zoom.o zoom.o
../libtthimage.a: $(OBJECTS) ../libtthimage.a: $(OBJECTS)
$(AR) vrs $@ $? $(AR) rs $@ $?
$(RANLIB) $@ $(RANLIB) $@
#----------------------------------------------------------------- #-----------------------------------------------------------------
@ -178,16 +186,12 @@ OBJECTS = 7seg.o \
foo: foo.c $(DEPS) ../libtthimage.a foo: foo.c $(DEPS) ../libtthimage.a
gcc $(CFLAGS) $< ../libtthimage.a -o $@ gcc $(CFLAGS) $< ../libtthimage.a -o $@
t_t16x24: t_t16x24.c $(DEPS) ../libtthimage.a
gcc $(CFLAGS) $< ../libtthimage.a -o $@
t_png: t_png.c $(DEPS) ../libtthimage.a t_png: t_png.c $(DEPS) ../libtthimage.a
gcc $(CFLAGS) $< ../libtthimage.a -lpng -lz -o $@ gcc $(CFLAGS) $< ../libtthimage.a -lpng -lz -o $@
testbmp: testbmp.c $(DEPS) ../libtthimage.a testbmp: testbmp.c $(DEPS) ../libtthimage.a
gcc $(CFLAGS) $< ../libtthimage.a -lm -o $@ gcc $(CFLAGS) $< ../libtthimage.a -lm -o $@
#----------------------------------------------------------------- #-----------------------------------------------------------------
essais.o: essais.c $(DEPS) essais.h essais.o: essais.c $(DEPS) essais.h

View File

@ -7,7 +7,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <math.h> #include <math.h>
#include "tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int
@ -16,16 +16,14 @@ Image_anmo_X(Image_Desc *src, Image_Desc *dst)
int x, y; int x, y;
double dnormx, dnormy; double dnormx, dnormy;
fprintf(stderr, "%s : %p -> %p\n", __func__, src, dst); fprintf(stderr, ">>> %s: %p -> %p\n", __func__, src, dst);
/* /*
* we scan the destination picture * we scan the destination picture
*/ */
for (y=0; y<dst->height; y++) for (y=0; y<dst->height; y++) {
{
dnormy = (double)y/(double)dst->height; dnormy = (double)y/(double)dst->height;
for (x=0; x<dst->width; x++) for (x=0; x<dst->width; x++) {
{
dnormx = (double)x/(double)dst->width; dnormx = (double)x/(double)dst->width;
@ -73,10 +71,8 @@ double xamp, yamp;
long nb_in, nb_out; long nb_in, nb_out;
#endif #endif
image = Image_alloc(w, h, 3); if (NULL==(image = Image_alloc(w, h, 3))) {
if (image==NULL) fprintf(stderr, "%s %s : Abend: no mem\n", __FILE__, __func__);
{
fprintf(stderr, "%s: Abend: no mem\n", __FILE__);
exit(5); exit(5);
} }

View File

@ -12,7 +12,7 @@
#include "../tthimage.h" #include "../tthimage.h"
#define VERSION_STRING "5 octobre 2015" #define VERSION_STRING "7 juiller 2022"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/*:: private variables */ /*:: private variables */
@ -45,7 +45,7 @@ int taille;
uint8_t *pbits; uint8_t *pbits;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s ( %d %d )\n", __func__, w, h); fprintf(stderr, ">>> %s ( %d %d )\n", __func__, w, h);
#endif #endif
/* is there a sanity check on the dimensions ? */ /* is there a sanity check on the dimensions ? */
@ -90,7 +90,7 @@ int Image_free_that_BP(A_BitPlane *bp, int k)
{ {
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s ( %p %d )\n", __func__, bp, k); fprintf(stderr, ">>> %s ( %p %d )\n", __func__, bp, k);
#endif #endif
if (bp->magic != MAGIC_BIT_PLANE) { if (bp->magic != MAGIC_BIT_PLANE) {
@ -117,7 +117,7 @@ return FUNC_IS_ALPHA;
int Image_BP_setname(A_BitPlane *bp, const char *name) int Image_BP_setname(A_BitPlane *bp, const char *name)
{ {
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s ( %p '%s' )\n", __func__, bp, name); fprintf(stderr, ">>> %s ( %p '%s' )\n", __func__, bp, name);
#endif #endif
if (MAGIC_BIT_PLANE != bp->magic) { if (MAGIC_BIT_PLANE != bp->magic) {
@ -186,10 +186,9 @@ offbit = x % 8;
fprintf(stderr, " offbyte %d, offbit %d\n", offbyte, offbit); fprintf(stderr, " offbyte %d, offbit %d\n", offbyte, offbit);
fprintf(stderr, " avant 0x%02x\n", bp->plane[offbyte]); fprintf(stderr, " avant 0x%02x\n", bp->plane[offbyte]);
#endif #endif
if (bit)
bp->plane[offbyte] |= (1 << offbit); if (bit) bp->plane[offbyte] |= (1 << offbit);
else else bp->plane[offbyte] &= ~(1 << offbit);
bp->plane[offbyte] &= ~(1 << offbit);
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL > 1
fprintf(stderr, " apres 0x%02x\n", bp->plane[offbyte]); fprintf(stderr, " apres 0x%02x\n", bp->plane[offbyte]);
@ -243,7 +242,7 @@ fprintf(stderr, "%s ( %p '%s' 0x%03x )\n", __func__, bp, fname, k);
if (NULL==(fp=fopen(fname, "w"))) if (NULL==(fp=fopen(fname, "w")))
{ {
fprintf(stderr, "fucked in %s\n", __func__); fprintf(stderr, "fucked in %s on file '%s'\n", __func__, fname);
return FULL_NUCKED; return FULL_NUCKED;
} }
@ -252,17 +251,14 @@ fprintf(fp, "# written by libtthimage v %s\n# bitplane module '%s'\n",
IMAGE_VERSION_STRING, VERSION_STRING); IMAGE_VERSION_STRING, VERSION_STRING);
chariot = 0; chariot = 0;
for (y=0; y<bp->height; y++) for (y=0; y<bp->height; y++) {
{ for (x=0; x<bp->width; x++) {
for (x=0; x<bp->width; x++)
{
Image_BP_pget(bp, x, y, &v); Image_BP_pget(bp, x, y, &v);
if (v) fputc('1', fp); if (v) fputc('1', fp);
else fputc('0', fp); else fputc('0', fp);
if (chariot++ < 74) if (chariot++ < 74)
fputc(' ', fp); fputc(' ', fp);
else else {
{
fputc('\n', fp); chariot=0; fputc('\n', fp); chariot=0;
} }
} }

View File

@ -14,7 +14,7 @@
#include <alloca.h> #include <alloca.h>
#endif #endif
#include "tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int

View File

@ -244,6 +244,9 @@ for (y=0; y<s1->height; y++)
b2 = (s2->Bpix[y])[x]; b2 = (s2->Bpix[y])[x];
coef = (fx2+fy2)/dmax; coef = (fx2+fy2)/dmax;
if (1==yo) {
coef = cos(coef);
}
if (coef < 0.0) coef = 0.0; if (coef < 0.0) coef = 0.0;
if (coef > 1.0) coef = 1.0; if (coef > 1.0) coef = 1.0;
@ -253,6 +256,7 @@ for (y=0; y<s1->height; y++)
(d->Bpix[y])[x] = (int)(b1*(1.0-coef)+b2*coef); (d->Bpix[y])[x] = (int)(b1*(1.0-coef)+b2*coef);
} }
fprintf(stderr, "x %4d y %4d c %f\n", x, y, coef);
} }
return OLL_KORRECT; return OLL_KORRECT;

View File

@ -21,20 +21,17 @@ int r2, g2, b2;
int rd, gd, bd; int rd, gd, bd;
double k, ka, kb; double k, ka, kb;
if ( (foo=Image_compare_desc(s1, s2)) ) if ( (foo=Image_compare_desc(s1, s2)) ) {
{ fprintf(stderr, "%s: sources err: %s\n", __func__, Image_err2str(foo));
fprintf(stderr, "V degrade: sources err: %s\n", Image_err2str(foo));
return foo; return foo;
} }
for (y=0; y<s1->height; y++) for (y=0; y<s1->height; y++) {
{
k = (double)y/(double)s1->height; k = (double)y/(double)s1->height;
if (sens) { ka = k; kb = 1.0 - ka; } if (sens) { ka = k; kb = 1.0 - ka; }
else { kb = k; ka = 1.0 - kb; } else { kb = k; ka = 1.0 - kb; }
for (x=0; x<s1->width; x++) for (x=0; x<s1->width; x++) {
{
Image_getRGB(s1, x, y, &r1, &g1, &b1); Image_getRGB(s1, x, y, &r1, &g1, &b1);
Image_getRGB(s2, x, y, &r2, &g2, &b2); Image_getRGB(s2, x, y, &r2, &g2, &b2);
rd = (int)((double)r1*ka+(double)r2*(kb)); rd = (int)((double)r1*ka+(double)r2*(kb));
@ -57,19 +54,16 @@ int r2, g2, b2;
int rd, gd, bd; int rd, gd, bd;
double k, ka, kb; double k, ka, kb;
if ( (foo=Image_compare_desc(s1, s2)) ) if ( (foo=Image_compare_desc(s1, s2)) ) {
{ fprintf(stderr, "%s: sources err: %s\n", __func__, Image_err2str(foo));
fprintf(stderr, "H degrade: sources err: %s\n", Image_err2str(foo));
return foo; return foo;
} }
for (x=0; x<s1->width; x++) for (x=0; x<s1->width; x++) {
{
k = (double)x/(double)s1->width; k = (double)x/(double)s1->width;
if (sens) { ka = k; kb = 1.0-ka; } if (sens) { ka = k; kb = 1.0-ka; }
else { kb = k; ka = 1.0-kb; } else { kb = k; ka = 1.0-kb; }
for (y=0; y<s1->height; y++) for (y=0; y<s1->height; y++) {
{
Image_getRGB(s1, x, y, &r1, &g1, &b1); Image_getRGB(s1, x, y, &r1, &g1, &b1);
Image_getRGB(s2, x, y, &r2, &g2, &b2); Image_getRGB(s2, x, y, &r2, &g2, &b2);
rd = (int)((double)r1*ka+(double)r2*(kb)); rd = (int)((double)r1*ka+(double)r2*(kb));
@ -96,14 +90,12 @@ int foo;
fprintf(stderr, "%s:%d:%s: no such function or procedure\n", fprintf(stderr, "%s:%d:%s: no such function or procedure\n",
__FILE__, __LINE__, __func__); __FILE__, __LINE__, __func__);
if ( (foo=Image_compare_desc(s1, s2)) ) if ( (foo=Image_compare_desc(s1, s2)) ) {
{ fprintf(stderr, "%s: sources err: %s\n", __func__, Image_err2str(foo));
fprintf(stderr, "D degrade: sources err: %s\n", Image_err2str(foo));
return foo; return foo;
} }
if ( (foo=Image_compare_desc(s1, dst)) ) if ( (foo=Image_compare_desc(s1, dst)) ) {
{ fprintf(stderr, "%s: dst err: %s\n", __func__, Image_err2str(foo));
fprintf(stderr, "D degrade: dst err: %s\n", Image_err2str(foo));
return foo; return foo;
} }
@ -120,30 +112,25 @@ int Image_combine_Vsplit(Image_Desc *s1, Image_Desc *s2, Image_Desc *d,
int foo, x, y; int foo, x, y;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s ( %p %p %p %d %d )\n", __func__, s1, s2, d, xv, uh); fprintf(stderr, ">>> %s ( %p %p %p %d %d )\n", __func__, s1, s2, d, xv, uh);
#endif #endif
if (0 != uh) if (0 != uh)
fprintf(stderr, "%s : uh must be 0 and not %d\n", __func__, uh); fprintf(stderr, "%s : uh must be 0 and not %d\n", __func__, uh);
if ( (foo=Image_compare_desc(s1, s2)) ) if ( (foo=Image_compare_desc(s1, s2)) ) {
{
fprintf(stderr, "%s : src err: %s\n", __func__, Image_err2str(foo)); fprintf(stderr, "%s : src err: %s\n", __func__, Image_err2str(foo));
return foo; return foo;
} }
for (y=0; y<s1->height; y++) for (y=0; y<s1->height; y++) {
{ for (x=0; x<s1->width; x++) {
for (x=0; x<s1->width; x++) if (x<xv) {
{
if (x<xv)
{
(d->Rpix[y])[x] = (s1->Rpix[y])[x]; (d->Rpix[y])[x] = (s1->Rpix[y])[x];
(d->Gpix[y])[x] = (s1->Gpix[y])[x]; (d->Gpix[y])[x] = (s1->Gpix[y])[x];
(d->Bpix[y])[x] = (s1->Bpix[y])[x]; (d->Bpix[y])[x] = (s1->Bpix[y])[x];
} }
else else {
{
(d->Rpix[y])[x] = (s2->Rpix[y])[x]; (d->Rpix[y])[x] = (s2->Rpix[y])[x];
(d->Gpix[y])[x] = (s2->Gpix[y])[x]; (d->Gpix[y])[x] = (s2->Gpix[y])[x];
(d->Bpix[y])[x] = (s2->Bpix[y])[x]; (d->Bpix[y])[x] = (s2->Bpix[y])[x];
@ -163,7 +150,7 @@ int Image_combine_Hsplit(Image_Desc *s1, Image_Desc *s2, Image_Desc *d,
int x, y; int x, y;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s (%p %p %p %d %d)\n", __func__, s1, s2, d, yv, uh); fprintf(stderr, ">>> %s ( %p %p %p %d %d )\n", __func__, s1, s2, d, yv, uh);
#endif #endif
if (0 != uh) if (0 != uh)

View File

@ -4,7 +4,7 @@
#include <stdio.h> #include <stdio.h>
#include "tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*

View File

@ -4,7 +4,7 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include "tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
@ -17,6 +17,10 @@ int foo, val;
int x, y; int x, y;
long nbre; long nbre;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d %p )\n", __func__, img, seuilr, ptl);
#endif
nbre = 0; nbre = 0;
for (y=0; y<img->height; y++) for (y=0; y<img->height; y++)
{ {

View File

@ -100,22 +100,18 @@ Image_noise(Image_Desc *source, Image_Desc *but, int intensite)
{ {
int x, y, r, g, b, foo; int x, y, r, g, b, foo;
if ( (foo=Image_compare_desc(source, but)) ) if ( (foo=Image_compare_desc(source, but)) ) {
{ fprintf(stderr, "%s : images are differents %d\n", __func__, foo);
fprintf(stderr, "%s : images are differents %d\n", __func__, foo); return foo;
return foo; }
}
if (intensite < 1) if (intensite < 1) {
{ fprintf(stderr, "%s : bad intensity %d\n", __func__, intensite);
fprintf(stderr, "%s : bad intensity %d\n", __func__, intensite); intensite = 1;
intensite = 1; }
}
for (x=0; x<source->width; x++) for (x=0; x<source->width; x++) {
{ for (y=0; y<source->height; y++) {
for (y=0; y<source->height; y++)
{
r = Image_clamp_pixel((source->Rpix[y])[x] r = Image_clamp_pixel((source->Rpix[y])[x]
+ (rand()%intensite) - (intensite/2)); + (rand()%intensite) - (intensite/2));
g = Image_clamp_pixel((source->Gpix[y])[x] g = Image_clamp_pixel((source->Gpix[y])[x]

View File

@ -5,7 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int Image_gray_ops_0(Image_Desc *src, Image_Desc *dst, int k, int mask) int Image_gray_ops_0(Image_Desc *src, Image_Desc *dst, int k, int mask)

View File

@ -7,15 +7,13 @@
#include "../tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_print_histo_0(long *histo, char *fname, char *texte)
Image_print_histo_0(long *histo, char *fname, char *texte)
{ {
int foo; int foo;
printf("** %s **\n", texte); printf("** %s / %s **\n", texte, fname);
for (foo=0; foo<256; foo++) for (foo=0; foo<256; foo++) {
{
printf("%7ld ", histo[foo]); printf("%7ld ", histo[foo]);
if ((foo % 8)==0) if ((foo % 8)==0)
printf("\n"); printf("\n");
@ -36,8 +34,7 @@ unsigned long grand;
unsigned char *ucptr; unsigned char *ucptr;
int foo; int foo;
if (NULL != texte) if (NULL != texte) {
{
printf("============= %s ============\n", texte); printf("============= %s ============\n", texte);
} }
@ -57,16 +54,16 @@ for (foo=0; foo<sizeof(grand); foo++)
printf("\n"); printf("\n");
/* examen des types de base */ /* examen des types de base */
printf("basic types : short=%d int=%d long=%d ptr=%d\n", printf("basic types : short=%ld int=%ld long=%ld ptr=%ld\n",
sizeof(short), sizeof(int), sizeof(long), sizeof(void *)); sizeof(short), sizeof(int), sizeof(long), sizeof(void *));
/* examen des tructures de la libtthimage */ /* examen des tructures de la libtthimage */
printf("Image_Desc : %5u\n", sizeof(Image_Desc)); printf("Image_Desc : %5ld\n", sizeof(Image_Desc));
printf("Image_Rect : %5u\n", sizeof(Image_Rect)); printf("Image_Rect : %5ld\n", sizeof(Image_Rect));
printf("RGBA : %5u\n", sizeof(RGBA)); printf("RGBA : %5ld\n", sizeof(RGBA));
printf("A_BitPlane : %5u\n", sizeof(A_BitPlane)); printf("A_BitPlane : %5ld\n", sizeof(A_BitPlane));
printf("RGB_map : %5u\n", sizeof(RGB_map)); printf("RGB_map : %5ld\n", sizeof(RGB_map));
printf("Image_Point : %5u\n", sizeof(Image_Point)); printf("Image_Point : %5ld\n", sizeof(Image_Point));
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/

View File

@ -10,8 +10,7 @@
#include "../tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_mircol_0(Image_Desc *dst, char *txt, int flag)
Image_mircol_0(Image_Desc *dst, char *txt, int flag)
{ {
int x, y; int x, y;
RGBA fond, encre; RGBA fond, encre;
@ -66,8 +65,7 @@ return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* a quoi sert ce flag */ /* a quoi sert ce flag */
int int Image_mircol_1(Image_Desc *dst, char *txt, int flag)
Image_mircol_1(Image_Desc *dst, char *txt, int flag)
{ {
RGBA fond, encre; RGBA fond, encre;
int x, y, r, g, b; int x, y, r, g, b;
@ -239,19 +237,20 @@ int Image_mirRGB_0(Image_Desc *dst, int flag)
int x, y; int x, y;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s : %p %d\n", __func__, dst, flag); fprintf(stderr, ">>> %s ( %p %d )\n", __func__, dst, flag);
#endif #endif
if (dst->width != 256 || dst->height != 256) if (flag) {
{ fprintf(stderr, "flag is %d in %s\n", flag, __func__);
}
if (dst->width != 256 || dst->height != 256) {
fprintf(stderr, "Image mire RGB 0: image is not 256x256\n"); fprintf(stderr, "Image mire RGB 0: image is not 256x256\n");
return IMAGE_BAD_DIMS; return IMAGE_BAD_DIMS;
} }
for (x=0; x<256; x++) for (x=0; x<256; x++) {
{ for (y=0; y<256; y++) {
for (y=0; y<256; y++)
{
(dst->Rpix[y])[x] = x; (dst->Rpix[y])[x] = x;
(dst->Gpix[y])[x] = y; (dst->Gpix[y])[x] = y;
(dst->Bpix[y])[x] = (y+x)/2; (dst->Bpix[y])[x] = (y+x)/2;

View File

@ -11,7 +11,7 @@
#include <stdio.h> #include <stdio.h>
#include "tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
@ -22,7 +22,7 @@ Image_octree_0(Image_Desc *src, Image_Desc *dst)
{ {
#if DEBUG #if DEBUG
fprintf(stderr, "%s ( %p %p )\n", __func__, src, dst); fprintf(stderr, ">>> %s ( %p %p )\n", __func__, src, dst);
#endif #endif
return FULL_NUCKED; return FULL_NUCKED;
@ -33,7 +33,7 @@ Image_octree_1(Image_Desc *src, Image_Desc *dst)
{ {
#if DEBUG #if DEBUG
fprintf(stderr, "%s ( %p %p )\n", __func__, src, dst); fprintf(stderr, ">>> %s ( %p %p )\n", __func__, src, dst);
#endif #endif
return FULL_NUCKED; return FULL_NUCKED;

View File

@ -411,6 +411,9 @@ if ( (fp=fopen(fname, "w")) == NULL )
return FILE_CREATE_ERR; return FILE_CREATE_ERR;
} }
fprintf(fp, "P3\n%d 1\n255\n", p->nbre); fprintf(fp, "P3\n%d 1\n255\n", p->nbre);
if (NULL != comment) {
fprintf(fp, "# %s\n", comment);
}
for (foo=0; foo<p->nbre; foo++) for (foo=0; foo<p->nbre; foo++)
{ {
fprintf(fp, "%3d %3d %3d\n", p->red[foo], p->green[foo], p->blue[foo]); fprintf(fp, "%3d %3d %3d\n", p->red[foo], p->green[foo], p->blue[foo]);

View File

@ -99,7 +99,7 @@ for (x=0; x<dst->width; x++)
for (y=0; y<dst->height; y++) for (y=0; y<dst->height; y++)
{ {
dy = (double)x / (double)dst->height; dy = (double)x / (double)dst->height;
r = (int)round(256.0 * sqrt(dx * dy)); r = (int)round(256.0 * sqrt(dx * dy)); /* XXX */
g = b = rand() & 0xf0; g = b = rand() & 0xf0;
Image_plotRGB(dst, x, y, r, g, b); Image_plotRGB(dst, x, y, r, g, b);
} }

View File

@ -58,10 +58,14 @@ Image_pixeliz_X(Image_Desc *src, Image_Desc *dst)
{ {
int foo; int foo;
#if DEBUG_LEVEL
fprintf(stderr, "Pixeliz X: appel de test, pas finalise.\n"); fprintf(stderr, "Pixeliz X: appel de test, pas finalise.\n");
#endif
foo = Image_pixeliz_0(src, dst, 5, 13); foo = Image_pixeliz_0(src, dst, 5, 13);
#if DEBUG_LEVEL
fprintf(stderr, "Pixeliz X: valeur obtenue: %d\n", foo); fprintf(stderr, "Pixeliz X: valeur obtenue: %d\n", foo);
#endif
return foo; return foo;
} }

View File

@ -9,7 +9,7 @@
int int
Image_XOR_pixel(Image_Desc *img, int x, int y, int r, int g, int b) Image_XOR_pixel(Image_Desc *img, int x, int y, int r, int g, int b)
{ {
int pr, pg, pb, a; int pr, pg, pb;
if ( (x<0) || (y<0) || (x>=img->width) || (y>=img->height) ) if ( (x<0) || (y<0) || (x>=img->width) || (y>=img->height) )
{ {

View File

@ -42,7 +42,7 @@ fprintf(stderr, "%s ( '%s' %d )\n", __func__, fname, k);
writepng_version_info(); writepng_version_info();
#endif #endif
return 666; return NULL;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int Image_save_as_PNG(Image_Desc *img, char *fname, int p1, int p2) int Image_save_as_PNG(Image_Desc *img, char *fname, int p1, int p2)

View File

@ -19,30 +19,25 @@
* *
* Le coefficient K va de 0 a 10000 ! * Le coefficient K va de 0 a 10000 !
*/ */
int int Image_hf15_mix(Image_Desc *s1, Image_Desc *s2, Image_Desc *dst, int k)
Image_hf15_mix(Image_Desc *s1, Image_Desc *s2, Image_Desc *dst, int k)
{ {
int foo, x, y, h1, h2, hd; int foo, x, y, h1, h2, hd;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s: k = %d\n", __func__, k); fprintf(stderr, ">>> %s: k = %d\n", __func__, k);
#endif #endif
if ( (foo=Image_compare_desc(s1, s2)) ) if ( (foo=Image_compare_desc(s1, s2)) ) {
{
fprintf(stderr, "hf15 mix: err on sources: %s\n", Image_err2str(foo)); fprintf(stderr, "hf15 mix: err on sources: %s\n", Image_err2str(foo));
return foo; return foo;
} }
if ( (foo=Image_compare_desc(s1, dst)) ) if ( (foo=Image_compare_desc(s1, dst)) ) {
{
fprintf(stderr, "hf15 mix: err on dest: %s\n", Image_err2str(foo)); fprintf(stderr, "hf15 mix: err on dest: %s\n", Image_err2str(foo));
return foo; return foo;
} }
for (y=0; y<s1->height; y++) for (y=0; y<s1->height; y++) {
{ for (x=0; x<s1->width; x++) {
for (x=0; x<s1->width; x++)
{
h1 = Image_hf15_height(s1, x, y); h1 = Image_hf15_height(s1, x, y);
h2 = Image_hf15_height(s2, x, y); h2 = Image_hf15_height(s2, x, y);
hd = ((h1*k) + (h2*(10000-k))) / 10000; hd = ((h1*k) + (h2*(10000-k))) / 10000;
@ -63,26 +58,21 @@ return FUNC_IS_BETA;
* new 5 Janvier 2003 * new 5 Janvier 2003
* il y a probablement des problemes d'overflow ici. * il y a probablement des problemes d'overflow ici.
*/ */
int int Image_hf15_mult_i(Image_Desc *s1, Image_Desc *s2, Image_Desc *dst)
Image_hf15_mult_i(Image_Desc *s1, Image_Desc *s2, Image_Desc *dst)
{ {
int foo, x, y, h1, h2, hd; int foo, x, y, h1, h2, hd;
if ( (foo=Image_compare_desc(s1, s2)) ) if ( (foo=Image_compare_desc(s1, s2)) ) {
{
fprintf(stderr, "hf15 mult i: err on srces: %s\n", Image_err2str(foo)); fprintf(stderr, "hf15 mult i: err on srces: %s\n", Image_err2str(foo));
return foo; return foo;
} }
if ( (foo=Image_compare_desc(s1, dst)) ) if ( (foo=Image_compare_desc(s1, dst)) ) {
{
fprintf(stderr, "hf15 mult: err on dest: %s\n", Image_err2str(foo)); fprintf(stderr, "hf15 mult: err on dest: %s\n", Image_err2str(foo));
return foo; return foo;
} }
for (y=0; y<s1->height; y++) for (y=0; y<s1->height; y++) {
{ for (x=0; x<s1->width; x++) {
for (x=0; x<s1->width; x++)
{
h1 = Image_hf15_height(s1, x, y); h1 = Image_hf15_height(s1, x, y);
h2 = Image_hf15_height(s2, x, y); h2 = Image_hf15_height(s2, x, y);
hd = (h1 * h2) / 32768; hd = (h1 * h2) / 32768;
@ -96,21 +86,17 @@ return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* nouveau 17 novembre 2009 - avenue St Exupery */ /* nouveau 17 novembre 2009 - avenue St Exupery */
int int Image_hf15_mult_k(Image_Desc *s, Image_Desc *d, float dk)
Image_hf15_mult_k(Image_Desc *s, Image_Desc *d, float dk)
{ {
int foo, x, y, h1, h2; int foo, x, y, h1, h2;
if ( (foo=Image_compare_desc(s, d)) ) if ( (foo=Image_compare_desc(s, d)) ) {
{
fprintf(stderr, "hf15 mult k: error: %s\n", Image_err2str(foo)); fprintf(stderr, "hf15 mult k: error: %s\n", Image_err2str(foo));
return foo; return foo;
} }
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++)
{
h1 = Image_hf15_height(s, x, y); h1 = Image_hf15_height(s, x, y);
h2 = (int)( (float)h1 * dk ); h2 = (int)( (float)h1 * dk );
Image_hf15_plot(d, x, y, h2); Image_hf15_plot(d, x, y, h2);
@ -121,12 +107,11 @@ return FULL_NUCKED;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* nouveau Juin 2008 - avenue St Exupery */ /* nouveau Juin 2008 - avenue St Exupery */
int int Image_hf15_div_i(Image_Desc *s1, Image_Desc *s2, Image_Desc *dst)
Image_hf15_div_i(Image_Desc *s1, Image_Desc *s2, Image_Desc *dst)
{ {
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s ( %p %p %p )\n", __func__, s1, s2, dst); fprintf(stderr, ">>> %s ( %p %p %p )\n", __func__, s1, s2, dst);
#endif #endif
return FULL_NUCKED; return FULL_NUCKED;
@ -141,24 +126,20 @@ int foo;
float rh, mean_a; float rh, mean_a;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s ( %p , %p )\n", __func__, src, dst); fprintf(stderr, ">>> %s ( %p , %p )\n", __func__, src, dst);
#endif #endif
if ( (foo=Image_compare_desc(src, dst)) ) if ( (foo=Image_compare_desc(src, dst)) ) {
{
fprintf(stderr, "hf15 sqrt: (failed) : %s\n", Image_err2str(foo)); fprintf(stderr, "hf15 sqrt: (failed) : %s\n", Image_err2str(foo));
return foo; return foo;
} }
mean_a = 0.0; mean_a = 0.0;
for (y=0; y<src->height; y++) for (y=0; y<src->height; y++) {
{ for (x=0; x<src->width; x++) {
for (x=0; x<src->width; x++)
{
h = Image_hf15_height(src, x, y); h = Image_hf15_height(src, x, y);
if (h < 0) if (h < 0) {
{
fprintf(stderr, "WTF ! %s %p %d,%d %d\n", fprintf(stderr, "WTF ! %s %p %d,%d %d\n",
__func__, __func__,
src, x, y, h); src, x, y, h);
@ -178,8 +159,7 @@ return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* nouveau Novembre 2008 - avenue St Exupery */ /* nouveau Novembre 2008 - avenue St Exupery */
int int Image_hf15_pow(Image_Desc *src, Image_Desc *dst, double p0w44)
Image_hf15_pow(Image_Desc *src, Image_Desc *dst, double p0w44)
{ {
int x, y, h; int x, y, h;
int foo; int foo;
@ -188,20 +168,18 @@ float rh;
float minh, maxh; float minh, maxh;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s ( %p , %p, %g )\n", __func__, src, dst, p0w44); fprintf(stderr, ">>> %s ( %p , %p, %g )\n", __func__, src, dst, p0w44);
#endif #endif
if ( (foo=Image_compare_desc(src, dst)) ) if ( (foo=Image_compare_desc(src, dst)) ) {
{
fprintf(stderr, "%s : (fail) : %s\n", __func__, Image_err2str(foo)); fprintf(stderr, "%s : (fail) : %s\n", __func__, Image_err2str(foo));
return foo; return foo;
} }
minh = 999999.99;
maxh = -999999.99; minh = 9999999.99;
for (y=0; y<src->height; y++) maxh = -9999999.99;
{ for (y=0; y<src->height; y++) {
for (x=0; x<src->width; x++) for (x=0; x<src->width; x++) {
{
h = Image_hf15_height(src, x, y); h = Image_hf15_height(src, x, y);
rh = (float)h / 32768.0; rh = (float)h / 32768.0;
rh = pow(rh, p0w44); rh = pow(rh, p0w44);
@ -226,19 +204,16 @@ int foo, x, y, h;
double rh; double rh;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s ( %p , %p )\n", __func__, src, dst); fprintf(stderr, ">>> %s ( %p , %p )\n", __func__, src, dst);
#endif #endif
if ( (foo=Image_compare_desc(src, dst)) ) if ( (foo=Image_compare_desc(src, dst)) ) {
{
fprintf(stderr, "%s : (fail) : %s\n", __func__, Image_err2str(foo)); fprintf(stderr, "%s : (fail) : %s\n", __func__, Image_err2str(foo));
return foo; return foo;
} }
for (y=0; y<src->height; y++) for (y=0; y<src->height; y++) {
{ for (x=0; x<src->width; x++) {
for (x=0; x<src->width; x++)
{
h = Image_hf15_height(src, x, y); h = Image_hf15_height(src, x, y);
rh = (double)h / 32768.0; rh = (double)h / 32768.0;
rh = exp(rh) - 1.0; rh = exp(rh) - 1.0;
@ -254,7 +229,7 @@ return FUNC_IS_ALPHA;
int Image_hf15_exp2(Image_Desc *src, Image_Desc *dst) int Image_hf15_exp2(Image_Desc *src, Image_Desc *dst)
{ {
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s ( %p , %p )\n", __func__, src, dst); fprintf(stderr, ">>> %s ( %p %p )\n", __func__, src, dst);
#endif #endif
return FULL_NUCKED; return FULL_NUCKED;
} }

View File

@ -29,6 +29,10 @@ fprintf(stderr, "%s : img=%p hfin=%d taille=%d k=%d\n",
fprintf(stderr, " pic dims : %d x %d\n", im->width, im->height); fprintf(stderr, " pic dims : %d x %d\n", im->width, im->height);
#endif #endif
if (taille) {
fprintf(stderr, "%s : taille = %d, wtf?\n", __func__, taille);
}
/* this is really a MESS ! */ /* this is really a MESS ! */
fhfin = (float)(hfin*hfin); fhfin = (float)(hfin*hfin);
x2 = im->width / 2; x2 = im->width / 2;

View File

@ -12,15 +12,13 @@
#include "../tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_print_point(Image_Point *ppt)
Image_print_point(Image_Point *ppt)
{ {
printf(" xy %-4d %-4d c %-3d h %d\n", ppt->x, ppt->y, ppt->c, ppt->h); printf(" xy %-4d %-4d c %-3d h %d\n", ppt->x, ppt->y, ppt->c, ppt->h);
return FUNC_IS_ALPHA; return FUNC_IS_ALPHA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_ptl_dump(Image_PtList *pl, char *txt)
Image_ptl_dump(Image_PtList *pl, char *txt)
{ {
fprintf(stderr, "---+---------------\n"); fprintf(stderr, "---+---------------\n");
fprintf(stderr, " | %s\n", txt); fprintf(stderr, " | %s\n", txt);
@ -32,8 +30,7 @@ fprintf(stderr, "---+---------------\n");
return FUNC_IS_BETA; return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
Image_PtList * Image_PtList * Image_ptl_alloc(int nbre, char *name)
Image_ptl_alloc(int nbre, char *name)
{ {
Image_PtList *ptr; Image_PtList *ptr;
@ -71,8 +68,7 @@ if ( (ptr->points=malloc(sizeof(Image_Point)*nbre))==NULL)
return ptr; return ptr;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_ptl_add(Image_PtList *ptl, int x, int y, int h, int c)
Image_ptl_add(Image_PtList *ptl, int x, int y, int h, int c)
{ {
Image_Point *ptrpt; Image_Point *ptrpt;
int newsize, idx; int newsize, idx;
@ -124,8 +120,7 @@ return FUNC_IS_BETA;
* des programmes FORTRAN, beaucoup plus pointilleux sur le * des programmes FORTRAN, beaucoup plus pointilleux sur le
* formatage des données. * formatage des données.
*/ */
int int Image_ptl_write(char *filename, Image_PtList *ptl)
Image_ptl_write(char *filename, Image_PtList *ptl)
{ {
FILE *fp; FILE *fp;
int foo; int foo;
@ -151,19 +146,19 @@ fclose(fp);
return FUNC_IS_BETA; return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_ptl_read(char *filename, Image_PtList *ptl)
Image_ptl_read(char *filename, Image_PtList *ptl)
{ {
FILE *fp; FILE *fp;
int foo; int foo;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s ( '%s' %p )\n", __func__, filename, ptl); fprintf(stderr, ">>> %s ( '%s' %p )\n", __func__, filename, ptl);
#endif #endif
if (ptl->control != 0xfde9601a) if (ptl->control != 0xfde9601a)
{ {
fprintf(stderr, "%s: no deadbeef in %p\n", __func__, ptl); fprintf(stderr, "%s: no deadbeef in %p\n", __func__, ptl);
fprintf(stderr, " can't read '%s'\n", filename);
return 666; return 666;
} }
@ -174,8 +169,7 @@ return FULL_NUCKED;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* destruction d'une liste de points */ /* destruction d'une liste de points */
int int Image_ptl_kill(Image_PtList *ptl, char *msg)
Image_ptl_kill(Image_PtList *ptl, char *msg)
{ {
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "Killing point list %p for '%s'\n", ptl, msg); fprintf(stderr, "Killing point list %p for '%s'\n", ptl, msg);
@ -187,6 +181,10 @@ if (ptl->control != 0xfde9601a)
return 666; return 666;
} }
if (NULL != msg) {
fprintf(stderr, "%s is killing %p because %s\n", __func__, ptl, msg);
}
/* killing the array */ /* killing the array */
free(ptl->points); ptl->points = NULL; free(ptl->points); ptl->points = NULL;
ptl->control = 0; ptl->control = 0;
@ -211,8 +209,7 @@ if (NULL != alloc) *alloc = ptl->alloc;
return OLL_KORRECT; return OLL_KORRECT;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_ptl_get_point(Image_PtList *ptl, Image_Point *pt, int idx)
Image_ptl_get_point(Image_PtList *ptl, Image_Point *pt, int idx)
{ {
if (ptl->control != 0xfde9601a) if (ptl->control != 0xfde9601a)
{ {
@ -241,8 +238,7 @@ fprintf(stderr, "%s: %p %d -> %d %d\n", __func__, ptl, idx, pt->x, pt->y);
return FUNC_IS_BETA; return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_ptl_boundingbox(Image_PtList *ptl, Image_Rect *box)
Image_ptl_boundingbox(Image_PtList *ptl, Image_Rect *box)
{ {
int xmin, ymin, xmax, ymax; int xmin, ymin, xmax, ymax;
int foo; int foo;

View File

@ -5,7 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include "tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*

View File

@ -33,6 +33,11 @@ fprintf(stderr, "scale simple: %p (%dx%d) -> %p (%dx%d) k:%d \n",
dst, dst->width, dst->height, k); dst, dst->width, dst->height, k);
#endif #endif
if (k) {
fprintf(stderr, "in %s, k must be zero, was %d\n", __func__, k);
return BAD_PARAMETER;
}
coefX = (float)dst->width / (float)src->width; coefX = (float)dst->width / (float)src->width;
coefY = (float)dst->height / (float)src->height; coefY = (float)dst->height / (float)src->height;
@ -65,8 +70,8 @@ return FUNC_IS_ALPHA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* new 2 nov 2009 - ave StEx */ /* new 2 nov 2009 - ave StEx */
/* I've lost all my mathematical concepts (la vieillesse est un naufrage) /* I've lost all my mathematical concepts so I'm going to make
* so I'm going to make some approximations\dots */ some approximations\dots */
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)
@ -145,6 +150,11 @@ fprintf(stderr, "scale bilinear: %p (%dx%d) -> %p (%dx%d) k:%d \n",
dst, dst->width, dst->height, k); dst, dst->width, dst->height, k);
#endif #endif
if (k) {
fprintf(stderr, "in %s, k must be zero, was %d\n", __func__, k);
return BAD_PARAMETER;
}
coefX = (double)dst->width / (double)src->width; coefX = (double)dst->width / (double)src->width;
coefY = (double)dst->height / (double)src->height; coefY = (double)dst->height / (double)src->height;
@ -152,12 +162,10 @@ coefY = (double)dst->height / (double)src->height;
fprintf(stderr, "%s : coefs %lf %lf\n", __func__, coefX, coefY); fprintf(stderr, "%s : coefs %lf %lf\n", __func__, coefX, coefY);
#endif #endif
for (yd=0; yd<dst->height; yd++) for (yd=0; yd<dst->height; yd++) {
{
fyd = (double)yd; fyd = (double)yd;
fys = fyd / coefY; fys = fyd / coefY;
for (xd=0; xd<dst->width; xd++) for (xd=0; xd<dst->width; xd++) {
{
fxd = (double)xd; fxd = (double)xd;
fxs = fxd / coefX; fxs = fxd / coefX;
@ -199,6 +207,11 @@ fprintf(stderr, "image\t%d %d, scale %f %f\n",
src->width, src->height, scaleX, scaleY); src->width, src->height, scaleX, scaleY);
#endif #endif
if (methode) {
fprintf(stderr, "in %s, methode must be zero, was %d\n", __func__, methode);
return NULL;
}
fx = (float)src->width * scaleX; fx = (float)src->width * scaleX;
fy = (float)src->height * scaleY; fy = (float)src->height * scaleY;
@ -221,6 +234,9 @@ fprintf(stderr, "\tnew image @ %p\n", dst);
#endif #endif
foo = Image_scale_simple(src, dst, 0); foo = Image_scale_simple(src, dst, 0);
if (foo) {
fprintf(stderr, "in %s scale_simple -> %d\n", __func__, foo);
}
return dst; return dst;
} }

View File

@ -25,11 +25,9 @@ int x, y, r, g, b;
memcpy(filtre, Sobel, 11*sizeof(int)); memcpy(filtre, Sobel, 11*sizeof(int));
for (foo=0; foo<4; foo++) for (foo=0; foo<4; foo++) {
{
fprintf(stderr, "sobel4: pass %d\n", foo); fprintf(stderr, "sobel4: pass %d\n", foo);
if (NULL == (tmp[foo] = Image_clone(src, 0))) if (NULL == (tmp[foo] = Image_clone(src, 0))) {
{
fprintf(stderr,"Sobel 4: no memory, aborting\n"); fprintf(stderr,"Sobel 4: no memory, aborting\n");
abort(); abort();
} }
@ -38,10 +36,8 @@ for (foo=0; foo<4; foo++)
Image_rotate_filtre(filtre); Image_rotate_filtre(filtre);
} }
for (x=0; x<src->width; x++) for (x=0; x<src->width; x++) {
{ for (y=0; y<src->height; y++) {
for (y=0; y<src->height; y++)
{
r = ( tmp[0]->Rpix[y][x] + tmp[1]->Rpix[y][x] + r = ( tmp[0]->Rpix[y][x] + tmp[1]->Rpix[y][x] +
tmp[2]->Rpix[y][x] + tmp[3]->Rpix[y][x]) / 4; tmp[2]->Rpix[y][x] + tmp[3]->Rpix[y][x]) / 4;
g = ( tmp[0]->Gpix[y][x] + tmp[1]->Gpix[y][x] + g = ( tmp[0]->Gpix[y][x] + tmp[1]->Gpix[y][x] +
@ -57,8 +53,7 @@ for (x=0; x<src->width; x++)
dst->modified = 1; dst->modified = 1;
for (foo=0; foo<4; foo++) for (foo=0; foo<4; foo++) {
{
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL > 1
fprintf(stderr, "%s: freeing %d\n", __func__, foo); fprintf(stderr, "%s: freeing %d\n", __func__, foo);
#endif #endif
@ -68,6 +63,3 @@ for (foo=0; foo<4; foo++)
return FUNC_NOT_FINISH; return FUNC_NOT_FINISH;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/*::------------------------------------------------------------------::*/
/*::------------------------------------------------------------------::*/

View File

@ -20,20 +20,17 @@ Image_combine_stereo_0(Image_Desc *gauche, Image_Desc *droite,
int x, y, foo; int x, y, foo;
int rouge, vert; int rouge, vert;
if ( (foo=Image_compare_desc(gauche, droite)) ) if ( (foo=Image_compare_desc(gauche, droite)) ) {
{
fprintf(stderr, "Combine Stereo 0: sources are differents (%d)\n", foo); fprintf(stderr, "Combine Stereo 0: sources are differents (%d)\n", foo);
return foo; return foo;
} }
if ( (foo=Image_compare_desc(gauche, stereo)) ) if ( (foo=Image_compare_desc(gauche, stereo)) ) {
{
fprintf(stderr, "Combine Stereo 0: dest have a bad dim (%d)\n", foo); fprintf(stderr, "Combine Stereo 0: dest have a bad dim (%d)\n", foo);
return foo; return foo;
} }
for (y=0; y<gauche->height; y++) for (y=0; y<gauche->height; y++) {
{
for (x=0; x<droite->width; x++) for (x=0; x<droite->width; x++)
{ {
rouge = ( Image_R_pixel(droite, x, y)+ rouge = ( Image_R_pixel(droite, x, y)+
@ -67,13 +64,11 @@ Image_combine_stereo_1(Image_Desc *s1, Image_Desc *s2, Image_Desc *d,
int x, y, foo, cumul; int x, y, foo, cumul;
int rouge, bleu; int rouge, bleu;
if ( (foo=Image_compare_desc(s1, s2)) ) if ( (foo=Image_compare_desc(s1, s2)) ) {
{
fprintf(stderr, "Combine Stereo 1: sources are differents (%d)\n", foo); fprintf(stderr, "Combine Stereo 1: sources are differents (%d)\n", foo);
return foo; return foo;
} }
if ( (foo=Image_compare_desc(s1, d)) ) if ( (foo=Image_compare_desc(s1, d)) ) {
{
fprintf(stderr, "Combine Stereo 1: dest have a bad dim (%d)\n", foo); fprintf(stderr, "Combine Stereo 1: dest have a bad dim (%d)\n", foo);
return foo; return foo;
} }
@ -84,10 +79,8 @@ fprintf(stderr, "Combine Stereo 1: coefs are %d %d %d\n", kr, kg, kb);
fprintf(stderr, "Combine Stereo 1: cumul is %d\n", cumul); fprintf(stderr, "Combine Stereo 1: cumul is %d\n", cumul);
#endif #endif
for (y=0; y<s1->height; y++) for (y=0; y<s1->height; y++) {
{ for (x=0; x<s1->width; x++) {
for (x=0; x<s1->width; x++)
{
rouge = Image_R_pixel(s2, x, y) * kr + rouge = Image_R_pixel(s2, x, y) * kr +
Image_G_pixel(s2, x, y) * kg + Image_G_pixel(s2, x, y) * kg +
Image_B_pixel(s2, x, y) * kb; Image_B_pixel(s2, x, y) * kb;

View File

@ -6,7 +6,7 @@
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
#include "tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int

View File

@ -23,7 +23,7 @@ Image_warp_essai_0(Image_Desc *src, Image_Desc *dst, double angle,
{ {
int x, y, r, g, b; int x, y, r, g, b;
long lfoo; long lfoo;
double arad, dheight, dwidth, tmax, dist, va; double arad, dheight, dwidth, tmax, dist;
int ofx, ofy; int ofx, ofy;
dheight = (double)dst->height; dheight = (double)dst->height;
@ -31,28 +31,23 @@ dwidth = (double)dst->width;
lfoo = ((dst->height*dst->height)+(dst->width*dst->width)); lfoo = ((dst->height*dst->height)+(dst->width*dst->width));
tmax = sqrt((double)lfoo) / 2.0; tmax = sqrt((double)lfoo) / 2.0;
va = angle / 360.0;
#if DEBUG_LEVEL
fprintf(stderr, "%s : %d,%d dh = %f dw = %f tmax = %f\n", __func__, fprintf(stderr, "%s : %d,%d dh = %f dw = %f tmax = %f\n", __func__,
xc, yc, dheight, dwidth, tmax); xc, yc, dheight, dwidth, tmax);
#endif
for (y=0; y<dst->height; y++) for (y=0; y<dst->height; y++) {
{ /* printf("------- Ligne %d -----------------\n", y); */
/*
printf("------- Ligne %d -----------------\n", y);
*/
arad = ((double)y / dheight) * M_PI; arad = ((double)y / dheight) * M_PI;
for (x=0; x<dst->width; x++) for (x=0; x<dst->width; x++) {
{
dist = (double)x / dwidth; dist = (double)x / dwidth;
ofx = xc + (int)(sin(arad)*dist*tmax); ofx = xc + (int)(sin(arad)*dist*tmax);
ofy = yc + (int)(cos(arad)*dist*tmax); ofy = yc + (int)(cos(arad)*dist*tmax);
/* /* printf("%15f %15f %6d %6d\n", arad, dist, ofx, ofy); */
printf("%15f %15f %6d %6d\n", arad, dist, ofx, ofy);
*/
if ( ofx>=0 && ofx<src->width && ofy>=0 && ofy<src->height ) if ( ofx>=0 && ofx<src->width && ofy>=0 && ofy<src->height )
{ {
@ -67,7 +62,7 @@ for (y=0; y<dst->height; y++)
} }
} }
return FUNC_NOT_FINISH; return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int

View File

@ -30,11 +30,9 @@ my = dst->height / 2;
sincalc = sin(arad); sincalc = sin(arad);
coscalc = cos(arad); coscalc = cos(arad);
for (xd=0; xd<dst->width; xd++) for (xd=0; xd<dst->width; xd++) {
{
fxd = (double)(xd-mx); fxd = (double)(xd-mx);
for (yd=0; yd<dst->height; yd++) for (yd=0; yd<dst->height; yd++) {
{
fyd = (double)(yd-my); fyd = (double)(yd-my);
fxs = fxd * coscalc - fyd * sincalc; fxs = fxd * coscalc - fyd * sincalc;
fys = fxd * sincalc + fyd * coscalc; fys = fxd * sincalc + fyd * coscalc;
@ -42,15 +40,14 @@ for (xd=0; xd<dst->width; xd++)
xs = (int)fxs + mx; xs = (int)fxs + mx;
ys = (int)fys + my; ys = (int)fys + my;
if (xs>=0 && xs<src->width && ys>=0 && ys<src->height) if (xs>=0 && xs<src->width && ys>=0 && ys<src->height) {
{
/* Image_getRGB(src, xs, ys, &r, &g, &b); */ /* Image_getRGB(src, xs, ys, &r, &g, &b); */
r = (src->Rpix[ys])[xs]; r = (src->Rpix[ys])[xs];
g = (src->Gpix[ys])[xs]; g = (src->Gpix[ys])[xs];
b = (src->Bpix[ys])[xs]; b = (src->Bpix[ys])[xs];
} }
else else
{ r = g = b = 142; } { r = g = b = 127; }
/* Image_plotRGB(dst, xd, yd, r, g, b); */ /* Image_plotRGB(dst, xd, yd, r, g, b); */
(dst->Rpix[yd])[xd] = r; (dst->Rpix[yd])[xd] = r;
@ -93,11 +90,9 @@ coscalc = cos(arad);
fxs = fys = 0.0; /* ? hein ? */ fxs = fys = 0.0; /* ? hein ? */
foo = 0; foo = 0;
for (xd=0; xd<dst->width; xd++) for (xd=0; xd<dst->width; xd++) {
{
fxd = (double)(xd-mx); fxd = (double)(xd-mx);
for (yd=0; yd<dst->height; yd++) for (yd=0; yd<dst->height; yd++) {
{
fyd = (double)(yd-my); fyd = (double)(yd-my);
@ -106,6 +101,7 @@ for (xd=0; xd<dst->width; xd++)
/* MAIS C'EST PAS ENCORE FINI CE TRUC ? */ /* MAIS C'EST PAS ENCORE FINI CE TRUC ? */
/* 4 mai 2007: ben non, ya rien :) */ /* 4 mai 2007: ben non, ya rien :) */
/* 5 juillet 2022 : toujours pas fait ??? */
return FULL_NUCKED; return FULL_NUCKED;
} }

View File

@ -4,6 +4,7 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <math.h> #include <math.h>
#include "../tthimage.h" #include "../tthimage.h"
@ -19,7 +20,7 @@ int x, y;
int x2, y2, foo; int x2, y2, foo;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "*** Image_shift_xy: work in progress...\n"); fprintf(stderr, "*** %s: work in progress...\n", __func__);
fprintf(stderr, "src=%p dst=%p ox=%d oy=%d\n", src, dst, ox, oy); fprintf(stderr, "src=%p dst=%p ox=%d oy=%d\n", src, dst, ox, oy);
#endif #endif
@ -62,23 +63,55 @@ return FUNC_IS_BETA; /* et elle coredumpe ? */
/* OPTIMIZED FOR SPEED */ /* OPTIMIZED FOR SPEED */
int Image_shift_x(Image_Desc *src, Image_Desc *dst, int ox) int Image_shift_x(Image_Desc *src, Image_Desc *dst, int ox)
{ {
unsigned char *buffer;
int foo, line;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "*** %s : work in progress...\n", __func__); fprintf(stderr, "*** %s : work in progress...\n", __func__);
fprintf(stderr, "%p -> sX(%d) -> %p\n", src, ox, dst); fprintf(stderr, "%p -> sX(%d) -> %p\n", src, ox, dst);
#endif #endif
if ( (foo=Image_compare_desc(src, dst)) )
{
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
return foo;
}
if (NULL==(buffer=malloc(src->width))) {
fprintf(stderr, "%s: malloc(%d) fail.\n", __func__, src->width);
#if MUST_ABORT
abort();
#endif
exit(1);
}
for (line=0; line<src->width; line++) {
/* do something here */
}
free(buffer);
return FULL_NUCKED; return FULL_NUCKED;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* OPTIMIZED FOR SPEED */ /* OPTIMIZED FOR SPEED */
int Image_shift_y(Image_Desc *src, Image_Desc *dst, int oy) int Image_shift_y(Image_Desc *src, Image_Desc *dst, int oy)
{ {
int foo;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "*** %s : work in progress...\n", __func__); fprintf(stderr, "*** %s : work in progress...\n", __func__);
fprintf(stderr, "%p -> sY(%d) -> %p\n", src, oy, dst); fprintf(stderr, "%p -> sY(%d) -> %p\n", src, oy, dst);
#endif #endif
if ( (foo=Image_compare_desc(src, dst)) )
{
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
return foo;
}
return FULL_NUCKED; return FULL_NUCKED;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/

View File

@ -1,5 +1,6 @@
# #
# GLOBAL MAKE CONFIGURATION # GLOBAL MAKE CONFIGURATION
# For the "tTh" image library
# #
DESTDIR=/usr/local DESTDIR=/usr/local
@ -18,9 +19,10 @@ HTML_DIR=$(DESTDIR)/html
# --> see file 'PORTING.txt' for porting tips on misc # --> see file 'PORTING.txt' for porting tips on misc
# architextures (just sparc64 for now) # architextures (just sparc64 for now)
# #
# use -Wmissing-prototypes ?
LIBIMG_OPT=-DFORCE_ABORT=1 -DDEBUG_LEVEL=0 -DIMGCOMMENT=0 LIBIMG_OPT=-DFORCE_ABORT=1 -DDEBUG_LEVEL=0 -DIMGCOMMENT=0
CC_OPTS=-Wall -W -g -ansi -Wmissing-prototypes -fPIC -no-pie CC_OPTS=-Wall -W -g -ansi -O3 -fPIC -no-pie
CC_HACKS=-DNEED_ALLOCA_H CC_HACKS=-DNEED_ALLOCA_H
CFLAGS= $(CC_OPTS) \ CFLAGS= $(CC_OPTS) \
$(LIBIMG_OPT) \ $(LIBIMG_OPT) \

14
Tests/Makefile Normal file
View File

@ -0,0 +1,14 @@
#-----------------------------------------------------------------
include ../Paramakes.mk
DEPS = ../tthimage.h ../Paramakes.mk Makefile
all: t_t16x24
#-----------------------------------------------------------------
t_t16x24: t_t16x24.c $(DEPS) ../libtthimage.a
gcc $(CFLAGS) $< ../libtthimage.a -o $@
#-----------------------------------------------------------------

View File

@ -18,6 +18,10 @@ RGBA encre, papier;
img = Image_TGA_alloc_load(tgasrc); img = Image_TGA_alloc_load(tgasrc);
foo = Image_t16x24_txtload("16x24thin", NULL, 0); foo = Image_t16x24_txtload("16x24thin", NULL, 0);
if (foo) {
fprintf(stderr, "%s err %d loading font '16x24thin'\n", __func__, foo);
return foo;
}
encre.r = 0; encre.g = 255; encre.b = 100; encre.a = 255; encre.r = 0; encre.g = 255; encre.b = 100; encre.a = 255;
papier.r = 255; papier.b = 0; papier.g = 0; papier.a = 200; papier.r = 255; papier.b = 0; papier.g = 0; papier.a = 200;
@ -31,9 +35,7 @@ return -1;
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
char *fichier; int foo;
int foo;
Image_Desc *image;
fprintf(stderr, "-------------- %s ------------\n", argv[0]); fprintf(stderr, "-------------- %s ------------\n", argv[0]);
foo = Image_t16x24_chars_map("16x24thin", "all16x24chars.tga", 0); foo = Image_t16x24_chars_map("16x24thin", "all16x24chars.tga", 0);

View File

@ -39,6 +39,7 @@ La gestion de la ligne de commande est désastreuse. **À REFAIRE**
Pas mal de façons de mettre un cadre sur l'image. Pas mal de façons de mettre un cadre sur l'image.
Niveau de kitchitude assez élevé. Niveau de kitchitude assez élevé.
Paramètres mal documentés.
## tga_combine ## tga_combine

View File

@ -127,7 +127,7 @@ memset(prect, 0, sizeof(Image_Rect));
cptr = strdup(str); cptr = strdup(str);
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stder, "copie dans cptr %p\n", cptr); fprintf(stderr, "copie dans cptr %p\n", cptr);
#endif #endif
idx = 0; idx = 0;
@ -135,6 +135,9 @@ cptr = strtok(cptr, ",");
while (NULL != cptr) { while (NULL != cptr) {
fprintf(stderr, "%3d %p = '%s'\n", idx, cptr, cptr); fprintf(stderr, "%3d %p = '%s'\n", idx, cptr, cptr);
foo = sscanf(cptr, "%d", &val); foo = sscanf(cptr, "%d", &val);
/*
* no error check ?
*/
fprintf(stderr, "val = %d\n", val); fprintf(stderr, "val = %d\n", val);
switch (idx) { switch (idx) {
case 0: prect->x = val; break; case 0: prect->x = val; break;
@ -227,7 +230,7 @@ for (foo=prem, idxt=0; foo<argc; foo++, idxt++)
case 'd': case 'd':
/* the 'd' is for 'double precision', not for 'decimal' */ /* the 'd' is for 'double precision', not for 'decimal' */
if (sscanf(argv[foo], "%lf", &flottant)==1) if (1 == sscanf(argv[foo], "%lf", &flottant))
{ {
params[idxt].type = 'd'; params[idxt].type = 'd';
params[idxt].p.d = flottant; params[idxt].p.d = flottant;
@ -298,8 +301,7 @@ fflush(stdout);
int GIP(int rang) int GIP(int rang)
{ {
if (rang<0 || params[rang].type!='i') if (rang<0 || params[rang].type!='i') {
{
fprintf(stderr, "erreur GIP %d\n", rang); fprintf(stderr, "erreur GIP %d\n", rang);
exit(5); exit(5);
} }
@ -308,8 +310,7 @@ return params[rang].p.i;
int GCP(int rang) int GCP(int rang)
{ {
if (rang<0 || params[rang].type!='c') if (rang<0 || params[rang].type!='c') {
{
fprintf(stderr, "erreur GCP %d\n", rang); fprintf(stderr, "erreur GCP %d\n", rang);
exit(5); exit(5);
} }
@ -322,8 +323,7 @@ int GIPdef(int rang, int def)
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "Warning ! %s is not tested\n", __func__); fprintf(stderr, "Warning ! %s is not tested\n", __func__);
#endif #endif
if (rang<0 || params[rang].type!='i') if (rang<0 || params[rang].type!='i') {
{
return def; return def;
} }
return params[rang].p.i; return params[rang].p.i;
@ -334,8 +334,7 @@ char * GSP(int rang)
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL > 1
fprintf(stderr, "GetStringParameter(%d)\n", rang); fprintf(stderr, "GetStringParameter(%d)\n", rang);
#endif #endif
if (rang<0 || params[rang].type!='s') if (rang<0 || params[rang].type!='s') {
{
fprintf(stderr, "erreur GSP %d\n", rang); fprintf(stderr, "erreur GSP %d\n", rang);
exit(5); exit(5);
} }
@ -347,8 +346,7 @@ return params[rang].p.s;
double GDP(int rang) double GDP(int rang)
{ {
if (rang<0 || params[rang].type!='d') if (rang<0 || params[rang].type!='d') {
{
fprintf(stderr, "erreur GDP %d\n", rang); fprintf(stderr, "erreur GDP %d\n", rang);
exit(5); exit(5);
} }
@ -357,8 +355,7 @@ return params[rang].p.d;
int GFP(int rang) int GFP(int rang)
{ {
if (rang<0 || params[rang].type!='f') if (rang<0 || params[rang].type!='f') {
{
fprintf(stderr, "erreur GFP %d\n", rang); fprintf(stderr, "erreur GFP %d\n", rang);
exit(5); exit(5);
} }
@ -395,8 +392,7 @@ fprintf(stderr, "%s : %s, argc=%d\n", __func__, argv[0], argc);
envvar = getenv(NOM_VAR_ENV_VERBOSE); envvar = getenv(NOM_VAR_ENV_VERBOSE);
if ( (envvar!=NULL) && !strcmp(envvar, "yes") ) flag = 1; if ( (envvar!=NULL) && !strcmp(envvar, "yes") ) flag = 1;
if (flag || force) if (flag || force) {
{
fprintf(stderr, "TGA(%d) %d arg:", getpid(), argc); fprintf(stderr, "TGA(%d) %d arg:", getpid(), argc);
for (foo=0; foo<argc; foo++) for (foo=0; foo<argc; foo++)
fprintf(stderr, " %s", argv[foo]); fprintf(stderr, " %s", argv[foo]);
@ -410,7 +406,7 @@ int set_new_seed(int k)
char *ptr; char *ptr;
long seed; long seed;
/* if (k) fprintf(stderr, "%s: k %d\n", __func__, k); */ if (k) fprintf(stderr, "%s: k %d\n", __func__, k);
if (NULL==(ptr=getenv("FIXED_SEED"))) { if (NULL==(ptr=getenv("FIXED_SEED"))) {
/* no fixed seed in context, doing semi-random */ /* no fixed seed in context, doing semi-random */

View File

@ -17,7 +17,7 @@ fprintf(stderr, " compiled %s at %s\n", __DATE__, __TIME__);
fprintf(stderr, "Usage:\n\ttga_applymap M src.tga color.map dst.tga\n"); fprintf(stderr, "Usage:\n\ttga_applymap M src.tga color.map dst.tga\n");
fprintf(stderr, " M is 1 or 2\n"); fprintf(stderr, " M is 1 or 2\n");
Image_print_version(0); if (flag) Image_print_version(0);
exit(5); exit(5);
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
@ -33,34 +33,29 @@ if (argc==2 && !strcmp(argv[1], "-?")) usage(1);
if (argc != 5) usage(0); if (argc != 5) usage(0);
if ( (src=Image_TGA_alloc_load(argv[2])) == NULL ) if ( (src=Image_TGA_alloc_load(argv[2])) == NULL ) {
{
fprintf(stderr, "can't load '%s'\n", argv[2]); fprintf(stderr, "can't load '%s'\n", argv[2]);
exit(1); exit(1);
} }
if ( (foo=Image_load_color_Map(argv[3], "map", &map)) ) if ( (foo=Image_load_color_Map(argv[3], "map", &map)) ) {
{
fprintf(stderr, "%s: %s: err%d %s\n", argv[0], argv[3], fprintf(stderr, "%s: %s: err%d %s\n", argv[0], argv[3],
foo, Image_err2str(foo)); foo, Image_err2str(foo));
exit(1); exit(1);
} }
if (must_be_verbose()) if (must_be_verbose()) {
{
fprintf(stderr, "il y a %d couleurs dans la palette '%s'\n", fprintf(stderr, "il y a %d couleurs dans la palette '%s'\n",
map.nbre, argv[3]); map.nbre, argv[3]);
} }
if ( (dst=Image_clone(src, 0))==NULL ) if ( (dst=Image_clone(src, 0))==NULL ) {
{
fprintf(stderr, "can't clone %p, exiting...\n", src); fprintf(stderr, "can't clone %p, exiting...\n", src);
exit(2); exit(2);
} }
/* ----------- */ /* ----------- */
switch (argv[1][0]) switch (argv[1][0]) {
{
default: default:
case '1': case '1':
foo=Image_apply_Map(src, dst, &map); foo=Image_apply_Map(src, dst, &map);
@ -74,21 +69,18 @@ switch (argv[1][0])
} }
/* ----------- */ /* ----------- */
if (foo) if (foo) {
{
fprintf(stderr, "%s: apply map: erreur %d: %s\n", fprintf(stderr, "%s: apply map: erreur %d: %s\n",
argv[0], foo, Image_err2str(foo)); argv[0], foo, Image_err2str(foo));
} }
foo = Image_TGA_save(argv[4], dst, 0); foo = Image_TGA_save(argv[4], dst, 0);
if (foo) if (foo) {
{
fprintf(stderr, "%s: TGA_save: err #%d\n\t\t %s\n", fprintf(stderr, "%s: TGA_save: err #%d\n\t\t %s\n",
argv[0], foo, Image_err2str(foo)); argv[0], foo, Image_err2str(foo));
exit(1); exit(1);
} }
fprintf(stderr, "apply map ok\n");
exit (0); exit (0);
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/

View File

@ -34,6 +34,7 @@
#define MIX_WAOU 80 #define MIX_WAOU 80
#define MIX_WAUO 81 #define MIX_WAUO 81
#define MIX_CIRCLE0 84 #define MIX_CIRCLE0 84
#define MIX_CIRCLE1 85 /* new 6 juillet 2022 */
#define MIX_HDEG 100 #define MIX_HDEG 100
#define MIX_VDEG 101 #define MIX_VDEG 101
#define MIX_PROTO 110 #define MIX_PROTO 110
@ -77,6 +78,7 @@ mot_clef les_types[] =
{ "waou", MIX_WAOU, "iiii", h_waou }, { "waou", MIX_WAOU, "iiii", h_waou },
{ "wauo", MIX_WAUO, "i", h_wauo }, { "wauo", MIX_WAUO, "i", h_wauo },
{ "circle0", MIX_CIRCLE0, "i", h_circle0 }, { "circle0", MIX_CIRCLE0, "i", h_circle0 },
{ "circle1", MIX_CIRCLE1, "i", "don't know" },
{ "hdeg", MIX_HDEG, "f", h_deg }, { "hdeg", MIX_HDEG, "f", h_deg },
{ "vdeg", MIX_VDEG, "f", h_deg }, { "vdeg", MIX_VDEG, "f", h_deg },
@ -254,6 +256,10 @@ switch (mode)
case MIX_CIRCLE0: case MIX_CIRCLE0:
foo = Image_combine_cercle_flou(s1, s2, d, 0); foo = Image_combine_cercle_flou(s1, s2, d, 0);
break; break;
case MIX_CIRCLE1:
fprintf(stderr, "pid %d is circle trashing\n", getpid());
foo = Image_combine_cercle_flou(s1, s2, d, 1);
break;
/* FIXME 16 sept 2009 : je pense que hdeg et vdeg sont inverses */ /* FIXME 16 sept 2009 : je pense que hdeg et vdeg sont inverses */
case MIX_HDEG: case MIX_HDEG:

View File

@ -29,6 +29,7 @@
#define EFF_PIXELY 34 /* new 30 mars 2007 */ #define EFF_PIXELY 34 /* new 30 mars 2007 */
#define EFF_FIVE 35 /* new 16 dec 2007 */ #define EFF_FIVE 35 /* new 16 dec 2007 */
#define EFF_WARP_0 36 /* new 17 janv 2015 */ #define EFF_WARP_0 36 /* new 17 janv 2015 */
#define EFF_ROTULACION 37 /* new 6 juillet 2022 */
#define EFF_RECURSE 40 #define EFF_RECURSE 40
#define EFF_RGBMSKH 41 #define EFF_RGBMSKH 41
#define EFF_RGBMSKV 42 #define EFF_RGBMSKV 42
@ -67,6 +68,8 @@ mot_clef mots_clef[] =
{ "gray", EFF_GRAY, "", "" }, { "gray", EFF_GRAY, "", "" },
{ "grayk", EFF_GRAYK, "iii", "3 coefs" }, { "grayk", EFF_GRAYK, "iii", "3 coefs" },
{ "mirror", EFF_MIRROR, "", "" }, { "mirror", EFF_MIRROR, "", "" },
{ "updown", EFF_UPDOWN, "", "upside down" },
{ "rotulacion", EFF_ROTULACION, "d", "angle in degree" },
{ "extrbits0", EFF_EXTRBIT0, "iii", "shifts for r, g & b" }, { "extrbits0", EFF_EXTRBIT0, "iii", "shifts for r, g & b" },
{ "mosaic", EFF_MOSAIC, "", "?" }, { "mosaic", EFF_MOSAIC, "", "?" },
{ "mosaic0", EFF_MOSAIC0, "iif", "?" }, { "mosaic0", EFF_MOSAIC0, "iif", "?" },
@ -74,7 +77,7 @@ mot_clef mots_clef[] =
{ "negate", EFF_NEGATE, "", "" }, { "negate", EFF_NEGATE, "", "" },
{ "seuil", EFF_SEUIL, "iii", "rgb thresholds" }, { "seuil", EFF_SEUIL, "iii", "rgb thresholds" },
{ "degoule", EFF_DEGOULE, "ii", "k1 & k2 ? wtf ?" }, { "degoule", EFF_DEGOULE, "ii", "k1 & k2 ? wtf ?" },
{ "noise", EFF_NOISE, "i", "0..100" }, { "noise", EFF_NOISE, "i", "0..255" },
{ "pixelX", EFF_PIXELX, "", "prototype" }, { "pixelX", EFF_PIXELX, "", "prototype" },
{ "pixelY", EFF_PIXELY, "", "prototype" }, { "pixelY", EFF_PIXELY, "", "prototype" },
{ "efive", EFF_FIVE, "", "got it, code it" }, { "efive", EFF_FIVE, "", "got it, code it" },
@ -93,7 +96,6 @@ mot_clef mots_clef[] =
{ "sinwave1", EFF_SINW1, "dddddd", "strange effect" }, { "sinwave1", EFF_SINW1, "dddddd", "strange effect" },
{ "swapcol", EFF_SWAPCOL, "s", "rg rb bg" }, { "swapcol", EFF_SWAPCOL, "s", "rg rb bg" },
{ "swapnibble", EFF_SWAPNIBBLE, "", "swap all pix nibbles" }, { "swapnibble", EFF_SWAPNIBBLE, "", "swap all pix nibbles" },
{ "updown", EFF_UPDOWN, "", "upside down" },
{ "shift_xy", EFF_SHIFT_XY, "ii", "les deux offsets" }, { "shift_xy", EFF_SHIFT_XY, "ii", "les deux offsets" },
{ "water", EFF_WATER, "i", "'par' is water distance" }, { "water", EFF_WATER, "i", "'par' is water distance" },
/* { "fukung", EFF_FUKUNG, "i", "OMG ! WTF ?" }, */ /* { "fukung", EFF_FUKUNG, "i", "OMG ! WTF ?" }, */
@ -110,18 +112,16 @@ mot_clef mots_clef[] =
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
void usage(int flag) void usage(int flag)
{ {
fprintf(stderr, "*** tga_effects v 0.1.56 [%s] %s\n", fprintf(stderr, "*** tga_effects v 0.1.58 [%s] %s\n",
TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT); TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT);
fprintf(stderr, "\nUsage:\n"); fprintf(stderr, "\nUsage:\n");
fprintf(stderr, "\ttga_effects <src.tga> EFF <dst.tga> [p1] ... [p8]\n"); fprintf(stderr, "\ttga_effects <src.tga> EFF <dst.tga> [p1] ... [p8]\n");
if (flag) if (flag) {
{
Image_print_version(0); Image_print_version(0);
liste_mots_clefs(mots_clef, 42); liste_mots_clefs(mots_clef, 42);
} }
else else {
{
fprintf(stderr, "\ttry 'tga_effects list' for a list.\n"); fprintf(stderr, "\ttry 'tga_effects list' for a list.\n");
} }
exit(5); exit(5);
@ -236,7 +236,7 @@ srand(getpid());
idx = cherche_mot_clef(argv[2], mots_clef, &commande, &nbargs); idx = cherche_mot_clef(argv[2], mots_clef, &commande, &nbargs);
if (idx < 0) if (idx < 0)
{ {
fprintf(stderr, "tga_effects: mot-clef %s inconnu...\n", argv[2]); fprintf(stderr, "tga_effects: mot-clef '%s' inconnu...\n", argv[2]);
exit (5); exit (5);
} }
@ -284,6 +284,11 @@ switch (commande)
case EFF_MIRROR: case EFF_MIRROR:
foo = Image_mirror(src, dst, 0); foo = Image_mirror(src, dst, 0);
break; break;
case EFF_ROTULACION: /* new 6 juillet 2022 */
angle = GDP(0);
fprintf(stderr, "%s: angle rotulacion = %f\n", __FILE__, angle);
foo = Image_center_rotate(src, dst, angle);
break;
case EFF_EXTRBIT0: case EFF_EXTRBIT0:
foo = Image_extrbits_0(src, dst, GIP(0), GIP(1), GIP(2)); foo = Image_extrbits_0(src, dst, GIP(0), GIP(1), GIP(2));
break; break;
@ -326,9 +331,10 @@ switch (commande)
case EFF_WARP_0: case EFF_WARP_0:
angle = 33.5; angle = 33.5;
xc = GIP(1); yc = GIP(2); xc = GIP(1); yc = GIP(2);
fprintf(stderr, "WARP_0 %f %d %d\n", angle, xc, yc);
foo = Image_warp_essai_0(src, dst, angle, xc, yc); foo = Image_warp_essai_0(src, dst, angle, xc, yc);
fprintf(stderr, " -> %d\n", foo); #if DEBUG_LEVEL
fprintf(stderr, "warp0 %f %d %d > %d\n", angle, xc, yc, foo);
#endif
break; break;
case EFF_RECURSE: case EFF_RECURSE:
#if DEBUG_LEVEL #if DEBUG_LEVEL

View File

@ -18,6 +18,7 @@
#define PCX8 60 #define PCX8 60
#define PCX24 61 #define PCX24 61
#define PGMHF 80 #define PGMHF 80
#define TIFF 90
mot_clef mots_clef[] = mot_clef mots_clef[] =
{ {
@ -28,6 +29,7 @@ mot_clef mots_clef[] =
{ "pcx8", PCX8, "i", "plop" }, { "pcx8", PCX8, "i", "plop" },
{ "pcx24", PCX24, "i", "plup" }, { "pcx24", PCX24, "i", "plup" },
{ "pgmhf", PGMHF, "", "height fields for POV" }, { "pgmhf", PGMHF, "", "height fields for POV" },
{ "tiff", TIFF, "", "" },
{ NULL, 0, NULL, NULL } { NULL, 0, NULL, NULL }
}; };
@ -35,13 +37,12 @@ mot_clef mots_clef[] =
void usage(int flag) void usage(int flag)
{ {
fprintf(stderr, "*** tga_export v 0.0.9 [%s] %s\n", fprintf(stderr, "*** tga_export v 0.0.10 [%s] %s\n",
TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT); TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT);
fprintf(stderr, "tga_export source.tga format destination.xxx [params]\n\n"); fprintf(stderr, "tga_export source.tga format destination.xxx [params]\n\n");
if (flag) if (flag) {
{
liste_mots_clefs(mots_clef, 42); liste_mots_clefs(mots_clef, 42);
} }
exit(5); exit(5);
@ -65,13 +66,11 @@ if (argc < 4) usage(1);
/* recherche du type d'exportation demandé */ /* recherche du type d'exportation demandé */
idx = cherche_mot_clef(argv[2], mots_clef, &commande, &nbargs); idx = cherche_mot_clef(argv[2], mots_clef, &commande, &nbargs);
if (idx < 0) if (idx < 0) {
{
fprintf(stderr, "tga_export: format %s inconnu...\n", argv[2]); fprintf(stderr, "tga_export: format %s inconnu...\n", argv[2]);
exit (5); exit (5);
} }
if ( (argc-nbargs) != FIRST_PARAM ) if ( (argc-nbargs) != FIRST_PARAM ) {
{
fprintf(stderr, "%s: bad number of parameters\n", argv[0]); fprintf(stderr, "%s: bad number of parameters\n", argv[0]);
exit(5); exit(5);
} }
@ -79,14 +78,12 @@ if ( (argc-nbargs) != FIRST_PARAM )
/* analyse des paramètres */ /* analyse des paramètres */
foo = parse_parametres(argc, argv, mots_clef[idx].ptypes, FIRST_PARAM); foo = parse_parametres(argc, argv, mots_clef[idx].ptypes, FIRST_PARAM);
if ( (img=Image_TGA_alloc_load(argv[1]))==NULL ) if ( (img=Image_TGA_alloc_load(argv[1]))==NULL ) {
{
fprintf(stderr, "tga_export: can't load '%s'\n", argv[1]); fprintf(stderr, "tga_export: can't load '%s'\n", argv[1]);
exit(5); exit(5);
} }
switch (commande) switch (commande) {
{
case PGM0: case PGM0:
foo = Image_wr_pgm_0(argv[3], img, GCP(0)); foo = Image_wr_pgm_0(argv[3], img, GCP(0));
break; break;
@ -109,10 +106,10 @@ switch (commande)
break; break;
} }
if (foo) if (foo) {
{
fprintf(stderr, "tga_export (%s) ", argv[2]); fprintf(stderr, "tga_export (%s) ", argv[2]);
Image_print_error("ecriture fichier", foo); Image_print_error("ecriture fichier", foo);
exit(1);
} }
return 0; return 0;

View File

@ -39,18 +39,16 @@ mot_clef mots_clef[] =
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
void usage(int flag) void usage(int flag)
{ {
fprintf(stderr, "*** tga_filtres v 0.0.17 [%s] %s\n", fprintf(stderr, "*** tga_filtres v 0.0.18 [%s] %s\n",
TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT); TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT);
fprintf(stderr, "\nUsage:\n"); fprintf(stderr, "\nUsage:\n");
fprintf(stderr, "\ttga_filtres <src.tga> FILTR <dst.tga> [p1] ... [pn]\n"); fprintf(stderr, "\ttga_filtres <src.tga> FILTR <dst.tga> [p1] ... [pn]\n");
if (flag) if (flag) {
{
Image_print_version(0); Image_print_version(0);
liste_mots_clefs(mots_clef, 42); liste_mots_clefs(mots_clef, 42);
} }
else else {
{
fprintf(stderr, "\ttry 'tga_filtres list' for a list.\n"); fprintf(stderr, "\ttry 'tga_filtres list' for a list.\n");
} }
exit(5); exit(5);
@ -77,8 +75,7 @@ srand(getpid());
/* recherche du type d'effet demandé */ /* recherche du type d'effet demandé */
idx = cherche_mot_clef(argv[2], mots_clef, &commande, &nbargs); idx = cherche_mot_clef(argv[2], mots_clef, &commande, &nbargs);
if (idx < 0) if (idx < 0) {
{
fprintf(stderr, "tga_filtres: mot-clef %s inconnu...\n", argv[2]); fprintf(stderr, "tga_filtres: mot-clef %s inconnu...\n", argv[2]);
exit (5); exit (5);
} }
@ -88,8 +85,7 @@ fprintf(stderr, "%s --> idx=%d, commande=%d, %d args\n",
fprintf(stderr, "argc = %d\n", argc); fprintf(stderr, "argc = %d\n", argc);
#endif #endif
if ( (argc-nbargs) != FIRST_PARAM ) if ( (argc-nbargs) != FIRST_PARAM ) {
{
fprintf(stderr, "%s: bad number of parameters\n", argv[0]); fprintf(stderr, "%s: bad number of parameters\n", argv[0]);
exit(5); exit(5);
} }
@ -97,14 +93,12 @@ if ( (argc-nbargs) != FIRST_PARAM )
/* analyse des paramètres */ /* analyse des paramètres */
foo = parse_parametres(argc, argv, mots_clef[idx].ptypes, FIRST_PARAM); foo = parse_parametres(argc, argv, mots_clef[idx].ptypes, FIRST_PARAM);
if ((src = Image_TGA_alloc_load(argv[1]))==NULL) if ((src = Image_TGA_alloc_load(argv[1]))==NULL) {
{
fprintf(stderr, "tga_filtres: can't load image %s\n", argv[1]); fprintf(stderr, "tga_filtres: can't load image %s\n", argv[1]);
exit(5); exit(5);
} }
if ( (dst=Image_clone(src, 0)) == NULL ) if ( (dst=Image_clone(src, 0)) == NULL ) {
{
fprintf(stderr, "tga_filtres: can't clone %p\n", src); fprintf(stderr, "tga_filtres: can't clone %p\n", src);
exit(1); exit(1);
} }
@ -145,9 +139,10 @@ switch (commande)
break; break;
} }
if (foo) if (foo) {
Image_print_error("filtrage ", foo); Image_print_error("tga_filtres ", foo);
exit(1);
}
foo = Image_TGA_save(argv[3], dst, 0); foo = Image_TGA_save(argv[3], dst, 0);
return 0; return 0;

View File

@ -84,13 +84,11 @@ if (must_be_verbose())
#endif #endif
idx = cherche_mot_clef(argv[3], mots_clef, &commande, &nbargs); idx = cherche_mot_clef(argv[3], mots_clef, &commande, &nbargs);
if (idx < 0) if (idx < 0) {
{
fprintf(stderr, "tga_incrust: mot-clef '%s' inconnu...\n", argv[3]); fprintf(stderr, "tga_incrust: mot-clef '%s' inconnu...\n", argv[3]);
exit (5); exit (5);
} }
if ( (argc-nbargs) != FIRST_PARAM ) if ( (argc-nbargs) != FIRST_PARAM ) {
{
fprintf(stderr, "%s: bad number of parameters\n", argv[0]); fprintf(stderr, "%s: bad number of parameters\n", argv[0]);
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "argc=%d nbargs=%d FIRST_PARAM=%d\n", fprintf(stderr, "argc=%d nbargs=%d FIRST_PARAM=%d\n",
@ -106,14 +104,12 @@ foo = parse_parametres(argc, argv, mots_clef[idx].ptypes, FIRST_PARAM);
fprintf(stderr, "parse params -> %d\n", foo); fprintf(stderr, "parse params -> %d\n", foo);
#endif #endif
if (NULL==(where=Image_TGA_alloc_load(argv[1]))) if (NULL==(where=Image_TGA_alloc_load(argv[1]))) {
{
fprintf(stderr, "can't load %s\n", argv[1]); fprintf(stderr, "can't load %s\n", argv[1]);
exit(2); exit(2);
} }
if (NULL==(what=Image_TGA_alloc_load(argv[2]))) if (NULL==(what=Image_TGA_alloc_load(argv[2]))) {
{
fprintf(stderr, "can't load %s\n", argv[2]); fprintf(stderr, "can't load %s\n", argv[2]);
exit(2); exit(2);
} }
@ -134,8 +130,7 @@ switch (commande)
Image_DeAllocate(what); free(what); Image_DeAllocate(what); free(what);
foo = Image_TGA_save(argv[4], where, 0); foo = Image_TGA_save(argv[4], where, 0);
if (foo) if (foo) {
{
fprintf(stderr, "save -> %d\n", foo); fprintf(stderr, "save -> %d\n", foo);
} }
Image_DeAllocate(where); free(where); Image_DeAllocate(where); free(where);

View File

@ -11,3 +11,8 @@ cd Tools
echo "========== in $PWD" echo "========== in $PWD"
make make
cd .. cd ..
cd Tests
echo "========== in $PWD"
make
cd ..

View File

@ -4,7 +4,7 @@
http:///la.buvette.org/devel/libimage/ http:///la.buvette.org/devel/libimage/
*/ */
#ifndef IMAGE_VERSION_STRING #ifndef IMAGE_VERSION_STRING
#define IMAGE_VERSION_STRING "0.4.51 pl 8" #define IMAGE_VERSION_STRING "0.4.51 pl 16"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*