Compare commits
105 Commits
01e6b0103f
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
58b8fa878c | ||
|
|
d298f63e7e | ||
|
|
0b8cf14126 | ||
|
|
b3da0e6ec0 | ||
|
|
97ad716bd2 | ||
|
|
ae54fb932a | ||
|
|
5418e01820 | ||
|
|
24b3d4de11 | ||
|
|
5ffc94c17d | ||
|
|
6fddb97ee4 | ||
|
|
725ccf3c87 | ||
|
|
f4c3825186 | ||
|
|
d6877097d0 | ||
|
|
8c30ea844f | ||
|
|
82a7050d07 | ||
|
|
1b442ece82 | ||
|
|
1750225cf9 | ||
|
|
8a163578ad | ||
|
|
a01eebd240 | ||
|
|
65f396bedd | ||
|
|
402c80962a | ||
|
|
3a3311647b | ||
|
|
d6632ade7e | ||
|
|
38173616ba | ||
|
|
ce04418ef1 | ||
|
|
e2b830b537 | ||
|
|
1762a35868 | ||
|
|
acb36a45b3 | ||
|
|
4a3f107263 | ||
|
|
cd5f42b76e | ||
|
|
0b094bf7b8 | ||
|
|
7e09d1b490 | ||
|
|
5b2320b421 | ||
|
|
e3347cb775 | ||
|
|
ee6a416f9e | ||
|
|
43368bf900 | ||
|
|
4f41ae399b | ||
|
|
7aab0e030a | ||
|
|
e841207907 | ||
|
|
53a108561f | ||
|
|
8d36957956 | ||
|
|
b367f42b9e | ||
|
|
b264cffb02 | ||
|
|
449705c0ee | ||
|
|
d9d2db45b0 | ||
|
|
96ddcfccaf | ||
|
|
ff4b7acff8 | ||
|
|
dda374fc7d | ||
|
|
0c17de9f93 | ||
|
|
b9102e2991 | ||
|
|
298643ede5 | ||
|
|
86cb7eaa4a | ||
|
|
2246a5d744 | ||
|
|
56941f1215 | ||
|
|
39903d1067 | ||
|
|
a67809b4e8 | ||
|
|
378a1046a0 | ||
|
|
4ab69cced3 | ||
|
|
9ca6acd176 | ||
|
|
8fae30abc7 | ||
|
|
54e6a7e58a | ||
|
|
32fc223f2c | ||
|
|
6744a631c1 | ||
|
|
cced0a8811 | ||
|
|
56250127bc | ||
|
|
2594cabf94 | ||
|
|
21de0960e8 | ||
|
|
d09291bd4e | ||
|
|
7b0384a3b7 | ||
|
|
ba7ba3d666 | ||
|
|
806c9b0071 | ||
|
|
7b10854729 | ||
|
|
226d1b39a9 | ||
|
|
3f1f5fc49b | ||
|
|
5f61f21362 | ||
|
|
7977766a52 | ||
|
|
907f538cff | ||
|
|
42fafdc570 | ||
|
|
395b262c92 | ||
|
|
bef1c6c5e3 | ||
|
|
d260117865 | ||
|
|
ca0acf0c26 | ||
|
|
15124ad892 | ||
|
|
00e796bf5e | ||
|
|
c1c954100e | ||
|
|
35e5947fdb | ||
|
|
5f80203592 | ||
|
|
d5d9aa8c43 | ||
|
|
2c4612411b | ||
|
|
f70037a143 | ||
|
|
4efe885d9a | ||
|
|
ca9947e7cc | ||
|
|
63b0bce081 | ||
|
|
2f1f51671c | ||
|
|
7679fabae9 | ||
|
|
5bee2ac73c | ||
|
|
c73a361120 | ||
|
|
a4e3d073f5 | ||
|
|
1175eece63 | ||
|
|
5510569f8b | ||
|
|
1d1336fd96 | ||
|
|
8e9f083aa9 | ||
|
|
bd1b329029 | ||
|
|
dec52079cd | ||
|
|
20754c17e9 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -3,6 +3,7 @@
|
||||
|
||||
libtthimage.a
|
||||
cscope.out
|
||||
gmon.out
|
||||
|
||||
Lib/foo
|
||||
Lib/testtga
|
||||
|
||||
16
Contribs/ExplodeVidz.md
Normal file
16
Contribs/ExplodeVidz.md
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
# Exploding Vidz for fun and profit.
|
||||
|
||||
But du jeu : traiter la séquence d'image complète d'une vidéo live,
|
||||
sans devoir attendre 107 ans que le job soit fait.
|
||||
|
||||
## Current status
|
||||
|
||||
- [rgb_decomp.c](rgb_decomp.c)
|
||||
|
||||
## Film at 11.
|
||||
|
||||
See you soon.
|
||||
|
||||
|
||||
|
||||
9
Contribs/README.md
Normal file
9
Contribs/README.md
Normal file
@@ -0,0 +1,9 @@
|
||||
|
||||
# Contributions
|
||||
|
||||
Voici une collection informelle de fonctions diverses et variées contribuées
|
||||
par moi-même (et peut-être, un jour, d'autres gens...) et qui risquent
|
||||
bien de n'être **pas très maintenues**, contrairement au reste du *kluge*.
|
||||
|
||||
Nous allons commencer par des fonctions inventées lors d'une *n*-ième session
|
||||
du projet [ExplodeVidz](ExplodeVidz.md).
|
||||
87
Contribs/rgb_decomp.c
Normal file
87
Contribs/rgb_decomp.c
Normal file
@@ -0,0 +1,87 @@
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/resource.h>
|
||||
|
||||
#include <tthimage.h>
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
|
||||
int rgb_process_by_filename(char *inf, char *outf)
|
||||
{
|
||||
Image_Desc *src, *dst;
|
||||
int foo;
|
||||
int x, y, larg, offs;
|
||||
int r, g, b;
|
||||
|
||||
if ( (src=Image_TGA_alloc_load(inf)) == NULL )
|
||||
{
|
||||
fprintf(stderr, "%s: err load %s\n", __func__, inf);
|
||||
exit(5);
|
||||
}
|
||||
|
||||
printf("source '%s' %dx%d\n", inf, src->width, src->height);
|
||||
|
||||
if ( (dst=Image_clone(src, 0)) == NULL )
|
||||
{
|
||||
fprintf(stderr, "%s: no mem for image cloning\n", __func__);
|
||||
exit(5);
|
||||
}
|
||||
|
||||
Image_clear(dst, 160, 60, 60);
|
||||
|
||||
/*
|
||||
* calcul de la zone à traiter
|
||||
*/
|
||||
larg = src->width / 3;
|
||||
offs = (src->width - larg) / 2;
|
||||
printf("largeur %d offset %d\n", larg, offs);
|
||||
|
||||
|
||||
for (y=0; y<src->height; y++) {
|
||||
for (x=0; x<larg; x++) {
|
||||
|
||||
Image_getRGB(src, x+offs, y, &r, &g, &b);
|
||||
|
||||
Image_plotRGB(dst, x, y, r, r, r);
|
||||
Image_plotRGB(dst, x+offs, y, g, g, g);
|
||||
Image_plotRGB(dst, x+(2*offs), y, b, b, b);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Image_egalise_cos010(dst, dst, 0);
|
||||
|
||||
foo = Image_TGA_save(outf, dst, 0);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s: error %d saving %s\n", __func__, foo, outf);
|
||||
exit(5);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int foo;
|
||||
|
||||
if (3 != argc)
|
||||
{
|
||||
exit(1);
|
||||
}
|
||||
|
||||
foo = rgb_process_by_filename(argv[1], argv[2]);
|
||||
if (foo) {
|
||||
fprintf(stderr, "process by filename -> %d\n", foo);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
702
Datas/16x24gruik
Normal file
702
Datas/16x24gruik
Normal file
@@ -0,0 +1,702 @@
|
||||
32
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
33
|
||||
................
|
||||
................
|
||||
................
|
||||
......**........
|
||||
.....****.......
|
||||
....******......
|
||||
.....****.......
|
||||
.....****.......
|
||||
.....***........
|
||||
.....***........
|
||||
......**........
|
||||
......**........
|
||||
......**........
|
||||
......**........
|
||||
......**........
|
||||
......**........
|
||||
.......*........
|
||||
................
|
||||
.....****.......
|
||||
....**..**......
|
||||
....**..**......
|
||||
.....****.......
|
||||
................
|
||||
................
|
||||
34
|
||||
................
|
||||
...**......**...
|
||||
...***....***...
|
||||
...**......**...
|
||||
...**......**...
|
||||
...*........*...
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
35
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
43
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
.....*****......
|
||||
......***.......
|
||||
.......*........
|
||||
.......**.......
|
||||
......***.......
|
||||
..*..******..*..
|
||||
..************..
|
||||
..*..******.....
|
||||
.......**.......
|
||||
.......**.......
|
||||
.......**.......
|
||||
......****......
|
||||
...*********....
|
||||
................
|
||||
................
|
||||
................
|
||||
44
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
......**........
|
||||
......**........
|
||||
.....**.........
|
||||
....**..........
|
||||
46
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
......***.......
|
||||
.....**.**......
|
||||
.....*.*.*......
|
||||
......***.......
|
||||
................
|
||||
................
|
||||
48
|
||||
................
|
||||
..************..
|
||||
..************..
|
||||
................
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
................
|
||||
..************..
|
||||
..************..
|
||||
................
|
||||
55
|
||||
................
|
||||
..************..
|
||||
..************..
|
||||
................
|
||||
.............**.
|
||||
.............**.
|
||||
.............**.
|
||||
.............**.
|
||||
.............**.
|
||||
.............**.
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
.............**.
|
||||
.............**.
|
||||
.............**.
|
||||
.............**.
|
||||
.............**.
|
||||
.............**.
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
56
|
||||
................
|
||||
..************..
|
||||
..************..
|
||||
................
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
................
|
||||
..************..
|
||||
..************..
|
||||
................
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
................
|
||||
..************..
|
||||
..************..
|
||||
................
|
||||
57
|
||||
................
|
||||
..************..
|
||||
..************..
|
||||
................
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
.**..........**.
|
||||
................
|
||||
..************..
|
||||
..************..
|
||||
................
|
||||
.............**.
|
||||
.............**.
|
||||
.............**.
|
||||
.............**.
|
||||
.............**.
|
||||
.............**.
|
||||
................
|
||||
..************..
|
||||
..************..
|
||||
................
|
||||
60
|
||||
................
|
||||
................
|
||||
................
|
||||
..........**....
|
||||
.........***....
|
||||
........**......
|
||||
.......**.......
|
||||
......**........
|
||||
.....**.........
|
||||
....**..........
|
||||
...**...........
|
||||
..***...........
|
||||
...**...........
|
||||
....**..........
|
||||
.....**.........
|
||||
......**........
|
||||
.......**.......
|
||||
........**......
|
||||
.........***....
|
||||
..........**....
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
77
|
||||
..****......****
|
||||
..****......****
|
||||
..****......****
|
||||
..**..**..**..**
|
||||
..**..**..**..**
|
||||
..**..**..**..**
|
||||
..**....**....**
|
||||
..**....**....**
|
||||
..**....**....**
|
||||
..**..........**
|
||||
..**..........**
|
||||
..**..........**
|
||||
..**..........**
|
||||
..**..........**
|
||||
..**..........**
|
||||
..**..........**
|
||||
..**..........**
|
||||
..**..........**
|
||||
..**..........**
|
||||
..**..........**
|
||||
..**..........**
|
||||
................
|
||||
................
|
||||
................
|
||||
80
|
||||
................
|
||||
..**********....
|
||||
..**********....
|
||||
....**......**..
|
||||
....**......**..
|
||||
....**.......*..
|
||||
....**......R...
|
||||
....**......**..
|
||||
....**......*...
|
||||
....**....**....
|
||||
....********....
|
||||
....****........
|
||||
....**..........
|
||||
....**..........
|
||||
.....*..........
|
||||
.....*..........
|
||||
....**..........
|
||||
....**..........
|
||||
...***..........
|
||||
..*****.........
|
||||
..*...**........
|
||||
................
|
||||
................
|
||||
................
|
||||
83
|
||||
................
|
||||
.......**.......
|
||||
....********....
|
||||
..**........**..
|
||||
..**........**..
|
||||
..**........**..
|
||||
..**............
|
||||
..**............
|
||||
..**............
|
||||
....***.........
|
||||
......****......
|
||||
.........***....
|
||||
............**..
|
||||
............**..
|
||||
............**..
|
||||
..**........**..
|
||||
..**........**..
|
||||
..**........**..
|
||||
....********....
|
||||
........**......
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
84
|
||||
................
|
||||
................
|
||||
................
|
||||
..************..
|
||||
..************..
|
||||
..**...**...**..
|
||||
..*....**....*..
|
||||
.......**.......
|
||||
.......**.......
|
||||
.......**.......
|
||||
......**........
|
||||
......**........
|
||||
......**........
|
||||
.......**.......
|
||||
........**......
|
||||
........**......
|
||||
.......**.......
|
||||
.......**.......
|
||||
.......**.......
|
||||
.......**.......
|
||||
......***.......
|
||||
....******..*...
|
||||
...**********...
|
||||
................
|
||||
85
|
||||
................
|
||||
................
|
||||
................
|
||||
..****....****..
|
||||
..***......***..
|
||||
..**........**..
|
||||
..**........**..
|
||||
..**........**..
|
||||
..**........**..
|
||||
..**........**..
|
||||
.**..........**.
|
||||
.**.........**..
|
||||
..**.......**...
|
||||
..**.......**...
|
||||
..**.......**...
|
||||
..**.......**...
|
||||
..**.......**...
|
||||
..***.....***...
|
||||
...***...***....
|
||||
...*********....
|
||||
....******......
|
||||
................
|
||||
................
|
||||
................
|
||||
97
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
....*******.....
|
||||
...**......*....
|
||||
...........**...
|
||||
...........*....
|
||||
...********.....
|
||||
..**.......**...
|
||||
..**.......**...
|
||||
..**.......**...
|
||||
..**.......**...
|
||||
..**......**....
|
||||
...*******.**...
|
||||
................
|
||||
................
|
||||
................
|
||||
101
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
....******......
|
||||
...********.....
|
||||
..**.......**...
|
||||
..**.......**...
|
||||
..**......**....
|
||||
...********.....
|
||||
..**............
|
||||
..**............
|
||||
..**............
|
||||
...**...........
|
||||
...***.....**...
|
||||
.....******.....
|
||||
................
|
||||
................
|
||||
................
|
||||
104
|
||||
................
|
||||
................
|
||||
................
|
||||
...****.........
|
||||
...****.........
|
||||
...***..........
|
||||
....**..........
|
||||
....**..........
|
||||
....**..........
|
||||
....**..........
|
||||
....**..........
|
||||
....**..........
|
||||
....**..........
|
||||
....**..**......
|
||||
....********....
|
||||
....**.....**...
|
||||
....**.....**...
|
||||
...**......**...
|
||||
...**......**...
|
||||
....**.....**...
|
||||
...****...***...
|
||||
................
|
||||
................
|
||||
................
|
||||
105
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
......**........
|
||||
....*****.......
|
||||
.....***........
|
||||
................
|
||||
................
|
||||
................
|
||||
.....*****......
|
||||
......**........
|
||||
......**........
|
||||
......*.........
|
||||
.....**.........
|
||||
......**........
|
||||
......**........
|
||||
......**........
|
||||
.....***........
|
||||
...*******......
|
||||
................
|
||||
................
|
||||
................
|
||||
111
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
.....******.....
|
||||
....**.....*....
|
||||
...**......**...
|
||||
...**......**...
|
||||
...**......**...
|
||||
....**.....**...
|
||||
.....**...**....
|
||||
......****......
|
||||
................
|
||||
................
|
||||
................
|
||||
112
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
...**...........
|
||||
..****..****....
|
||||
...***..****....
|
||||
....****....**..
|
||||
.....***....**..
|
||||
.....***....**..
|
||||
.....***....**..
|
||||
.....***....**..
|
||||
....****....**..
|
||||
....**..****....
|
||||
....**..****....
|
||||
....**...**.....
|
||||
....**..........
|
||||
....**..........
|
||||
....**..........
|
||||
..******........
|
||||
..******........
|
||||
..******........
|
||||
|
||||
116
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
....***.........
|
||||
....**..........
|
||||
....**..........
|
||||
....**..........
|
||||
....**..........
|
||||
...*********....
|
||||
...***....**....
|
||||
....**..........
|
||||
....**..........
|
||||
....**..........
|
||||
....**..........
|
||||
....**..........
|
||||
....**..........
|
||||
....**..........
|
||||
....***.........
|
||||
.....***....***.
|
||||
......*******...
|
||||
........***.....
|
||||
................
|
||||
................
|
||||
117
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
..***.....***...
|
||||
..**.......**...
|
||||
..**.......**...
|
||||
..**.......**...
|
||||
..**.......**...
|
||||
..**.......**...
|
||||
..**.......**...
|
||||
...**.....**....
|
||||
....*******.....
|
||||
.....****.......
|
||||
................
|
||||
................
|
||||
................
|
||||
118
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
.***.......***..
|
||||
..**.......**...
|
||||
..**.......**...
|
||||
...**......**...
|
||||
...**.....**....
|
||||
....**....**....
|
||||
....**...**.....
|
||||
.....**.**......
|
||||
......***.......
|
||||
.......*........
|
||||
................
|
||||
................
|
||||
................
|
||||
120
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
..***.......***.
|
||||
...**......**...
|
||||
....**....**....
|
||||
.....**..**.....
|
||||
......****......
|
||||
.....**..**.....
|
||||
....**....**....
|
||||
...**......**...
|
||||
..***......***..
|
||||
................
|
||||
................
|
||||
................
|
||||
121
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
................
|
||||
..**........**..
|
||||
..**........**..
|
||||
..**.......***..
|
||||
..**.......**...
|
||||
..**.......***..
|
||||
..**........**..
|
||||
..**........**..
|
||||
..**........**..
|
||||
....**********..
|
||||
....**********..
|
||||
........******..
|
||||
............**..
|
||||
............**..
|
||||
............**..
|
||||
.....********...
|
||||
..**********....
|
||||
......****......
|
||||
|
||||
BIN
Datas/8x8std
Normal file
BIN
Datas/8x8std
Normal file
Binary file not shown.
BIN
Datas/8x8thin
Normal file
BIN
Datas/8x8thin
Normal file
Binary file not shown.
256
Datas/neon.map
Normal file
256
Datas/neon.map
Normal file
@@ -0,0 +1,256 @@
|
||||
0 0 0 A flashy map ... by D. Egnor
|
||||
0 0 0
|
||||
8 0 0
|
||||
16 4 4
|
||||
24 4 8
|
||||
32 8 12
|
||||
40 12 16
|
||||
48 12 20
|
||||
56 16 24
|
||||
64 20 28
|
||||
72 20 32
|
||||
80 24 36
|
||||
88 28 40
|
||||
96 28 44
|
||||
104 32 48
|
||||
112 36 52
|
||||
120 36 56
|
||||
128 40 60
|
||||
136 40 64
|
||||
144 44 68
|
||||
152 48 72
|
||||
160 48 76
|
||||
168 52 80
|
||||
176 56 84
|
||||
184 56 88
|
||||
192 60 92
|
||||
200 64 96
|
||||
208 64 100
|
||||
216 68 104
|
||||
224 72 108
|
||||
232 72 112
|
||||
240 76 116
|
||||
252 80 120
|
||||
248 80 120
|
||||
240 76 116
|
||||
232 76 112
|
||||
224 72 108
|
||||
216 68 104
|
||||
208 68 100
|
||||
200 64 96
|
||||
192 60 92
|
||||
184 60 88
|
||||
176 56 84
|
||||
168 56 80
|
||||
160 52 76
|
||||
152 48 72
|
||||
144 48 68
|
||||
136 44 64
|
||||
128 40 60
|
||||
120 40 60
|
||||
112 36 56
|
||||
104 36 52
|
||||
96 32 48
|
||||
88 28 44
|
||||
80 28 40
|
||||
72 24 36
|
||||
64 20 32
|
||||
56 20 28
|
||||
48 16 24
|
||||
40 16 20
|
||||
32 12 16
|
||||
24 8 12
|
||||
16 8 8
|
||||
8 4 4
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 4 0
|
||||
0 12 0
|
||||
0 20 0
|
||||
0 28 0
|
||||
0 36 0
|
||||
0 44 0
|
||||
0 52 0
|
||||
0 60 0
|
||||
0 68 0
|
||||
0 76 0
|
||||
0 84 0
|
||||
0 92 0
|
||||
0 100 0
|
||||
0 108 0
|
||||
0 116 0
|
||||
0 124 0
|
||||
0 132 0
|
||||
0 140 0
|
||||
0 148 0
|
||||
0 156 0
|
||||
0 164 0
|
||||
0 172 0
|
||||
0 180 0
|
||||
0 188 0
|
||||
0 196 0
|
||||
0 204 0
|
||||
0 212 0
|
||||
0 220 0
|
||||
0 228 0
|
||||
0 236 0
|
||||
0 244 0
|
||||
0 252 0
|
||||
0 248 0
|
||||
0 240 0
|
||||
0 232 0
|
||||
0 224 0
|
||||
0 216 0
|
||||
0 208 0
|
||||
0 200 0
|
||||
0 192 0
|
||||
0 184 0
|
||||
0 176 0
|
||||
0 168 0
|
||||
0 160 0
|
||||
0 152 0
|
||||
0 144 0
|
||||
0 136 0
|
||||
0 128 0
|
||||
0 120 0
|
||||
0 112 0
|
||||
0 104 0
|
||||
0 96 0
|
||||
0 88 0
|
||||
0 80 0
|
||||
0 72 0
|
||||
0 64 0
|
||||
0 56 0
|
||||
0 48 0
|
||||
0 40 0
|
||||
0 32 0
|
||||
0 24 0
|
||||
0 16 0
|
||||
0 8 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
4 4 0
|
||||
12 12 0
|
||||
20 20 0
|
||||
28 28 0
|
||||
36 36 0
|
||||
44 44 0
|
||||
52 52 0
|
||||
60 60 0
|
||||
68 68 0
|
||||
76 76 0
|
||||
84 84 0
|
||||
92 92 0
|
||||
100 100 0
|
||||
108 108 0
|
||||
116 116 0
|
||||
124 124 0
|
||||
132 132 0
|
||||
140 140 0
|
||||
148 148 0
|
||||
156 156 0
|
||||
164 164 0
|
||||
172 172 0
|
||||
180 180 0
|
||||
188 188 0
|
||||
196 196 0
|
||||
204 204 0
|
||||
212 212 0
|
||||
220 220 0
|
||||
228 228 0
|
||||
236 236 0
|
||||
244 244 0
|
||||
252 252 0
|
||||
248 248 0
|
||||
240 240 0
|
||||
232 232 0
|
||||
224 224 0
|
||||
216 216 0
|
||||
208 208 0
|
||||
200 200 0
|
||||
192 192 0
|
||||
184 184 0
|
||||
176 176 0
|
||||
168 168 0
|
||||
160 160 0
|
||||
152 152 0
|
||||
144 144 0
|
||||
136 136 0
|
||||
128 128 0
|
||||
120 120 0
|
||||
112 112 0
|
||||
104 104 0
|
||||
96 96 0
|
||||
88 88 0
|
||||
80 80 0
|
||||
72 72 0
|
||||
64 64 0
|
||||
56 56 0
|
||||
48 48 0
|
||||
40 40 0
|
||||
32 32 0
|
||||
24 24 0
|
||||
16 16 0
|
||||
8 8 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
0 0 0
|
||||
97
Datas/primaires.map
Normal file
97
Datas/primaires.map
Normal file
@@ -0,0 +1,97 @@
|
||||
0 0 0
|
||||
0 0 16
|
||||
0 0 32
|
||||
0 0 48
|
||||
0 0 64
|
||||
0 0 80
|
||||
0 0 96
|
||||
0 0 112
|
||||
0 0 128
|
||||
0 0 144
|
||||
0 0 160
|
||||
0 0 176
|
||||
0 0 192
|
||||
0 0 208
|
||||
0 0 224
|
||||
0 0 240
|
||||
0 0 255
|
||||
16 0 0
|
||||
32 0 0
|
||||
48 0 0
|
||||
64 0 0
|
||||
80 0 0
|
||||
96 0 0
|
||||
112 0 0
|
||||
128 0 0
|
||||
144 0 0
|
||||
160 0 0
|
||||
176 0 0
|
||||
192 0 0
|
||||
208 0 0
|
||||
224 0 0
|
||||
240 0 0
|
||||
255 0 0
|
||||
0 16 0
|
||||
0 32 0
|
||||
0 48 0
|
||||
0 64 0
|
||||
0 80 0
|
||||
0 96 0
|
||||
0 112 0
|
||||
0 128 0
|
||||
0 144 0
|
||||
0 160 0
|
||||
0 176 0
|
||||
0 192 0
|
||||
0 208 0
|
||||
0 224 0
|
||||
0 240 0
|
||||
0 255 0
|
||||
0 16 16
|
||||
0 32 32
|
||||
0 48 48
|
||||
0 64 64
|
||||
0 80 80
|
||||
0 96 96
|
||||
0 112 112
|
||||
0 128 128
|
||||
0 144 144
|
||||
0 160 160
|
||||
0 176 176
|
||||
0 192 192
|
||||
0 208 208
|
||||
0 224 224
|
||||
0 240 240
|
||||
0 255 255
|
||||
16 0 16
|
||||
32 0 32
|
||||
48 0 48
|
||||
64 0 64
|
||||
80 0 80
|
||||
96 0 96
|
||||
112 0 112
|
||||
128 0 128
|
||||
144 0 144
|
||||
160 0 160
|
||||
176 0 176
|
||||
192 0 192
|
||||
208 0 208
|
||||
224 0 224
|
||||
240 0 240
|
||||
255 0 255
|
||||
16 16 0
|
||||
32 32 0
|
||||
48 48 0
|
||||
64 64 0
|
||||
80 80 0
|
||||
96 96 0
|
||||
112 112 0
|
||||
128 128 0
|
||||
144 144 0
|
||||
160 160 0
|
||||
176 176 0
|
||||
192 192 0
|
||||
208 208 0
|
||||
224 224 0
|
||||
240 240 0
|
||||
255 255 0
|
||||
256
Datas/volcano.map
Normal file
256
Datas/volcano.map
Normal file
@@ -0,0 +1,256 @@
|
||||
0 0 0 An explosion of lava ... by D. Egnor
|
||||
60 60 60
|
||||
64 60 60
|
||||
72 60 60
|
||||
76 56 56
|
||||
84 56 56
|
||||
88 52 52
|
||||
96 52 52
|
||||
100 48 48
|
||||
108 48 48
|
||||
112 44 44
|
||||
120 44 44
|
||||
128 40 40
|
||||
132 40 40
|
||||
140 36 36
|
||||
144 36 36
|
||||
152 32 32
|
||||
156 32 32
|
||||
164 28 28
|
||||
168 28 28
|
||||
176 24 24
|
||||
180 24 24
|
||||
188 20 20
|
||||
196 20 20
|
||||
200 16 16
|
||||
208 16 16
|
||||
212 12 12
|
||||
220 12 12
|
||||
224 8 8
|
||||
232 8 8
|
||||
236 4 4
|
||||
244 4 4
|
||||
252 0 0
|
||||
252 4 0
|
||||
252 12 0
|
||||
252 20 0
|
||||
252 28 0
|
||||
252 36 0
|
||||
252 44 0
|
||||
252 52 0
|
||||
252 60 0
|
||||
252 68 0
|
||||
252 76 0
|
||||
252 84 0
|
||||
252 92 0
|
||||
252 100 0
|
||||
252 108 0
|
||||
252 116 0
|
||||
252 124 0
|
||||
252 132 0
|
||||
252 140 0
|
||||
252 148 0
|
||||
252 156 0
|
||||
252 164 0
|
||||
252 172 0
|
||||
252 180 0
|
||||
252 188 0
|
||||
252 196 0
|
||||
252 204 0
|
||||
252 212 0
|
||||
252 220 0
|
||||
252 228 0
|
||||
252 236 0
|
||||
252 244 0
|
||||
252 252 0
|
||||
252 252 4
|
||||
252 252 12
|
||||
252 252 20
|
||||
252 252 28
|
||||
252 252 36
|
||||
252 252 44
|
||||
252 252 52
|
||||
252 252 60
|
||||
252 252 68
|
||||
252 252 76
|
||||
252 252 84
|
||||
252 252 92
|
||||
252 252 100
|
||||
252 252 108
|
||||
252 252 116
|
||||
252 252 124
|
||||
252 252 132
|
||||
252 252 140
|
||||
252 252 148
|
||||
252 252 156
|
||||
252 252 164
|
||||
252 252 172
|
||||
252 252 180
|
||||
252 252 188
|
||||
252 252 196
|
||||
252 252 204
|
||||
252 252 212
|
||||
252 252 220
|
||||
252 252 228
|
||||
252 252 236
|
||||
252 252 244
|
||||
252 252 252
|
||||
252 252 252
|
||||
252 248 248
|
||||
252 248 244
|
||||
252 244 240
|
||||
252 244 236
|
||||
252 240 232
|
||||
252 240 228
|
||||
252 236 224
|
||||
252 236 220
|
||||
252 232 216
|
||||
252 232 212
|
||||
252 228 208
|
||||
252 228 204
|
||||
252 224 200
|
||||
252 224 196
|
||||
252 220 192
|
||||
252 220 188
|
||||
252 216 184
|
||||
252 216 180
|
||||
252 212 176
|
||||
252 212 172
|
||||
252 208 168
|
||||
252 208 164
|
||||
252 204 160
|
||||
252 204 156
|
||||
252 200 152
|
||||
252 200 148
|
||||
252 196 144
|
||||
252 196 140
|
||||
252 192 136
|
||||
252 192 132
|
||||
252 188 128
|
||||
252 184 124
|
||||
252 184 120
|
||||
252 180 116
|
||||
252 180 112
|
||||
252 176 108
|
||||
252 176 104
|
||||
252 172 100
|
||||
252 172 96
|
||||
252 168 92
|
||||
252 168 88
|
||||
252 164 84
|
||||
252 164 80
|
||||
252 160 76
|
||||
252 160 72
|
||||
252 156 68
|
||||
252 156 64
|
||||
252 152 60
|
||||
252 152 56
|
||||
252 148 52
|
||||
252 148 48
|
||||
252 144 44
|
||||
252 144 40
|
||||
252 140 36
|
||||
252 140 32
|
||||
252 136 28
|
||||
252 136 24
|
||||
252 132 20
|
||||
252 132 16
|
||||
252 128 12
|
||||
252 128 8
|
||||
252 124 4
|
||||
252 120 0
|
||||
252 120 0
|
||||
252 116 0
|
||||
252 112 0
|
||||
252 108 0
|
||||
252 104 0
|
||||
252 100 0
|
||||
252 96 0
|
||||
252 92 0
|
||||
252 88 0
|
||||
252 84 0
|
||||
252 80 0
|
||||
252 76 0
|
||||
252 72 0
|
||||
252 68 0
|
||||
252 64 0
|
||||
252 60 0
|
||||
252 60 0
|
||||
252 56 0
|
||||
252 52 0
|
||||
252 48 0
|
||||
252 44 0
|
||||
252 40 0
|
||||
252 36 0
|
||||
252 32 0
|
||||
252 28 0
|
||||
252 24 0
|
||||
252 20 0
|
||||
252 16 0
|
||||
252 12 0
|
||||
252 8 0
|
||||
252 4 0
|
||||
252 0 0
|
||||
252 0 0
|
||||
248 0 0
|
||||
244 0 0
|
||||
244 0 0
|
||||
240 0 0
|
||||
236 0 0
|
||||
232 0 0
|
||||
232 0 0
|
||||
228 0 0
|
||||
224 0 0
|
||||
224 0 0
|
||||
220 0 0
|
||||
216 0 0
|
||||
212 0 0
|
||||
212 0 0
|
||||
208 0 0
|
||||
204 0 0
|
||||
204 0 0
|
||||
200 0 0
|
||||
196 0 0
|
||||
192 0 0
|
||||
192 0 0
|
||||
188 0 0
|
||||
184 0 0
|
||||
184 0 0
|
||||
180 0 0
|
||||
176 0 0
|
||||
172 0 0
|
||||
172 0 0
|
||||
168 0 0
|
||||
164 0 0
|
||||
160 0 0
|
||||
160 0 0
|
||||
156 4 4
|
||||
152 4 4
|
||||
148 8 8
|
||||
144 8 8
|
||||
140 12 12
|
||||
140 12 12
|
||||
136 16 16
|
||||
132 16 16
|
||||
128 20 20
|
||||
124 20 20
|
||||
120 24 24
|
||||
120 24 24
|
||||
116 28 28
|
||||
112 28 28
|
||||
108 32 32
|
||||
104 32 32
|
||||
100 36 36
|
||||
100 36 36
|
||||
96 40 40
|
||||
92 40 40
|
||||
88 44 44
|
||||
84 44 44
|
||||
80 48 48
|
||||
80 48 48
|
||||
76 52 52
|
||||
72 52 52
|
||||
68 56 56
|
||||
64 56 56
|
||||
60 60 60
|
||||
60 60 60
|
||||
@@ -1,9 +1,31 @@
|
||||
# libtthimage
|
||||
# libtthimage, la doc
|
||||
|
||||
Les fichiers HTML que vous avez ici sont des versions historiques,
|
||||
Les fichiers [HTML](html/) que vous avez ici sont des versions historiques,
|
||||
qui seront peut-être mise à jour au prochain grand refactoring.
|
||||
Leur contenu est donc à prendre avec des pincettes, ymmv.
|
||||
|
||||
Ceci dit, les principes généraux sont encore bons...
|
||||
Ceci dit, les principes généraux sont encore bons. Mais il y a quelques
|
||||
points à préciser.
|
||||
|
||||
## Compilation
|
||||
|
||||
Certaines options de compilation sont dans le fichier de
|
||||
[paramètres](../Paramakes.mk) pour les différents fichiers make.
|
||||
Je vous conseille de vérifier leurs pertinences, et en particulier
|
||||
les options `-p` et `-pg` que j'oublie parfois d'enlever avant
|
||||
le _push_.
|
||||
|
||||
Le script [build.sh](../build.sh) tente d'automatiser les
|
||||
compilations de la bibilothèque, des tests et des outils
|
||||
en ligne de commande. Il est encore loin d'être parfait.
|
||||
|
||||
## Installation
|
||||
|
||||
Le script [install.sh](../install.sh) va installer divers fichiers
|
||||
aux bonnes places là où on lui dit avec la variable `DESTDIR`.
|
||||
Attention, celle-ci doit être cohérente avec les valeurs déclarée
|
||||
dans le fichier Paramakes.mk !
|
||||
|
||||
## Utilisation
|
||||
|
||||
??? *Insérez ici quelques exemples d'utilisation des tools.*
|
||||
|
||||
0
Docs/html/README.md
Normal file
0
Docs/html/README.md
Normal file
3
Lib/.gitignore
vendored
3
Lib/.gitignore
vendored
@@ -1,3 +1,6 @@
|
||||
|
||||
*.png
|
||||
*.gif
|
||||
|
||||
cflow.txt
|
||||
reduce.map
|
||||
|
||||
10
Lib/7seg.c
10
Lib/7seg.c
@@ -17,7 +17,7 @@ int foo, numbit, mask;
|
||||
int failed;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, "%s ( %p, <%d,%d>, 0x%x, %d )\n", __func__,
|
||||
fprintf(stderr, ">>> %s ( %p, <%d,%d>, 0x%x, %d )\n", __func__,
|
||||
img, xpos, ypos, bits, k);
|
||||
#endif
|
||||
|
||||
@@ -123,8 +123,8 @@ static int patterns[] =
|
||||
/* 0 1 2 3 4 5 6 7 8 9 */
|
||||
int foo, idx, bits;
|
||||
|
||||
#if DEBEUG_LEVEL > 1
|
||||
fprintf(stderr, "%s digit 0x%2x sizeof(patterns) -> %d\n", __func__,
|
||||
#if DEBUG_LEVEL > 1
|
||||
fprintf(stderr, "%s: digit 0x%2x sizeof(patterns) -> %d\n", __func__,
|
||||
chiffre, sizeof(patterns));
|
||||
#endif
|
||||
|
||||
@@ -159,7 +159,7 @@ int foo;
|
||||
char digit;
|
||||
|
||||
#if DEBUG_LEVEL > 1
|
||||
fprintf(stderr, "%s ( %p, '%s', %d )\n", __func__, img, numstr, k);
|
||||
fprintf(stderr, ">>> %s ( %p, '%s', %d )\n", __func__, img, numstr, k);
|
||||
#endif
|
||||
|
||||
len = strlen(numstr);
|
||||
@@ -189,7 +189,7 @@ int foo, bar;
|
||||
int iter;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">> %s ( %p, %d, 0x%x )\n", __func__, img, nbre, k);
|
||||
fprintf(stderr, ">>> %s ( %p, %d, 0x%x )\n", __func__, img, nbre, k);
|
||||
#endif
|
||||
|
||||
iter = 0; /* safe value */
|
||||
|
||||
27
Lib/Makefile
27
Lib/Makefile
@@ -8,7 +8,7 @@ include ../Paramakes.mk
|
||||
|
||||
DEPS = ../tthimage.h ../Paramakes.mk Makefile
|
||||
|
||||
all: foo testtga
|
||||
all: foo testtga t_png testbmp
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
@@ -51,7 +51,6 @@ distances.o: distances.c $(DEPS)
|
||||
dither.o: dither.c $(DEPS)
|
||||
dither2.o: dither2.c $(DEPS)
|
||||
dither3.o: dither3.c $(DEPS)
|
||||
dither4.o: dither4.c $(DEPS)
|
||||
doublesz.o: doublesz.c $(DEPS)
|
||||
drawalpha.o: drawalpha.c $(DEPS)
|
||||
drawing.o: drawing.c $(DEPS)
|
||||
@@ -64,9 +63,12 @@ extractbits.o: extractbits.c $(DEPS)
|
||||
|
||||
filtadapt.o: filtadapt.c $(DEPS)
|
||||
filtres.o: filtres.c $(DEPS)
|
||||
falsecolors.o: falsecolors.c $(DEPS)
|
||||
functions.o: functions.c $(DEPS) # new Aug 15, 2024
|
||||
|
||||
gadgrect.o: gadgrect.c $(DEPS)
|
||||
glitch.o: glitch.c $(DEPS)
|
||||
gradient.o: gradient.c $(DEPS)
|
||||
|
||||
halfsize.o: halfsize.c $(DEPS)
|
||||
|
||||
@@ -109,6 +111,7 @@ ptlist.o: ptlist.c $(DEPS)
|
||||
|
||||
quadpics.o: quadpics.c $(DEPS)
|
||||
|
||||
readjpeg.o: readjpeg.c $(DEPS)
|
||||
recurse.o: recurse.c $(DEPS)
|
||||
rgbmask.o: rgbmask.c $(DEPS)
|
||||
|
||||
@@ -131,7 +134,6 @@ vignetize.o: vignetize.c $(DEPS)
|
||||
warp0.o: warp0.c $(DEPS)
|
||||
warp1.o: warp1.c $(DEPS)
|
||||
warp2.o: warp2.c $(DEPS)
|
||||
warp3.o: warp3.c $(DEPS)
|
||||
|
||||
zoom.o: zoom.c $(DEPS)
|
||||
|
||||
@@ -148,11 +150,12 @@ OBJECTS = 7seg.o \
|
||||
combine6.o combine_rnd.o \
|
||||
contrast.o \
|
||||
detect.o distances.o \
|
||||
dither.o dither2.o dither3.o dither4.o \
|
||||
dither.o dither2.o dither3.o \
|
||||
doublesz.o drawalpha.o drawing.o drawpatt.o \
|
||||
effects.o effects2.o effects3.o extractbits.o \
|
||||
filtadapt.o filtres.o \
|
||||
gadgrect.o glitch.o \
|
||||
filtadapt.o filtres.o falsecolors.o \
|
||||
functions.o \
|
||||
gadgrect.o glitch.o gradient.o \
|
||||
halfsize.o \
|
||||
image.o imprime.o \
|
||||
luts15bits.o \
|
||||
@@ -168,15 +171,16 @@ OBJECTS = 7seg.o \
|
||||
pov_hf15e.o pov_hf15e.o pov_hf15f.o pov_synth.o \
|
||||
ptlist.o \
|
||||
quadpics.o \
|
||||
recurse.o rgbmask.o \
|
||||
readjpeg.o recurse.o rgbmask.o \
|
||||
scale.o sobel4.o stereo.o \
|
||||
tamppool.o tele_2.o television.o \
|
||||
text0.o text1.o text16x24.o \
|
||||
tga.o tools.o turtle.o \
|
||||
vignetize.o \
|
||||
warp0.o warp1.o warp2.o warp3.o \
|
||||
warp0.o warp1.o warp2.o \
|
||||
zoom.o
|
||||
|
||||
# build the static library
|
||||
../libtthimage.a: $(OBJECTS)
|
||||
$(AR) rs $@ $?
|
||||
$(RANLIB) $@
|
||||
@@ -184,7 +188,7 @@ OBJECTS = 7seg.o \
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
foo: foo.c $(DEPS) ../libtthimage.a
|
||||
gcc $(CFLAGS) $< ../libtthimage.a -o $@
|
||||
gcc $(CFLAGS) $< ../libtthimage.a -lm -o $@
|
||||
|
||||
t_png: t_png.c $(DEPS) ../libtthimage.a
|
||||
gcc $(CFLAGS) $< ../libtthimage.a -lpng -lz -o $@
|
||||
@@ -197,7 +201,10 @@ testbmp: testbmp.c $(DEPS) ../libtthimage.a
|
||||
essais.o: essais.c $(DEPS) essais.h
|
||||
gcc $(CFLAGS) $< -c
|
||||
|
||||
testtga: testtga.c $(DEPS) ../libtthimage.a essais.o
|
||||
testtga.o: testtga.c testtga.c $(DEPS)
|
||||
gcc $(CFLAGS) $< -c
|
||||
|
||||
testtga: testtga.o ../libtthimage.a essais.o
|
||||
gcc $(CFLAGS) $< essais.o ../libtthimage.a -lm -o $@
|
||||
|
||||
#-----------------------------------------------------------------
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
# The tTh image processind library
|
||||
# The tTh image processing library
|
||||
|
||||
Ugly software born around 1995 on a MS-Dos 286 computer.
|
||||
Look at the [`Makefile`](Makefile) for no more explanations.
|
||||
More pertinent informations can be found in
|
||||
[`tthimage.h`](../tthimage.h).
|
||||
|
||||
|
||||
## Text primitives
|
||||
|
||||
Big rewrite in progress, the actual version is a mess.
|
||||
|
||||
Look at the `Makefile` for no more explanations.
|
||||
|
||||
@@ -7,8 +7,9 @@
|
||||
Et c,a va me forcer a installer libpng
|
||||
--------------------------------------
|
||||
15May01: on attend toujours libPNG
|
||||
07Dec01: pfeue, libPNG toujours pas là...
|
||||
07Dec01: pfeue, libPNG toujours pas la...
|
||||
03Fev14: ... please wait more ...
|
||||
04Oct22: on the way, stay tuned.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "tthimage.h"
|
||||
#include "../tthimage.h"
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int Image_alpha_setvalue(Image_Desc *dst, int v_alpha)
|
||||
|
||||
@@ -40,7 +40,6 @@ return FUNC_NOT_FINISH;
|
||||
int
|
||||
Image_anmo_grille(Image_Desc *dst)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
if (dst->magic != MAGIC_OF_IMAGE)
|
||||
{
|
||||
|
||||
@@ -2,17 +2,17 @@
|
||||
BASIC_IO Sept 2001
|
||||
-------- ---------
|
||||
|
||||
Ce module a été écrit pour tenter de régler les
|
||||
problèmes de "boutisme" pour que ça puisse aussi
|
||||
Ce module a ete ecrit pour tenter de regler les
|
||||
problemes de "boutisme" pour que c,a puisse aussi
|
||||
tourner sur les vrais processeurs, parce que, bon,
|
||||
les 386, ça suffit, hein...
|
||||
les 386, parfois, on s'en gave, hein...
|
||||
|
||||
Ceci dit, je ne sais pas vraiment comment traiter
|
||||
le problème. Pour le moment (Septembre 2001) c'est
|
||||
le probleme. Pour le moment (Septembre 2001) c'est
|
||||
un peu beaucoup du "try and test".
|
||||
|
||||
D'autre part, comment ça va se passer sur des CPUs
|
||||
à 64 (ou 128) bits ?
|
||||
D'autre part, comment les choses vont se passer sur
|
||||
des CPUs a 64 (ou 128) bits ?
|
||||
-------------------------------------------------
|
||||
|
||||
9 oct 2001: pourquoi pas de fonction pour ecrire des BYTEs ?
|
||||
@@ -136,7 +136,7 @@ for (foo=0; foo<4; foo++)
|
||||
|
||||
*pvalue = value;
|
||||
|
||||
return FUNC_IS_BETA;
|
||||
return FUNC_IS_BETA; /* XXX ? */
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int Image_basicIO_write_I_long(FILE *fp, long value)
|
||||
|
||||
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
|
||||
* de destination.
|
||||
*/
|
||||
int
|
||||
Image_get_rect(Image_Desc *s, Image_Rect *z, Image_Desc *d, int x, int y)
|
||||
int Image_get_rect(Image_Desc *s, Image_Rect *z, Image_Desc *d, int x, int y)
|
||||
{
|
||||
int xfoo, yfoo; /* oh! des 'foo' 2D :-) */
|
||||
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
|
||||
fprintf(stderr, "GET RECT src %p %4d, %4d, %4d, %4d\n",
|
||||
s, z->x, z->y, z->w, z->h);
|
||||
fprintf(stderr, " dst %p %4d, %4d\n", d, x, y);
|
||||
#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;
|
||||
}
|
||||
|
||||
for (yfoo=0; yfoo<z->h; yfoo++)
|
||||
{
|
||||
for (yfoo=0; yfoo<z->h; yfoo++) {
|
||||
ys = yfoo + z->y;
|
||||
if (ys<0 || ys>s->height-1)
|
||||
continue;
|
||||
for (xfoo=0; xfoo<z->w; xfoo++)
|
||||
{
|
||||
for (xfoo=0; xfoo<z->w; xfoo++) {
|
||||
xs = xfoo + z->x;
|
||||
if (xs<0 || xs>s->width-1)
|
||||
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
|
||||
* une image destination.
|
||||
*/
|
||||
int
|
||||
Image_put_rect(Image_Desc *s, Image_Rect *z, Image_Desc *d, int x, int y)
|
||||
int Image_put_rect(Image_Desc *s, Image_Rect *z, Image_Desc *d, int x, int y)
|
||||
{
|
||||
int xfoo, yfoo;
|
||||
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
|
||||
fprintf(stderr, "PUT RECT src %p %4d, %4d, %4d, %4d\n",
|
||||
s, z->x, z->y, z->w, z->h);
|
||||
fprintf(stderr, " dst %p %4d, %4d\n", d, x, y);
|
||||
#endif
|
||||
|
||||
for (yfoo=0; yfoo<z->h; yfoo++)
|
||||
{
|
||||
for (yfoo=0; yfoo<z->h; yfoo++) {
|
||||
ys = yfoo + z->y;
|
||||
if (ys<0 || ys>s->height-1)
|
||||
continue;
|
||||
@@ -80,8 +88,7 @@ for (yfoo=0; yfoo<z->h; yfoo++)
|
||||
if (yd<0 || yd>d->height-1)
|
||||
continue;
|
||||
|
||||
for (xfoo=0; xfoo<z->w; xfoo++)
|
||||
{
|
||||
for (xfoo=0; xfoo<z->w; xfoo++) {
|
||||
xs = xfoo + z->x;
|
||||
if (xs<0 || xs>s->width-1)
|
||||
continue;
|
||||
@@ -94,33 +101,27 @@ for (yfoo=0; yfoo<z->h; yfoo++)
|
||||
}
|
||||
}
|
||||
|
||||
return FUNC_IS_ALPHA;
|
||||
return FUNC_IS_ALPHA; /* AH BRAVO */
|
||||
}
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/*
|
||||
* coredumper dlmkt !
|
||||
*/
|
||||
int
|
||||
Image_copy_rect(Image_Desc *s, Image_Rect *z, Image_Desc *d, int x, int y)
|
||||
int Image_copy_rect(Image_Desc *s, Image_Rect *z, Image_Desc *d, int x, int y)
|
||||
{
|
||||
int xs, ys, xd, yd, xx, yy;
|
||||
int foo;
|
||||
|
||||
#if DEBUG_LEVEL > 1
|
||||
fprintf(stderr, "%s s=%p z=%p d=%p x,y=%d,%d\n", __func__,
|
||||
s, z, d, x, y);
|
||||
#endif
|
||||
fprintf(stderr, ">>> %s ( %p %p %p %d %d )\n", __func__, s, z, d, x, y );
|
||||
|
||||
if (d->magic != MAGIC_OF_IMAGE)
|
||||
{
|
||||
if (d->magic != MAGIC_OF_IMAGE) {
|
||||
fprintf(stderr, "%s: need Dead Beef\n", __func__);
|
||||
return NOT_AN_IMAGE_DESC;
|
||||
}
|
||||
|
||||
foo = 0;
|
||||
for (yy=0; yy<z->h; yy++)
|
||||
{
|
||||
for (yy=0; yy<z->h; yy++) {
|
||||
ys = yy + z->y;
|
||||
if (ys<0 || ys>=s->height)
|
||||
continue;
|
||||
@@ -129,8 +130,7 @@ for (yy=0; yy<z->h; yy++)
|
||||
if (yd<0 || yd>=d->height)
|
||||
continue;
|
||||
|
||||
for (xx=0; xx<z->w; xx++)
|
||||
{
|
||||
for (xx=0; xx<z->w; xx++) {
|
||||
xs = xx + z->x;
|
||||
if (xs<0 || xs>=s->width)
|
||||
continue;
|
||||
@@ -154,22 +154,21 @@ return FUNC_IS_BETA;
|
||||
* 23 dec 01 found a coredump if src image is too small
|
||||
*
|
||||
*/
|
||||
Image_Desc *
|
||||
Image_create_subimg(Image_Desc *src, Image_Rect *r, int gray)
|
||||
Image_Desc *Image_create_subimg(Image_Desc *src, Image_Rect *r, int gray)
|
||||
{
|
||||
Image_Desc *clone;
|
||||
int x,y,xs, ys;
|
||||
|
||||
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, r, gray);
|
||||
|
||||
/*
|
||||
* sanities controls...
|
||||
*/
|
||||
if (src->type != IMAGE_RGB)
|
||||
{
|
||||
if (src->type != IMAGE_RGB) {
|
||||
fprintf(stderr, "'%s' work only on RGB images\n", __func__);
|
||||
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",
|
||||
r->x, r->y, r->w, r->h);
|
||||
exit(5);
|
||||
@@ -180,34 +179,28 @@ if ( (r->x<0) || (r->y<0) )
|
||||
* now, we allocate the new image...
|
||||
*/
|
||||
clone = Image_alloc(r->w, r->h, src->type);
|
||||
if (clone == NULL)
|
||||
{
|
||||
if (clone == NULL) {
|
||||
fprintf(stderr, "CreateSubImage: can't alloc memory...\n");
|
||||
exit(5);
|
||||
}
|
||||
|
||||
for (x=0; x<r->w; x++)
|
||||
{
|
||||
for (x=0; x<r->w; x++) {
|
||||
xs = x + r->x;
|
||||
for (y=0; y<r->h; y++)
|
||||
{
|
||||
for (y=0; y<r->h; y++) {
|
||||
ys = y + r->y;
|
||||
/*printf("dst %4d %4d ", x, y); */
|
||||
/*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);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
/* XXX calling this func is a nasty cpu sucker,
|
||||
* so we have to go to a nasty optimize trick */
|
||||
/* XXX Image_pixel_copy(src, xs, ys, clone, x, y); */
|
||||
(clone->Rpix[y])[x] = (src->Rpix[ys])[xs];
|
||||
(clone->Gpix[y])[x] = (src->Gpix[ys])[xs];
|
||||
(clone->Bpix[y])[x] = (src->Bpix[ys])[xs];
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
68
Lib/bmp.c
68
Lib/bmp.c
@@ -19,15 +19,13 @@
|
||||
#include "bmp.h" /* maybe I can hardcoded bmp.h here ? */
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
static void
|
||||
fatal_error(char *txt)
|
||||
static void fatal_error(char *txt)
|
||||
{
|
||||
fprintf(stderr, "BMP: Fatal error: %s\n", txt);
|
||||
exit(10);
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_BMP_infos(char *nom, int *pw, int *ph, int *pt, int verb)
|
||||
int Image_BMP_infos(char *nom, int *pw, int *ph, int *pt, int verb)
|
||||
{
|
||||
FILE *fp;
|
||||
BMPHEAD head;
|
||||
@@ -35,17 +33,20 @@ int foo;
|
||||
|
||||
if (verb) printf("BMP_Infos : '%s'\n", nom);
|
||||
|
||||
if ((fp=fopen(nom, "r")) == NULL)
|
||||
{
|
||||
if ((fp=fopen(nom, "r")) == NULL) {
|
||||
fprintf(stderr, "BMP_Infos: can't open %s\n", nom);
|
||||
return FILE_NOT_FOUND;
|
||||
}
|
||||
|
||||
foo = fread(&head, 1, sizeof(head), fp);
|
||||
if (sizeof(head) != foo) {
|
||||
fprintf(stderr, "%s: err read header of %s\n", __func__, nom);
|
||||
fclose(fp);
|
||||
return UNKNOW_ERROR;
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
if (verb)
|
||||
{
|
||||
if (verb) {
|
||||
printf("signature %c%c filesize %8ld\n",
|
||||
head.id[0], head.id[1], head.filesize);
|
||||
printf("headerSize %8ld infoSize %8ld\n",
|
||||
@@ -54,7 +55,7 @@ if (verb)
|
||||
head.width, head.height, head.bits);
|
||||
printf("colors: used %ld important %ld\n",
|
||||
head.clrused, head.clrimportant);
|
||||
printf("taille structure header %d\n", sizeof(BMPHEAD));
|
||||
printf("taille structure header %ld\n", sizeof(BMPHEAD));
|
||||
}
|
||||
/*
|
||||
* now, return some usefull informations.
|
||||
@@ -70,28 +71,32 @@ return 0;
|
||||
*/
|
||||
#define PIX2BYTE(n) ((n+7)/8)
|
||||
|
||||
Image_Desc *
|
||||
Image_BMP_alloc_load(char *nom, int reserved)
|
||||
Image_Desc * Image_BMP_alloc_load(char *nom, int reserved)
|
||||
{
|
||||
(void)reserved; /* WARNING KILLER */
|
||||
FILE *fp;
|
||||
BMPHEAD head;
|
||||
int ligne, foo, larg, col, ligne2;
|
||||
Image_Desc *image;
|
||||
uint8_t *buffer;
|
||||
|
||||
if ((fp=fopen(nom, "r")) == NULL)
|
||||
{
|
||||
if ((fp=fopen(nom, "r")) == NULL) {
|
||||
fprintf(stderr, "can't open %s\n", nom);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
foo = fread(&head, 1, sizeof(head), fp);
|
||||
if (sizeof(head) != foo) {
|
||||
fprintf(stderr, "%s: err read header of %s\n", __func__, nom);
|
||||
fclose(fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, "BMP: on a lu %d octets pour le header.\n", foo);
|
||||
#endif
|
||||
|
||||
if ( head.id[0] != 'B' || head.id[1] != 'M' )
|
||||
{
|
||||
if ( head.id[0] != 'B' || head.id[1] != 'M' ) {
|
||||
fprintf(stderr, "BMP_Alloc_Load: BAD MAGIC %s\n", nom);
|
||||
return NULL;
|
||||
}
|
||||
@@ -103,15 +108,13 @@ fprintf(stderr, "BMP_Alloc_Load: image depth = %d\n", head.bits);
|
||||
/*
|
||||
* first step: allocating the memory.
|
||||
*/
|
||||
switch (head.bits)
|
||||
{
|
||||
switch (head.bits) {
|
||||
case 1: case 4: case 8:
|
||||
fprintf(stderr, "bit depth %d not supported\n", head.bits);
|
||||
return NULL;
|
||||
break;
|
||||
|
||||
case 24:
|
||||
|
||||
if ( (image=Image_alloc(head.width, head.height, 3))==NULL)
|
||||
fatal_error("no memory for picture in 'alloc_load'\n");
|
||||
|
||||
@@ -119,7 +122,6 @@ switch (head.bits)
|
||||
fatal_error("no memory for buffer in 'alloc_load'\n");
|
||||
|
||||
larg = head.width * 3;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -132,8 +134,7 @@ switch (head.bits)
|
||||
/*
|
||||
* round up to an even dword boundary (?)
|
||||
*/
|
||||
if (larg & 0x00000003)
|
||||
{
|
||||
if (larg & 0x00000003) {
|
||||
larg |= 0x00000003;
|
||||
larg++;
|
||||
}
|
||||
@@ -143,17 +144,14 @@ if (larg & 0x00000003)
|
||||
*
|
||||
* (no default case, filtered in first step)
|
||||
*/
|
||||
switch (head.bits)
|
||||
{
|
||||
switch (head.bits) {
|
||||
case 24:
|
||||
|
||||
for (ligne=0; ligne<head.height; ligne++)
|
||||
{
|
||||
for (ligne=0; ligne<head.height; ligne++) {
|
||||
foo=fread(buffer, 1, larg, fp);
|
||||
/* printf("ligne %5d lu %d\n", ligne, foo); */
|
||||
ligne2 = head.height - ligne - 1;
|
||||
for (col=0; col<head.width; col++)
|
||||
{
|
||||
for (col=0; col<head.width; col++) {
|
||||
(image->Bpix[ligne2])[col] = buffer[ col*3 ];
|
||||
(image->Gpix[ligne2])[col] = buffer[ (col*3) + 1 ];
|
||||
(image->Rpix[ligne2])[col] = buffer[ (col*3) + 2 ];
|
||||
@@ -172,9 +170,9 @@ return image;
|
||||
*
|
||||
* et cette fois-ci, on va faire gaffe au boutisme :)
|
||||
*/
|
||||
int
|
||||
Image_BMP_save_24(char *filename, Image_Desc *img, int flag)
|
||||
int Image_BMP_save_24(char *filename, Image_Desc *img, int flag)
|
||||
{
|
||||
(void)flag; /* WARNING KILLER */
|
||||
FILE *fp;
|
||||
long grand;
|
||||
short court;
|
||||
@@ -187,8 +185,7 @@ fprintf(stderr, "%s : writing %p to %s, flag=%d\n", __func__,
|
||||
img, filename, flag);
|
||||
#endif
|
||||
|
||||
if ((fp=fopen(filename, "w")) == NULL)
|
||||
{
|
||||
if ((fp=fopen(filename, "w")) == NULL) {
|
||||
fprintf(stderr, "can't open %s for writing\n", filename);
|
||||
return FILE_CREATE_ERR;
|
||||
}
|
||||
@@ -206,8 +203,7 @@ if (bytes & 0x3)
|
||||
bytes++;
|
||||
}
|
||||
*/
|
||||
switch (bytes & 0x3)
|
||||
{
|
||||
switch (bytes & 0x3) {
|
||||
case 0: /* OK */ break;
|
||||
case 1: bytes+=3; break;
|
||||
case 2: bytes+=2; break;
|
||||
@@ -261,14 +257,12 @@ fflush(fp);
|
||||
if ((buffer=(uint8_t *)malloc(sizeof(uint8_t)*4*img->width)) == NULL)
|
||||
fatal_error("no memory buffer for BMP24 save operation");
|
||||
|
||||
for (line=img->height-1; line>=0; line--)
|
||||
{
|
||||
for (line=img->height-1; line>=0; line--) {
|
||||
ptr = buffer;
|
||||
Rptr = img->Rpix[line];
|
||||
Gptr = img->Gpix[line];
|
||||
Bptr = img->Bpix[line];
|
||||
for (foo=0; foo<img->width; foo++)
|
||||
{
|
||||
for (foo=0; foo<img->width; foo++) {
|
||||
*ptr++ = Bptr[foo];
|
||||
*ptr++ = Gptr[foo];
|
||||
*ptr++ = Rptr[foo];
|
||||
|
||||
154
Lib/cadres.c
154
Lib/cadres.c
@@ -15,37 +15,32 @@
|
||||
* l'epaisseur de ce cadre est de DEUX pixels, et cette valeur
|
||||
* ne doit pas changer, car d'autres fonctions en dependent.
|
||||
*/
|
||||
int
|
||||
Image_cadre_A(Image_Desc *im)
|
||||
int Image_cadre_A(Image_Desc *im)
|
||||
{
|
||||
int x, y;
|
||||
int a, b;
|
||||
|
||||
a = 0; b = 255;
|
||||
|
||||
for (x=0; x<im->width; x++)
|
||||
{
|
||||
for (x=0; x<im->width; x++) {
|
||||
(im->Rpix[0])[x] = a;
|
||||
(im->Gpix[0])[x] = a;
|
||||
(im->Bpix[0])[x] = a;
|
||||
Image_plotRGB(im, x, im->height-1, a, a, a);
|
||||
}
|
||||
for (y=0; y<im->height; y++)
|
||||
{
|
||||
for (y=0; y<im->height; y++) {
|
||||
(im->Rpix[y])[0] = a;
|
||||
(im->Gpix[y])[0] = a;
|
||||
(im->Bpix[y])[0] = a;
|
||||
Image_plotRGB(im, im->width-1, y, a, a, a);
|
||||
}
|
||||
for (x=1; x<im->width-1; x++)
|
||||
{
|
||||
for (x=1; x<im->width-1; x++) {
|
||||
(im->Rpix[1])[x] = b;
|
||||
(im->Gpix[1])[x] = b;
|
||||
(im->Bpix[1])[x] = b;
|
||||
Image_plotRGB(im, x, im->height-2, b, b, b);
|
||||
}
|
||||
for (y=1; y<im->height-1; y++)
|
||||
{
|
||||
for (y=1; y<im->height-1; y++) {
|
||||
(im->Rpix[y])[1] = b;
|
||||
(im->Gpix[y])[1] = b;
|
||||
(im->Bpix[y])[1] = b;
|
||||
@@ -57,8 +52,7 @@ return OLL_KORRECT;
|
||||
/*
|
||||
* 30 septembre 2008: Image_cadre_B devient Image_cadre_cracra :)
|
||||
*/
|
||||
int
|
||||
Image_cadre_cracra(Image_Desc *im, int largeur, int k)
|
||||
int Image_cadre_cracra(Image_Desc *im, int largeur, int k)
|
||||
{
|
||||
int x, y, r, g, b;
|
||||
|
||||
@@ -69,10 +63,8 @@ if (im->width < (largeur+5) || im->height < (largeur+5))
|
||||
fprintf(stderr, "%s: k is $%04x\n", __func__, k);
|
||||
#endif
|
||||
|
||||
for (y=0; y<im->height; y++)
|
||||
{
|
||||
for (x=0; x<largeur; x++)
|
||||
{
|
||||
for (y=0; y<im->height; y++) {
|
||||
for (x=0; x<largeur; x++) {
|
||||
r = rand() % (10 + x * 20);
|
||||
g = rand() % (11 + x * 10);
|
||||
b = rand() % (10 + x * 12);
|
||||
@@ -81,8 +73,7 @@ for (y=0; y<im->height; y++)
|
||||
(im->Gpix[y])[x] = g;
|
||||
(im->Bpix[y])[x] = b;
|
||||
}
|
||||
for (x=0; x<largeur; x++)
|
||||
{
|
||||
for (x=0; x<largeur; x++) {
|
||||
r = rand() % (10 + (largeur-x) * 20);
|
||||
g = rand() % (10 + (largeur-x) * 10);
|
||||
b = rand() % (10 + (largeur-x) * 12);
|
||||
@@ -90,10 +81,8 @@ for (y=0; y<im->height; y++)
|
||||
}
|
||||
}
|
||||
|
||||
for (x=0; x<im->width; x++)
|
||||
{
|
||||
for (y=0; y<largeur; y++)
|
||||
{
|
||||
for (x=0; x<im->width; x++) {
|
||||
for (y=0; y<largeur; y++) {
|
||||
r = rand() % (10 + y * 10);
|
||||
g = rand() % (10 + y * 12);
|
||||
b = rand() % (10 + y * 20);
|
||||
@@ -102,8 +91,7 @@ for (x=0; x<im->width; x++)
|
||||
(im->Gpix[y])[x] = g;
|
||||
(im->Bpix[y])[x] = b;
|
||||
}
|
||||
for (y=0; y<largeur; y++)
|
||||
{
|
||||
for (y=0; y<largeur; y++) {
|
||||
r = rand() % (10 + (largeur-y) * 10);
|
||||
g = rand() % (10 + (largeur-y) * 12);
|
||||
b = rand() % (10 + (largeur-y) * 20);
|
||||
@@ -192,8 +180,7 @@ return OLL_KORRECT;
|
||||
/*
|
||||
* this function was the successor of the 'C' cadre. Need a rename.
|
||||
*/
|
||||
int
|
||||
Image_cadre_bruit(Image_Desc *im, int r, int g, int b, int n)
|
||||
int Image_cadre_bruit(Image_Desc *im, int r, int g, int b, int n)
|
||||
{
|
||||
int x, y, x2, y2, ir, ig, ib;
|
||||
float fx, fy;
|
||||
@@ -211,8 +198,7 @@ fn = (float)(n*n);
|
||||
x2 = im->width / 2;
|
||||
y2 = im->height / 2;
|
||||
|
||||
for (y=0; y<im->height; y++)
|
||||
{
|
||||
for (y=0; y<im->height; y++) {
|
||||
/*
|
||||
* distance au bord HAUT BAS le plus proche
|
||||
*/
|
||||
@@ -220,8 +206,7 @@ for (y=0; y<im->height; y++)
|
||||
else fy = (float)((im->height - y)-1);
|
||||
fy = fy*fy;
|
||||
|
||||
for (x=0; x<im->width; x++)
|
||||
{
|
||||
for (x=0; x<im->width; x++) {
|
||||
/*
|
||||
* distance au bord DROITE GAUCHE le plus proche
|
||||
*/
|
||||
@@ -232,15 +217,12 @@ for (y=0; y<im->height; y++)
|
||||
if (fx < fy) d = fx;
|
||||
else d = fy;
|
||||
|
||||
if (d < fn)
|
||||
{
|
||||
if (d < fn) {
|
||||
level = (int)((d / fn) * 1000.0);
|
||||
if ( (rand()%1000) < level )
|
||||
{
|
||||
if ( (rand()%1000) < level ) {
|
||||
Image_getRGB(im, x, y, &ir, &ig, &ib);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
ir = r; ig = g; ib = b;
|
||||
}
|
||||
/* Image_plotRGB(im, x, y, ir, ig, ib); */
|
||||
@@ -255,14 +237,12 @@ return OLL_KORRECT;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/* inventee pour blablanux :) */
|
||||
int
|
||||
Image_cadre_E(Image_Desc *im, int v1, int v2, int v3, int dim)
|
||||
int Image_cadre_E(Image_Desc *im, int v1, int v2, int v3, int dim)
|
||||
{
|
||||
int foo, bar;
|
||||
Image_Rect rect;
|
||||
|
||||
for (foo=0; foo<dim; foo++)
|
||||
{
|
||||
for (foo=0; foo<dim; foo++) {
|
||||
bar = 1 << (foo%8);
|
||||
#if DEBUG_LEVEL > 1
|
||||
fprintf(stderr, "cadre E: foo is %d, bar is 0x%x\n", foo, bar);
|
||||
@@ -274,32 +254,28 @@ for (foo=0; foo<dim; foo++)
|
||||
Image_draw_rect(im, &rect, v1^bar, v2^bar, v3^bar);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return OLL_KORRECT;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/* 5 Fev 2001
|
||||
* pas de dégradé
|
||||
*/
|
||||
int
|
||||
Image_cadre_pattern_0(Image_Desc *im, Image_Desc *pat, int larg)
|
||||
int Image_cadre_pattern_0(Image_Desc *im, Image_Desc *pat, int larg)
|
||||
{
|
||||
int x, y, r, g, b;
|
||||
|
||||
/*
|
||||
* Tiens, je la supposais plus facile a ecrire...
|
||||
*/
|
||||
for (y=0; y<im->height; y++)
|
||||
{
|
||||
for (x=0; x<larg; x++)
|
||||
{
|
||||
for (y=0; y<im->height; y++) {
|
||||
for (x=0; x<larg; x++) {
|
||||
Image_getRGB(pat, x%pat->width, y%pat->height, &r, &g, &b);
|
||||
/* Image_plotRGB(im, x, y, r, g, b); */
|
||||
(im->Rpix[y])[x] = r;
|
||||
(im->Gpix[y])[x] = g;
|
||||
(im->Bpix[y])[x] = b;
|
||||
}
|
||||
for (x=im->width-larg; x<im->width; x++)
|
||||
{
|
||||
for (x=im->width-larg; x<im->width; x++) {
|
||||
Image_getRGB(pat, x%pat->width, y%pat->height, &r, &g, &b);
|
||||
/* Image_plotRGB(im, x, y, r, g, b); */
|
||||
(im->Rpix[y])[x] = r;
|
||||
@@ -308,18 +284,15 @@ for (y=0; y<im->height; y++)
|
||||
}
|
||||
}
|
||||
|
||||
for (x=0; x<im->width; x++)
|
||||
{
|
||||
for (y=0; y<larg; y++)
|
||||
{
|
||||
for (x=0; x<im->width; x++) {
|
||||
for (y=0; y<larg; y++) {
|
||||
Image_getRGB(pat, x%pat->width, y%pat->height, &r, &g, &b);
|
||||
/* Image_plotRGB(im, x, y, r, g, b); */
|
||||
(im->Rpix[y])[x] = r;
|
||||
(im->Gpix[y])[x] = g;
|
||||
(im->Bpix[y])[x] = b;
|
||||
}
|
||||
for (y=im->height-larg; y<im->height; y++)
|
||||
{
|
||||
for (y=im->height-larg; y<im->height; y++) {
|
||||
Image_getRGB(pat, x%pat->width, y%pat->height, &r, &g, &b);
|
||||
/* Image_plotRGB(im, x, y, r, g, b); */
|
||||
(im->Rpix[y])[x] = r;
|
||||
@@ -332,10 +305,9 @@ return OLL_KORRECT;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/* 12 Feb 2001
|
||||
* dégradé propotionnel à la distance
|
||||
* dégradé proportionnel à la distance
|
||||
*/
|
||||
int
|
||||
Image_cadre_pattern_1(Image_Desc *im, Image_Desc *pat, int n)
|
||||
int Image_cadre_pattern_1(Image_Desc *im, Image_Desc *pat, int n)
|
||||
{
|
||||
int x, y, x2, y2, ir, ig, ib, jr, jg, jb, r, g, b;
|
||||
float fx, fy;
|
||||
@@ -348,12 +320,11 @@ x2 = im->width / 2;
|
||||
y2 = im->height / 2;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, "*** cadre pattern 1 : fn = %f\n", fn);
|
||||
fprintf(stderr, "*** %s: fn = %f\n", __func__, fn);
|
||||
#endif
|
||||
|
||||
lmax = 0;
|
||||
for (y=0; y<im->height; y++)
|
||||
{
|
||||
for (y=0; y<im->height; y++) {
|
||||
/*
|
||||
* distance au bord HAUT BAS le plus proche
|
||||
*/
|
||||
@@ -361,8 +332,7 @@ for (y=0; y<im->height; y++)
|
||||
else fy = (float)((im->height - y)-1);
|
||||
fy = fy*fy;
|
||||
|
||||
for (x=0; x<im->width; x++)
|
||||
{
|
||||
for (x=0; x<im->width; x++) {
|
||||
|
||||
/*
|
||||
* distance au bord DROITE GAUCHE le plus proche
|
||||
@@ -377,11 +347,9 @@ for (y=0; y<im->height; y++)
|
||||
if (fx < fy) d = fx;
|
||||
else d = fy;
|
||||
|
||||
if (d < fn)
|
||||
{
|
||||
if (d < fn) {
|
||||
level = (int)(100 * d / fn);
|
||||
if (level > lmax)
|
||||
{
|
||||
if (level > lmax) {
|
||||
lmax = level;
|
||||
}
|
||||
|
||||
@@ -405,8 +373,7 @@ fprintf(stderr, "cadre pattern 1 : lmax = %d\n", lmax);
|
||||
return OLL_KORRECT;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_cadre_pattern_2(Image_Desc *im, Image_Desc *pat, int n)
|
||||
int Image_cadre_pattern_2(Image_Desc *im, Image_Desc *pat, int n)
|
||||
{
|
||||
int x, y, x2, y2, ir, ig, ib;
|
||||
int xp, yp;
|
||||
@@ -425,15 +392,13 @@ fprintf(stderr, "*** cadre pat 2 : pat: %d x %d\n", pat->width, pat->height);
|
||||
#endif
|
||||
|
||||
lmax = 0;
|
||||
for (y=0; y<im->height; y++)
|
||||
{
|
||||
for (y=0; y<im->height; y++) {
|
||||
/* distance au bord HAUT BAS le plus proche */
|
||||
if (y < y2) fy = (float)y;
|
||||
else fy = (float)((im->height - y)-1);
|
||||
fy = fy*fy;
|
||||
|
||||
for (x=0; x<im->width; x++)
|
||||
{
|
||||
for (x=0; x<im->width; x++) {
|
||||
/* distance au bord DROITE GAUCHE le plus proche */
|
||||
if (x < x2) fx = (float)x;
|
||||
else fx = (float)((im->width - x)-1);
|
||||
@@ -442,15 +407,12 @@ for (y=0; y<im->height; y++)
|
||||
if (fx < fy) d = fx;
|
||||
else d = fy;
|
||||
|
||||
if (d < fn)
|
||||
{
|
||||
if (d < fn) {
|
||||
level = (int)((d / fn) * 1000.0);
|
||||
if ( (rand()%1000) < level )
|
||||
{
|
||||
if ( (rand()%1000) < level ) {
|
||||
Image_getRGB(im, x, y, &ir, &ig, &ib);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
xp = x % pat->width;
|
||||
yp = y % pat->height;
|
||||
Image_getRGB(pat, xp, yp, &ir, &ig, &ib);
|
||||
@@ -468,44 +430,38 @@ return OLL_KORRECT;
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/* nouveau : Mon 12 Sep 2022 10:47:18 PM CEST
|
||||
*/
|
||||
int Image_cadre_std2(Image_Desc *im, int r, int g, int b, int nh, int nv)
|
||||
int Image_cadre_std2(Image_Desc *im, int r, int g, int b, int nx, int ny)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p %d %d %d %d %d )\n", __func__,
|
||||
im, r, g, b, nh, nv);
|
||||
im, r, g, b, nx, ny);
|
||||
#endif
|
||||
|
||||
for (y=0; y<im->height; y++)
|
||||
{
|
||||
for (x=0; x<nv; x++)
|
||||
{
|
||||
for (y=0; y<im->height; y++) {
|
||||
for (x=0; x<nx; x++) {
|
||||
(im->Rpix[y])[x] = r;
|
||||
(im->Gpix[y])[x] = g;
|
||||
(im->Bpix[y])[x] = b;
|
||||
}
|
||||
for (x=0; x<nv; x++)
|
||||
{
|
||||
(im->Rpix[y])[im->width-x] = r;
|
||||
(im->Gpix[y])[im->width-x] = g;
|
||||
(im->Bpix[y])[im->width-x] = b;
|
||||
for (x=0; x<nx; x++) {
|
||||
(im->Rpix[y])[im->width-x-1] = r;
|
||||
(im->Gpix[y])[im->width-x-1] = g;
|
||||
(im->Bpix[y])[im->width-x-1] = b;
|
||||
}
|
||||
}
|
||||
|
||||
for (x=0; x<im->width; x++)
|
||||
{
|
||||
for (y=0; y<nh; y++)
|
||||
{
|
||||
for (x=0; x<im->width; x++) {
|
||||
for (y=0; y<ny; y++) {
|
||||
(im->Rpix[y])[x] = r;
|
||||
(im->Gpix[y])[x] = g;
|
||||
(im->Bpix[y])[x] = b;
|
||||
}
|
||||
for (y=0; y<nh; y++)
|
||||
{
|
||||
(im->Rpix[y+im->height-nh])[x] = r;
|
||||
(im->Gpix[y+im->height-nh])[x] = g;
|
||||
(im->Bpix[y+im->height-nh])[x] = b;
|
||||
for (y=0; y<ny; y++) {
|
||||
(im->Rpix[y+im->height-ny])[x] = r;
|
||||
(im->Gpix[y+im->height-ny])[x] = g;
|
||||
(im->Bpix[y+im->height-ny])[x] = b;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,26 +11,23 @@
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/*
|
||||
* fonction en chantier -> coredump probable
|
||||
* je ne sais pas à quoi va servir le paramètre 'flags' ...
|
||||
* je ne sais pas a quoi va servir le parametre 'flags' ...
|
||||
* 7 nov 2007:
|
||||
* le flag a disparu, il contient maintenant la valeur de
|
||||
* la composante verte. lol.
|
||||
*/
|
||||
int
|
||||
Image_cadre_burp_0(Image_Desc *img, int p1, int p2, int gval)
|
||||
int Image_cadre_burp_0(Image_Desc *img, int p1, int p2, int gval)
|
||||
{
|
||||
int x, y, zz, v;
|
||||
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, "%s p1=%d p2=%d flg=0x%02x\n", __func__, p1, p2, gval);
|
||||
fprintf(stderr, ">>> %s ( %p %d %d 0x%02x )\n", __func__, img, p1, p2, gval);
|
||||
#endif
|
||||
|
||||
for (x=0; x<img->width; x++)
|
||||
{
|
||||
for (x=0; x<img->width; x++) {
|
||||
v = (x * 256) / img->width;
|
||||
for (zz=0; zz<p1; zz++)
|
||||
{
|
||||
for (zz=0; zz<p1; zz++) {
|
||||
y = zz;
|
||||
(img->Rpix[y])[x] = 0;
|
||||
(img->Gpix[y])[x] = gval;
|
||||
@@ -43,11 +40,9 @@ for (x=0; x<img->width; x++)
|
||||
}
|
||||
}
|
||||
|
||||
for (y=p1; y<img->height-p1; y++)
|
||||
{
|
||||
for (y=p1; y<img->height-p1; y++) {
|
||||
v = (y * 256) / img->height;
|
||||
for (zz=0; zz<p2; zz++)
|
||||
{
|
||||
for (zz=0; zz<p2; zz++) {
|
||||
x = zz;
|
||||
(img->Rpix[y])[x] = 0;
|
||||
(img->Gpix[y])[x] = gval;
|
||||
@@ -70,8 +65,7 @@ return FUNC_IS_BETA;
|
||||
* 1er Juillet 2022: la colere est toujours la, mais ce n'est pas la
|
||||
* meme qu'il y a vingt ans...
|
||||
*/
|
||||
int
|
||||
Image_cadre_burp_1(Image_Desc *img, int p1, int p2, int flags)
|
||||
int Image_cadre_burp_1(Image_Desc *img, int p1, int p2, int flags)
|
||||
{
|
||||
int x, xx, y, yy, v;
|
||||
|
||||
@@ -81,14 +75,12 @@ int x, xx, y, yy, v;
|
||||
fprintf(stderr, ">>> %s ( %p %d %d $%x )\n", __func__, img, p1, p2, flags);
|
||||
#endif
|
||||
|
||||
for (x=0; x<img->width; x++)
|
||||
{
|
||||
for (x=0; x<img->width; x++) {
|
||||
v = (x * 256) / img->width;
|
||||
#if DEBUG_LEVEL > 1
|
||||
printf("%s : debug %d %d\n", __func__, x, v);
|
||||
#endif
|
||||
for (yy=0; yy<p1; yy++)
|
||||
{
|
||||
for (yy=0; yy<p1; yy++) {
|
||||
y = yy;
|
||||
(img->Rpix[y])[x] = TOPV-v;
|
||||
(img->Gpix[y])[x] = TOPV;
|
||||
@@ -101,11 +93,9 @@ for (x=0; x<img->width; x++)
|
||||
}
|
||||
}
|
||||
|
||||
for (y=p1; y<img->height-p1; y++)
|
||||
{
|
||||
for (y=p1; y<img->height-p1; y++) {
|
||||
v = (y * 256) / img->height;
|
||||
for (xx=0; xx<p2; xx++)
|
||||
{
|
||||
for (xx=0; xx<p2; xx++) {
|
||||
x = xx;
|
||||
(img->Rpix[y])[x] = 0;
|
||||
(img->Gpix[y])[x] = TOPV;
|
||||
@@ -118,8 +108,7 @@ for (y=p1; y<img->height-p1; y++)
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & 1)
|
||||
{
|
||||
if (flags & 1) {
|
||||
fprintf(stderr, "plop from %s\n", __func__);
|
||||
}
|
||||
|
||||
@@ -133,8 +122,7 @@ return OLL_KORRECT;
|
||||
* des exemples des objets POV de tTh
|
||||
*
|
||||
*/
|
||||
int
|
||||
Image_cadre_burp_2(Image_Desc *img, int taille, int pr, int pg, int pb)
|
||||
int Image_cadre_burp_2(Image_Desc *img, int taille, int pr, int pg, int pb)
|
||||
{
|
||||
int x, y, zz;
|
||||
|
||||
@@ -142,10 +130,8 @@ int x, y, zz;
|
||||
fprintf(stderr, ">>> %s: sz %d, rgb %d %d %d\n", __func__, taille, pr, pg, pb);
|
||||
#endif
|
||||
|
||||
for (x=0; x<img->width; x++)
|
||||
{
|
||||
for (zz=0; zz<taille; zz++)
|
||||
{
|
||||
for (x=0; x<img->width; x++) {
|
||||
for (zz=0; zz<taille; zz++) {
|
||||
y = zz;
|
||||
(img->Rpix[y])[x] |= pr;
|
||||
(img->Gpix[y])[x] ^= pg;
|
||||
@@ -158,10 +144,8 @@ for (x=0; x<img->width; x++)
|
||||
}
|
||||
}
|
||||
|
||||
for (y=taille; y<img->height-taille; y++)
|
||||
{
|
||||
for (zz=0; zz<taille; zz++)
|
||||
{
|
||||
for (y=taille; y<img->height-taille; y++) {
|
||||
for (zz=0; zz<taille; zz++) {
|
||||
x = zz;
|
||||
(img->Rpix[y])[x] |= pr;
|
||||
(img->Gpix[y])[x] ^= pg;
|
||||
@@ -177,13 +161,13 @@ for (y=taille; y<img->height-taille; y++)
|
||||
return OLL_KORRECT;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_cadre_burp_3(Image_Desc *img, int taille, int pr, int pg, int pb)
|
||||
int Image_cadre_burp_3(Image_Desc *img, int taille, int pr, int pg, int pb)
|
||||
{
|
||||
int foo;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, "Cadre burp3 on %p\n", img);
|
||||
fprintf(stderr, ">>> %s ( %p %d %d %d %d)\n", __func__, img, taille,
|
||||
pr, pg, pb);
|
||||
#endif
|
||||
|
||||
foo = Image_cadre_burp_2(img, taille, pr, pg, pb);
|
||||
@@ -201,7 +185,7 @@ int foo;
|
||||
int r, g, b;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, "%s : img at %p, taille=%d\n", __func__, img, taille);
|
||||
fprintf(stderr, ">>> %s ( %p %d )\n", __func__, img, taille);
|
||||
#endif
|
||||
|
||||
#define RASTA_RAND 4
|
||||
@@ -210,33 +194,30 @@ rect.x = rect.y = 0;
|
||||
rect.w = img->width;
|
||||
rect.h = img->height;
|
||||
|
||||
for (foo=0; foo<taille; foo++)
|
||||
{
|
||||
for (foo=0; foo<taille; foo++) {
|
||||
r = 220 + (rand() % RASTA_RAND);
|
||||
b = 10 + (rand() % RASTA_RAND);
|
||||
Image_draw_rect(img, &rect, r, 10, b);
|
||||
Image_draw_rect(img, &rect, r, 12, b);
|
||||
rect.x++; rect.y++;
|
||||
rect.h-=2; rect.w-=2;
|
||||
}
|
||||
for (foo=0; foo<taille; foo++)
|
||||
{
|
||||
for (foo=0; foo<taille; foo++) {
|
||||
r = 220 + (rand() % RASTA_RAND);
|
||||
g = 200 + (rand() % RASTA_RAND);
|
||||
Image_draw_rect(img, &rect, r, g, 10);
|
||||
Image_draw_rect(img, &rect, r, g, 12);
|
||||
rect.x++; rect.y++;
|
||||
rect.h-=2; rect.w-=2;
|
||||
}
|
||||
for (foo=0; foo<taille; foo++)
|
||||
{
|
||||
for (foo=0; foo<taille; foo++) {
|
||||
g = 220 + (rand() % RASTA_RAND);
|
||||
b = 10 + (rand() % RASTA_RAND);
|
||||
Image_draw_rect(img, &rect, 10, g, b);
|
||||
Image_draw_rect(img, &rect, 12, g, b);
|
||||
rect.x++; rect.y++;
|
||||
rect.h-=2; rect.w-=2;
|
||||
}
|
||||
|
||||
img->modified = 1;
|
||||
|
||||
return FUNC_IS_BETA;
|
||||
return OLL_KORRECT;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
calcluts.c
|
||||
----------
|
||||
|
||||
voir aussi: luts15bits.c
|
||||
voir aussi: luts15bits.c & palettes.c
|
||||
|
||||
*/
|
||||
|
||||
@@ -17,29 +17,26 @@
|
||||
#include "../tthimage.h"
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_calclut_lin(int *lut, int v0, int v255)
|
||||
int Image_calclut_lin(int *lut, int v0, int v255)
|
||||
{
|
||||
int foo, quux, delta;
|
||||
|
||||
#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
|
||||
|
||||
delta = v255 - v0;
|
||||
if (delta == 0)
|
||||
{
|
||||
if (delta == 0) {
|
||||
return DIVISOR_IS_0;
|
||||
}
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, "calclut lin: delta = %d\n", delta);
|
||||
fprintf(stderr, " calclut lin: delta = %d\n", delta);
|
||||
#endif
|
||||
|
||||
for (foo=0; foo<256; foo++)
|
||||
{
|
||||
for (foo=0; foo<256; foo++) {
|
||||
quux = (foo * delta / 255) + v0;
|
||||
#if DEBUG_LEVEL
|
||||
#if DEBUG_LEVEL > 1
|
||||
printf("lut(%d) = %d\n", foo, quux);
|
||||
#endif
|
||||
lut[foo] = quux;
|
||||
@@ -48,66 +45,53 @@ for (foo=0; foo<256; foo++)
|
||||
return FUNC_IS_ALPHA;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_calclut_foo(int *lut, int v0, int v255)
|
||||
int 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;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_print_lut(int *lut, char *fname, int flag)
|
||||
int Image_print_lut(int *lut, char *fname, int flag)
|
||||
{
|
||||
FILE *fp;
|
||||
int foo;
|
||||
|
||||
if (strcmp(fname, "-"))
|
||||
fp = fopen(fname, "w");
|
||||
else
|
||||
fp = stdout;
|
||||
if (strcmp(fname, "-")) fp = fopen(fname, "w");
|
||||
else fp = stdout;
|
||||
|
||||
for (foo=0; foo<256; foo++)
|
||||
{
|
||||
if (flag)
|
||||
printf("%d ", foo);
|
||||
printf("%d\n", lut[foo]);
|
||||
for (foo=0; foo<256; foo++) {
|
||||
if (flag) printf("%4d ", foo);
|
||||
printf(" %4d\n", lut[foo]);
|
||||
}
|
||||
|
||||
if (fp!=stdout)
|
||||
fclose(fp);
|
||||
if (fp!=stdout) fclose(fp);
|
||||
|
||||
return FUNC_IS_ALPHA;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_load_lut(int *lut, char *fname, int flag)
|
||||
int Image_load_lut(int *lut, char *fname, int flag)
|
||||
{
|
||||
FILE *fp;
|
||||
int value, foo, idx;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p '%s' )\n", __func__, fname, lut);
|
||||
#endif
|
||||
|
||||
if (flag) {
|
||||
fprintf(stderr, "in %s, flag must be O, was %d\n", __func__, flag);
|
||||
return WRONG_FLAG;
|
||||
}
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, "load_lut %s in %p\n", fname, lut);
|
||||
#endif
|
||||
|
||||
if (NULL==(fp=fopen(fname, "r")))
|
||||
{
|
||||
if (NULL==(fp=fopen(fname, "r"))) {
|
||||
fprintf(stderr, "%s can't fopen %s\n", __func__, fname);
|
||||
return 666;
|
||||
}
|
||||
|
||||
/* 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);
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, "load lut %3d %3d %d\n", idx, foo, value);
|
||||
#endif
|
||||
if (1==foo) lut[idx] = value;
|
||||
else lut[idx] = -1;
|
||||
}
|
||||
|
||||
@@ -246,14 +246,13 @@ return OLL_KORRECT;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
|
||||
int
|
||||
Image_LUT_mono(Image_Desc *src, Image_Desc *dst, int *lut)
|
||||
int Image_LUT_mono(Image_Desc *src, Image_Desc *dst, int *lut)
|
||||
{
|
||||
int x, y, foo;
|
||||
|
||||
if ( (foo=Image_compare_desc(src, dst)) )
|
||||
{
|
||||
fprintf(stderr, "Image_LUT_mono: images differentes %d\n", foo);
|
||||
fprintf(stderr, "%s: images differentes %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
@@ -267,7 +266,7 @@ for (y=0; y<src->height; y++)
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
return OLL_KORRECT;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/* et en parlant de LUTs, il n'y aurait pas un truc pour les LUTs
|
||||
|
||||
@@ -11,8 +11,7 @@
|
||||
#include "../tthimage.h"
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_col4bits_and(Image_Desc *src, Image_Desc *dst)
|
||||
int Image_col4bits_and(Image_Desc *src, Image_Desc *dst)
|
||||
{
|
||||
int foo;
|
||||
|
||||
@@ -52,13 +51,13 @@ static int compare_teinte(struct elem *p1, struct elem *p2)
|
||||
{
|
||||
int r1, g1, b1, r2, b2, g2;
|
||||
|
||||
r1 = (( (p1->rgb) >>8)&0xf)<<4;
|
||||
g1 = (( (p1->rgb) >>4)&0xf)<<4;
|
||||
b1 = ( (p1->rgb) &0xf)<<4;
|
||||
r1 = (( (p1->rgb) >>8)&0xf) <<4;
|
||||
g1 = (( (p1->rgb) >>4)&0xf) <<4;
|
||||
b1 = ( (p1->rgb) &0xf) <<4;
|
||||
|
||||
r2 = (( (p2->rgb) >>8)&0xf)<<4;
|
||||
g2 = (( (p2->rgb) >>4)&0xf)<<4;
|
||||
b2 = ( (p2->rgb) &0xf)<<4;
|
||||
r2 = (( (p2->rgb) >>8)&0xf) <<4;
|
||||
g2 = (( (p2->rgb) >>4)&0xf) <<4;
|
||||
b2 = ( (p2->rgb) &0xf) <<4;
|
||||
|
||||
/* printf("%8d %8d\n", p1->compte, p2->compte);
|
||||
return (p1->rgb - p2->rgb); */
|
||||
@@ -67,10 +66,11 @@ return ( (r1+g1+b1) - (r2+g2+b2) );
|
||||
}
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
|
||||
/*
|
||||
* XXX please explain parameters usage !
|
||||
*/
|
||||
#define TAILLE (1<<12)
|
||||
int
|
||||
Image_calc_Map_4bits(Image_Desc *img, RGB_map *map, int nbre)
|
||||
int Image_calc_Map_4bits(Image_Desc *img, RGB_map *map, int nbre)
|
||||
{
|
||||
long surface, maxi;
|
||||
int x, y, r, g, b, idx;
|
||||
@@ -81,35 +81,30 @@ struct elem elems[TAILLE];
|
||||
fprintf(stderr, " Calc map 4 bits: nbre = %d\n", nbre);
|
||||
#endif
|
||||
|
||||
if ( (nbre<1) || (nbre>255) )
|
||||
{
|
||||
fprintf(stderr, "Calc map 4 bits: nbre %d out of range\n", nbre);
|
||||
if ( (nbre<1) || (nbre>255) ) {
|
||||
fprintf(stderr, "%s: nbre %d out of range\n", __func__, nbre);
|
||||
return BAD_COLOR_NUMBER;
|
||||
}
|
||||
|
||||
surface = img->width * img->height;
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, " calc Map 4 bits: surface de l'image = %ld pixels\n", surface);
|
||||
fprintf(stderr, "%s: surface de l'image = %ld pixels\n", __func__, surface);
|
||||
#endif
|
||||
|
||||
for (x=0; x<TAILLE; x++)
|
||||
{
|
||||
for (x=0; x<TAILLE; x++) {
|
||||
elems[x].compte = 0L;
|
||||
elems[x].rgb = x;
|
||||
}
|
||||
|
||||
maxi = 0L;
|
||||
for (x=0; x<img->width; x++)
|
||||
{
|
||||
for (y=0; y<img->height; y++)
|
||||
{
|
||||
for (x=0; x<img->width; x++) {
|
||||
for (y=0; y<img->height; y++) {
|
||||
r = (img->Rpix[y])[x] >> 4;
|
||||
g = (img->Gpix[y])[x] >> 4;
|
||||
b = (img->Bpix[y])[x] >> 4;
|
||||
idx = (r<<8) | (g<<4) | b;
|
||||
|
||||
if (idx >= TAILLE)
|
||||
{
|
||||
if (idx >= TAILLE) {
|
||||
fprintf(stderr, "FATAL ERROR in %s\n", __func__);
|
||||
exit(5);
|
||||
}
|
||||
@@ -119,7 +114,7 @@ for (x=0; x<img->width; x++)
|
||||
}
|
||||
}
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, " Map4bits: compte maximum = %ld\n", maxi);
|
||||
fprintf(stderr, "%s: compte maximum = %ld\n", __func__, maxi);
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -130,7 +125,6 @@ qsort(elems, TAILLE, sizeof(struct elem), compare_compteur);
|
||||
|
||||
/*
|
||||
* trier la palette, certe, mais dans quel ordre ?
|
||||
*
|
||||
* 28 Jan 2002: why ?
|
||||
*/
|
||||
qsort(elems, nbre, sizeof(struct elem), compare_teinte);
|
||||
@@ -138,8 +132,7 @@ qsort(elems, nbre, sizeof(struct elem), compare_teinte);
|
||||
/*
|
||||
* recopier les 'nbre' entrees hautes dans la palette
|
||||
*/
|
||||
for(x=0; x<nbre; x++)
|
||||
{
|
||||
for(x=0; x<nbre; x++) {
|
||||
y = elems[x].rgb;
|
||||
|
||||
r = ((y>>8)&0xf)<<4;
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "../tthimage.h"
|
||||
|
||||
#define DEBUG_LEVEL 1
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/*
|
||||
* ATTENTION: cette fonction sert à faire des essais, et ne doit
|
||||
@@ -16,8 +18,7 @@
|
||||
*
|
||||
* n is the number of wanted colors
|
||||
*/
|
||||
int
|
||||
Image_essai_col_reduce(Image_Desc *src, Image_Desc *dst, int n, int t)
|
||||
int Image_essai_col_reduce(Image_Desc *src, Image_Desc *dst, int n, int t)
|
||||
{
|
||||
RGB_map map;
|
||||
int foo;
|
||||
|
||||
@@ -489,6 +489,8 @@ d->modified = 1;
|
||||
return OLL_KORRECT;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/* what are the three magic constants *_COEF ?
|
||||
*/
|
||||
int Image_to_gray(Image_Desc *s, Image_Desc *d, int flag)
|
||||
{
|
||||
int foo;
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
|
||||
made by Thierry Boudet, aka "Oulala", aka "Tonton Th".
|
||||
|
||||
ces fonctions combinent de diverses façons deux images
|
||||
ces fonctions combinent de diverses facons deux images
|
||||
de memes dimensions. on pourra, par exemple, les utiliser
|
||||
pour comparer deux traitements.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "../tthimage.h"
|
||||
|
||||
@@ -21,20 +22,19 @@
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/*
|
||||
* le paramètre 'zak' n'est pas utilisé et doit être mis à 0
|
||||
* le parametre 'zak' n'est pas utilise et doit etre mis a 0
|
||||
*/
|
||||
int
|
||||
Image_combine_lines(Image_Desc *s1, Image_Desc *s2, Image_Desc *d,
|
||||
int Image_combine_lines(Image_Desc *s1, Image_Desc *s2, Image_Desc *d,
|
||||
int sy, int oy, int zak)
|
||||
{
|
||||
int foo, x, y, my, r, g, b;
|
||||
|
||||
if (sy == 0) {
|
||||
fprintf(stderr, "Combine Lines: sy is zer0 and zak is %d\n", zak);
|
||||
fprintf(stderr, "%s: sy is 0 and zak is %d\n", __func__, zak);
|
||||
return DIVISOR_IS_ZERO;
|
||||
}
|
||||
if ( (foo=Image_compare_desc(s1, s2)) ) {
|
||||
fprintf(stderr, "Combine Lines: sources are differents (%d)\n", foo);
|
||||
fprintf(stderr, "%s: sources are differents (%d)\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
@@ -65,14 +65,17 @@ return OLL_KORRECT;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/*
|
||||
* le paramètre 'zak' n'est pas utilisé et doit être mis à 0
|
||||
* le parametre 'zak' n'est pas utilise et doit etre mis a 0
|
||||
*/
|
||||
int
|
||||
Image_combine_columns(Image_Desc *s1, Image_Desc *s2, Image_Desc *d,
|
||||
int Image_combine_columns(Image_Desc *s1, Image_Desc *s2, Image_Desc *d,
|
||||
int sx, int ox, int zak)
|
||||
{
|
||||
int foo, x, y, mx, r, g, b;
|
||||
|
||||
if (zak) {
|
||||
fprintf(stderr, "in %s, zak is not 0\n", __func__);
|
||||
}
|
||||
|
||||
if (sx == 0) {
|
||||
fprintf(stderr, "Combine Columns: sx is zer0\n");
|
||||
return DIVISOR_IS_ZERO;
|
||||
@@ -116,8 +119,7 @@ return OLL_KORRECT;
|
||||
*
|
||||
* 'zak' parameter is not used, and must be 0.
|
||||
*/
|
||||
int
|
||||
Image_combine_checker(Image_Desc *s1, Image_Desc *s2, Image_Desc *d,
|
||||
int Image_combine_checker(Image_Desc *s1, Image_Desc *s2, Image_Desc *d,
|
||||
int sx, int sy, int ox, int oy, int zak)
|
||||
{
|
||||
int foo, r, g, b;
|
||||
@@ -176,8 +178,7 @@ return 0;
|
||||
*
|
||||
* Tiens, le parametre 'yo' ne sert a rien ?
|
||||
*/
|
||||
int
|
||||
Image_combine_cercle_flou(Image_Desc *s1, Image_Desc *s2, Image_Desc *d, int yo)
|
||||
int Image_combine_cercle_flou(Image_Desc *s1, Image_Desc *s2, Image_Desc *d, int yo)
|
||||
{
|
||||
int foo;
|
||||
int xcenter, ycenter;
|
||||
@@ -240,19 +241,22 @@ return OLL_KORRECT;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/*
|
||||
* le flag 'yo' decide quelle image sera en haut à droite.
|
||||
* les paramètres p1 & p2 ne sont pas utilisés.
|
||||
* le flag 'yo' decide quelle image sera en haut a droite.
|
||||
* les parametres p1 & p2 ne sont pas utilises.
|
||||
*/
|
||||
int
|
||||
Image_combine_diagonale(Image_Desc *s1, Image_Desc *s2, Image_Desc *d,
|
||||
int Image_combine_diagonale(Image_Desc *s1, Image_Desc *s2, Image_Desc *d,
|
||||
int yo, int p1, int p2)
|
||||
{
|
||||
int foo;
|
||||
int x, y, r, g, b;
|
||||
int vertical, offset;
|
||||
|
||||
if ( p1 || p2 ) {
|
||||
fprintf(stderr, "%s: bad p1 %d or bad p2 %d\n", __func__, p1, p2);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -296,6 +300,7 @@ for (y=0; y<s1->height; y++) {
|
||||
}
|
||||
/*
|
||||
* 30 sept 2008 : est-ce que cette fonction a subi un bon fuzzing ?
|
||||
* 9 aout 2024 : non, pas encore ;)
|
||||
*/
|
||||
return OLL_KORRECT;
|
||||
}
|
||||
@@ -305,8 +310,7 @@ return OLL_KORRECT;
|
||||
we put in the destination image the min/max value
|
||||
of the RGB componants.
|
||||
*/
|
||||
int
|
||||
Image_combine_minmax(Image_Desc *s1, Image_Desc *s2, Image_Desc *d, int flg)
|
||||
int Image_combine_minmax(Image_Desc *s1, Image_Desc *s2, Image_Desc *d, int flg)
|
||||
{
|
||||
int foo, x, y, r, g, b;
|
||||
int r1, r2, g1, g2, b1, b2;
|
||||
@@ -349,11 +353,10 @@ return OLL_KORRECT;
|
||||
/*
|
||||
* fonction faite pour le finisseur de DBvsEE
|
||||
*
|
||||
* 6 oct 2001: une version qui permettrait de spécifier les
|
||||
* 6 oct 2001: une version qui permettrait de specifier les
|
||||
* seuils en r,g et b serait assez pratique aussi.
|
||||
*/
|
||||
int
|
||||
Image_combine_if_not_black(Image_Desc *s1, Image_Desc *s2, Image_Desc *d)
|
||||
int Image_combine_if_not_black(Image_Desc *s1, Image_Desc *s2, Image_Desc *d)
|
||||
{
|
||||
int foo, x, y, r, g, b;
|
||||
|
||||
@@ -389,8 +392,7 @@ return FUNC_IS_BETA; /* XXX c'est pas du OLL_KORRECT ? */
|
||||
/*
|
||||
* gni ?
|
||||
*/
|
||||
int
|
||||
Image_poke_2zones(Image_Desc *src, Image_Desc *ia, Image_Desc *ib,
|
||||
int Image_poke_2zones(Image_Desc *src, Image_Desc *ia, Image_Desc *ib,
|
||||
Image_Rect *za, Image_Rect *zb,
|
||||
Image_Desc *dst)
|
||||
{
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
/*
|
||||
Le coefficient K va de 0 a 10000 !
|
||||
*/
|
||||
int
|
||||
Image_mix(Image_Desc *a, Image_Desc *b, Image_Desc *c, int k)
|
||||
int Image_mix(Image_Desc *a, Image_Desc *b, Image_Desc *c, int k)
|
||||
{
|
||||
int x, y;
|
||||
int ra, rb, mk;
|
||||
@@ -25,7 +24,7 @@ int foo;
|
||||
if ( (foo=Image_compare_desc(a, b)) ||
|
||||
(foo=Image_compare_desc(a, c)) )
|
||||
{
|
||||
fprintf(stderr, "Image mix: images differentes %s\n", Image_err2str(foo));
|
||||
fprintf(stderr, "%s: images differentes %s\n", __func__, Image_err2str(foo));
|
||||
fprintf(stderr, " a %dx%d b %dx%d c %dx%d\n",
|
||||
a->width, a->height,
|
||||
b->width, b->height,
|
||||
@@ -38,14 +37,12 @@ fprintf(stderr, "Mixing: %p and %p to %p, k=%d\n", a, b, c, k);
|
||||
#endif
|
||||
|
||||
mk = 10000 - k;
|
||||
for (y=0; y<a->height; y++)
|
||||
{
|
||||
for (y=0; y<a->height; y++) {
|
||||
pra = a->Rpix[y]; prb = b->Rpix[y]; prk = c->Rpix[y];
|
||||
pga = a->Gpix[y]; pgb = b->Gpix[y]; pgk = c->Gpix[y];
|
||||
pba = a->Bpix[y]; pbb = b->Bpix[y]; pbk = c->Bpix[y];
|
||||
|
||||
for (x=0; x<a->width; x++)
|
||||
{
|
||||
for (x=0; x<a->width; x++) {
|
||||
ra = pra[x];
|
||||
rb = prb[x];
|
||||
prk[x] = ((ra * k) + (rb * mk)) / 10000;
|
||||
@@ -66,8 +63,7 @@ return 0;
|
||||
/* new 6 nov 2001
|
||||
Les coefficients K[rgb] vont de 0 a 10000 !
|
||||
*/
|
||||
int
|
||||
Image_mix_rgb(Image_Desc *a, Image_Desc *b, Image_Desc *c,
|
||||
int Image_mix_rgb(Image_Desc *a, Image_Desc *b, Image_Desc *c,
|
||||
int kr, int kg, int kb)
|
||||
{
|
||||
int foo, x, y;
|
||||
|
||||
@@ -13,42 +13,35 @@
|
||||
/*
|
||||
* un kludge en chantier. programmation à la 'Gruiik' en vue.
|
||||
*/
|
||||
int
|
||||
Image_combine_waou(Image_Desc *s1, Image_Desc *s2, Image_Desc *dst,
|
||||
int Image_combine_waou(Image_Desc *s1, Image_Desc *s2, Image_Desc *dst,
|
||||
int a, int b, int c, int d)
|
||||
{
|
||||
int x, y, foo;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, "%s ( %p %p %p %d : %d %d (%d) )\n",
|
||||
fprintf(stderr, ">>> %s ( %p %p %p %d : %d %d (%d) )\n",
|
||||
__func__, s1, s2, dst, a, b, c, d);
|
||||
#endif
|
||||
|
||||
if ( (foo=Image_compare_desc(s1, s2)) )
|
||||
{
|
||||
if ( (foo=Image_compare_desc(s1, s2)) ) {
|
||||
fprintf(stderr, "%s : sources are differents %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
if ( (foo=Image_compare_desc(s1, dst)) )
|
||||
{
|
||||
if ( (foo=Image_compare_desc(s1, dst)) ) {
|
||||
fprintf(stderr, "%s : destination bad dims %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
for (y=0; y<dst->height; y++)
|
||||
{
|
||||
for (x=0; x<dst->width; x++)
|
||||
{
|
||||
if (d)
|
||||
{
|
||||
for (y=0; y<dst->height; y++) {
|
||||
for (x=0; x<dst->width; x++) {
|
||||
if (d) {
|
||||
/* canonical function */
|
||||
(dst->Rpix[y])[x] = (x & (s1->Rpix[y])[x]) | a;
|
||||
(dst->Gpix[y])[x] = x | b;
|
||||
(dst->Bpix[y])[x] = (y & (s2->Rpix[y])[x]) | c;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
/* new 9 mars 2010 - ave St Ex */
|
||||
(dst->Rpix[y])[x] = (x & (s1->Rpix[y])[x]) ^ a;
|
||||
(dst->Gpix[y])[x] = x ^ b;
|
||||
@@ -63,8 +56,7 @@ return FUNC_IS_BETA;
|
||||
/*
|
||||
* un kludge en chantier. programmation à la 'Gruiik' en vue.
|
||||
*/
|
||||
int
|
||||
Image_combine_wauo(Image_Desc *s1, Image_Desc *s2, Image_Desc *dst,
|
||||
int Image_combine_wauo(Image_Desc *s1, Image_Desc *s2, Image_Desc *dst,
|
||||
int flag)
|
||||
{
|
||||
int x, y, foo;
|
||||
@@ -72,31 +64,25 @@ int x, y, foo;
|
||||
if ( flag )
|
||||
fprintf(stderr, "Combine Wauo: flag = %d ?\n", flag);
|
||||
|
||||
if ( (foo=Image_compare_desc(s1, s2)) )
|
||||
{
|
||||
if ( (foo=Image_compare_desc(s1, s2)) ) {
|
||||
fprintf(stderr, "Combine Wauo: sources are differents %d\n", foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
if ( (foo=Image_compare_desc(s1, dst)) )
|
||||
{
|
||||
if ( (foo=Image_compare_desc(s1, dst)) ) {
|
||||
fprintf(stderr, "Combine Wauo: destination bad dims %d\n", foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
for (y=1; y<dst->height-1; y++)
|
||||
{
|
||||
for (x=1; x<dst->width-1; x++)
|
||||
{
|
||||
for (y=1; y<dst->height-1; y++) {
|
||||
for (x=1; x<dst->width-1; x++) {
|
||||
(dst->Rpix[y])[x] = (s1->Rpix[y][x] + s2->Rpix[y][x])/2;
|
||||
|
||||
if (s1->Rpix[y][x] > s2->Rpix[y][x])
|
||||
{
|
||||
if (s1->Rpix[y][x] > s2->Rpix[y][x]) {
|
||||
(dst->Gpix[y])[x] = (s1->Gpix[y])[x];
|
||||
(dst->Bpix[y])[x] = (s2->Bpix[y])[x];
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
(dst->Gpix[y])[x] = (s2->Gpix[y])[x];
|
||||
(dst->Bpix[y])[x] = (s1->Bpix[y])[x];
|
||||
}
|
||||
@@ -109,31 +95,26 @@ return OLL_KORRECT;
|
||||
/*
|
||||
* threshold values (sr, sg, sb) are in the pix range [0..255]
|
||||
*/
|
||||
int
|
||||
Image_combine_seuils(Image_Desc *s1, Image_Desc *s2, Image_Desc *dst,
|
||||
int Image_combine_seuils(Image_Desc *s1, Image_Desc *s2, Image_Desc *dst,
|
||||
int sr, int sb, int sg)
|
||||
{
|
||||
int x, y, foo;
|
||||
int r, g, b;
|
||||
|
||||
if ( (foo=Image_compare_desc(s1, s2)) )
|
||||
{
|
||||
if ( (foo=Image_compare_desc(s1, s2)) ) {
|
||||
fprintf(stderr, "Combine Seuils: sources are differents %d\n", foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
if ( (foo=Image_compare_desc(s1, dst)) )
|
||||
{
|
||||
if ( (foo=Image_compare_desc(s1, dst)) ) {
|
||||
fprintf(stderr, "Combine Seuils: destination bad dims %d\n", foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
sr*=2; sg*=2; sb*=2;
|
||||
|
||||
for (y=0; y<dst->height; y++)
|
||||
{
|
||||
for (x=0; x<dst->width; x++)
|
||||
{
|
||||
for (y=0; y<dst->height; y++) {
|
||||
for (x=0; x<dst->width; x++) {
|
||||
if ( (s1->Rpix[y][x] + s2->Rpix[y][x]) > sr )
|
||||
r = s1->Rpix[y][x];
|
||||
else
|
||||
|
||||
@@ -88,7 +88,7 @@ int Image_XOR(Image_Desc *s1, Image_Desc *s2, Image_Desc *d, int k)
|
||||
int foo, x, y;
|
||||
|
||||
#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
|
||||
|
||||
if ( (foo=Image_compare_desc(s1, s2)) )
|
||||
|
||||
@@ -6,6 +6,67 @@
|
||||
#include <math.h>
|
||||
#include "../tthimage.h"
|
||||
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/*
|
||||
* new: Fri Sep 15 20:18:35 UTC 2023
|
||||
* inspired by the same func in FloatImg
|
||||
*/
|
||||
int Image_egalise_cos01(Image_Desc *source, Image_Desc *but, int k)
|
||||
{
|
||||
(void)k; /* WARNING KILLER */
|
||||
int lut[256], uc, idx, foo;
|
||||
float fidx;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__,
|
||||
source, but, k);
|
||||
#endif
|
||||
|
||||
if ( (foo=Image_compare_desc(source, but)) ) {
|
||||
fprintf(stderr, "%s: images not compatible, %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
for (idx=0; idx<256; idx++) {
|
||||
fidx = (float)idx / 255.0;
|
||||
uc = (unsigned char)(255.0*(0.5 - 0.5 * cos(3.141592654*fidx)));
|
||||
lut[idx] = uc;
|
||||
/* printf("%7d %7d\n", idx, uc); */
|
||||
}
|
||||
Image_LUT_mono(source, but, lut);
|
||||
|
||||
return OLL_KORRECT;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/*
|
||||
* new: Fri Sep 15 20:32:12 UTC 2023
|
||||
* inspired by the same func in FloatImg
|
||||
*/
|
||||
int Image_egalise_cos010(Image_Desc *source, Image_Desc *but, int k)
|
||||
{
|
||||
(void)k; /* WARNING KILLER */
|
||||
int lut[256], uc, idx, foo;
|
||||
float fidx;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__,
|
||||
source, but, k);
|
||||
#endif
|
||||
|
||||
if ( (foo=Image_compare_desc(source, but)) ) {
|
||||
fprintf(stderr, "%s: images not compatible, %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
for (idx=0; idx<256; idx++) {
|
||||
fidx = (float)idx / 255.0;
|
||||
uc = (unsigned char)(255.0*(0.5 - 0.5 * cos(3.141592654*fidx*2.0)));
|
||||
lut[idx] = uc;
|
||||
/* printf("%7d %7d\n", idx, uc); */
|
||||
}
|
||||
Image_LUT_mono(source, but, lut);
|
||||
|
||||
return OLL_KORRECT;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/*
|
||||
* cette fonction peut etre utilisee avec la meme image
|
||||
@@ -20,6 +81,10 @@ float fr, fg, fb;
|
||||
fprintf(stderr, "%s : %p -> %p\n", __func__, source, but);
|
||||
#endif
|
||||
|
||||
if (k) {
|
||||
fprintf(stderr, "In %s, k must be 0, was %d\n", __func__, k);
|
||||
}
|
||||
|
||||
if ( (foo=Image_compare_desc(source, but)) ) {
|
||||
fprintf(stderr, "%s : images are differents %d\n", __func__, foo);
|
||||
return foo;
|
||||
@@ -55,6 +120,10 @@ float fr, fg, fb;
|
||||
fprintf(stderr, "%s : %p -> %p\n", __func__, source, but);
|
||||
#endif
|
||||
|
||||
if (k) {
|
||||
fprintf(stderr, "In %s, k must be 0, was %d\n", __func__, k);
|
||||
}
|
||||
|
||||
if ( (foo=Image_compare_desc(source, but)) ) {
|
||||
fprintf(stderr, "%s : images are differents %d\n", __func__, foo);
|
||||
return foo;
|
||||
|
||||
110
Lib/dither.c
110
Lib/dither.c
@@ -12,11 +12,14 @@
|
||||
en entree, on doit avoir une image RGB, sinon, "segfault"
|
||||
le parametre 'uh' represente l'intensite de la couleur 'on'
|
||||
*/
|
||||
int
|
||||
Image_dither_Bayer_0(Image_Desc *s, Image_Desc *d, int uh)
|
||||
int Image_dither_Bayer_0(Image_Desc *s, Image_Desc *d, int uh)
|
||||
{
|
||||
int dx, dy, x, y, r, g, b;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, s, d, uh);
|
||||
#endif
|
||||
|
||||
/* directement copie de la page 389 de "Bitmapped graphics" de
|
||||
Steve Rimmer. */
|
||||
|
||||
@@ -57,18 +60,19 @@ return OLL_KORRECT;
|
||||
* 19 Juin 2000: dithering on a 2x2 matrice.
|
||||
* 15 Nov 2001: 'uh' parameter is _now_ working ;-}
|
||||
*/
|
||||
int
|
||||
Image_dither_crude(Image_Desc *s, Image_Desc *d, int uh)
|
||||
int Image_dither_crude(Image_Desc *s, Image_Desc *d, int uh)
|
||||
{
|
||||
int x, y, r, g, b;
|
||||
int som;
|
||||
|
||||
Image_clear(d, 0, 0, 0);
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, s, d, uh);
|
||||
#endif
|
||||
|
||||
for (x=0; x<(s->width-1); x+=2)
|
||||
{
|
||||
for (y=0; y<(s->height-1); y+=2)
|
||||
{
|
||||
if (s != d) Image_clear(d, 0, 0, 0);
|
||||
|
||||
for (x=0; x<(s->width-1); x+=2) {
|
||||
for (y=0; y<(s->height-1); y+=2) {
|
||||
r = g = b = 0;
|
||||
r += Image_R_pixel(s, x, y);
|
||||
r += Image_R_pixel(s, x+1, y);
|
||||
@@ -96,14 +100,8 @@ for (x=0; x<(s->width-1); x+=2)
|
||||
|
||||
som = r + g + b;
|
||||
|
||||
if (som < 2048)
|
||||
{
|
||||
Image_plotRGB(d, x+1, y+1, 0, 0, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
Image_plotRGB(d, x+1, y+1, uh, uh, uh);
|
||||
}
|
||||
if (som < 2048) Image_plotRGB(d, x+1, y+1, 0, 0, 0);
|
||||
else Image_plotRGB(d, x+1, y+1, uh, uh, uh);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,27 +109,28 @@ return OLL_KORRECT;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/*
|
||||
* ça ne marche pas très fort, ce truc...
|
||||
* Il ne marche pas tres fort, ce truc...
|
||||
*/
|
||||
int
|
||||
Image_dither_2x2(Image_Desc *s, Image_Desc *d, int uh)
|
||||
int Image_dither_2x2(Image_Desc *s, Image_Desc *d, int uh)
|
||||
{
|
||||
int x, y, xm, ym;
|
||||
int r, g, b, v;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, s, d, uh);
|
||||
#endif
|
||||
|
||||
x = s->width; xm = (x&1) ? (x-1) : x;
|
||||
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
|
||||
fprintf(stderr, "dither 2x2: %d %d %d %d\n", x, xm, y, ym);
|
||||
#endif
|
||||
|
||||
for (x=0; x<xm; x+=2)
|
||||
{
|
||||
for (y=0; y<ym; y+=2)
|
||||
{
|
||||
for (x=0; x<xm; x+=2) {
|
||||
for (y=0; y<ym; y+=2) {
|
||||
/*
|
||||
* bon sang, mais que faire ici ?
|
||||
*/
|
||||
@@ -155,24 +154,24 @@ for (x=0; x<xm; x+=2)
|
||||
return FUNC_IS_ALPHA;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_dither_seuil_random(Image_Desc *s, Image_Desc *d, int uh)
|
||||
int Image_dither_seuil_random(Image_Desc *s, Image_Desc *d, int uh)
|
||||
{
|
||||
int x, y, r, g, b;
|
||||
int foo;
|
||||
|
||||
if ( (foo=Image_compare_desc(s, d)) )
|
||||
{
|
||||
fprintf(stderr, "dither seuil random: images are differents %d\n", foo);
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, s, d, uh);
|
||||
#endif
|
||||
|
||||
if ( (foo=Image_compare_desc(s, d)) ) {
|
||||
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
Image_clear(d, 0, 0, 0);
|
||||
if (s != d) Image_clear(d, 0, 0, 0);
|
||||
|
||||
for (y=0; y<s->height; y++)
|
||||
{
|
||||
for (x=0; x<s->width; x++)
|
||||
{
|
||||
for (y=0; y<s->height; y++) {
|
||||
for (x=0; x<s->width; x++) {
|
||||
if (s->Rpix[y][x] < rand() % 256) r = 0;
|
||||
else r = uh;
|
||||
|
||||
@@ -195,35 +194,33 @@ return OLL_KORRECT;
|
||||
*
|
||||
* subtle bug: uh _must_ be 255 ?
|
||||
*/
|
||||
int
|
||||
Image_dither_simple_error(Image_Desc *s, Image_Desc *d, int uh)
|
||||
int Image_dither_simple_error(Image_Desc *s, Image_Desc *d, int uh)
|
||||
{
|
||||
int x, y, xa, xb, inc, errR, errG, errB;
|
||||
int r, g, b, dr, dg, db;
|
||||
int foo;
|
||||
|
||||
if ( (foo=Image_compare_desc(s, d)) )
|
||||
{
|
||||
fprintf(stderr, "dither simple error: images are differents %d\n", foo);
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, s, d, uh);
|
||||
#endif
|
||||
|
||||
if ( (foo=Image_compare_desc(s, d)) ) {
|
||||
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
Image_clear(d, 0, 0, 0);
|
||||
if (s != d) Image_clear(d, 0, 0, 0);
|
||||
errR = errG = errB = 0;
|
||||
|
||||
for (y=0; y<s->height; y++)
|
||||
{
|
||||
if (y & 1)
|
||||
{
|
||||
for (y=0; y<s->height; y++) {
|
||||
if (y & 1) {
|
||||
xa = 0; xb = s->width - 1; inc = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
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];
|
||||
if ( (r + errR) > 127 ) dr = uh;
|
||||
else dr = 0;
|
||||
@@ -253,26 +250,21 @@ return OLL_KORRECT;
|
||||
* 29 Jan 2002: may be I can buid a func for automagically
|
||||
* computing of right values ?
|
||||
*/
|
||||
int
|
||||
Image_dither_double_seuil(Image_Desc *s, Image_Desc *d, int sa, int sb, int uh)
|
||||
int Image_dither_double_seuil(Image_Desc *s, Image_Desc *d, int sa, int sb, int uh)
|
||||
{
|
||||
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);
|
||||
return foo;
|
||||
}
|
||||
|
||||
if ( sa >= sb )
|
||||
{
|
||||
if ( sa >= sb ) {
|
||||
fprintf(stderr, "dither double seuil: lo %d > hi %d !\n", sa, sb);
|
||||
}
|
||||
|
||||
for (y=0; y<s->height; y++)
|
||||
{
|
||||
for (x=0; x<s->width; x++)
|
||||
{
|
||||
for (y=0; y<s->height; y++) {
|
||||
for (x=0; x<s->width; x++) {
|
||||
r = (s->Rpix[y])[x];
|
||||
if (r < sa) r = 0;
|
||||
else if (r > sb) r = uh;
|
||||
|
||||
@@ -42,7 +42,7 @@ if ( (foo=Image_compare_desc(s, d)) )
|
||||
Image_TGA_save("/tmp/aaaa_debug_a.tga", s, 0);
|
||||
#endif
|
||||
|
||||
Image_clear(d, 0, 0, 0);
|
||||
/* XXX Image_clear(d, 0, 0, 0); */
|
||||
|
||||
for (y=0; y<s->height-3; y+=3)
|
||||
{
|
||||
@@ -108,7 +108,7 @@ if ( (foo=Image_compare_desc(s, d)) )
|
||||
fprintf(stderr, "* Image_dither_3x3_1 (%s) is experimental\n", __FILE__);
|
||||
#endif
|
||||
|
||||
Image_clear(d, 0, 0, 0);
|
||||
/* XXX Image_clear(d, 0, 0, 0); */
|
||||
|
||||
for (y=0; y<s->height-3; y+=3)
|
||||
{
|
||||
@@ -167,7 +167,7 @@ if ( (foo=Image_compare_desc(s, d)) )
|
||||
return foo;
|
||||
}
|
||||
|
||||
Image_clear(d, 0, 0, 0);
|
||||
/* XXX Image_clear(d, 0, 0, 0); */
|
||||
|
||||
return FUNC_NOT_FINISH;
|
||||
}
|
||||
@@ -183,7 +183,7 @@ if ( (foo=Image_compare_desc(s, d)) )
|
||||
return foo;
|
||||
}
|
||||
|
||||
Image_clear(d, 0, 0, 0);
|
||||
/* XXX Image_clear(d, 0, 0, 0); */
|
||||
|
||||
return FUNC_NOT_FINISH;
|
||||
}
|
||||
|
||||
@@ -8,8 +8,7 @@
|
||||
#include "../tthimage.h"
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_dither_atkinson(Image_Desc *s, Image_Desc *d, int uh)
|
||||
int Image_dither_atkinson(Image_Desc *s, Image_Desc *d, int uh)
|
||||
{
|
||||
int x, y, r, g, b;
|
||||
int foo, sr, sg, sb;
|
||||
@@ -24,10 +23,8 @@ if ( (foo=Image_compare_desc(s, d)) )
|
||||
Image_clear(d, 0, 0, 0);
|
||||
r = g = b = sr = sg = sb = 0;
|
||||
|
||||
for (y=0; y<s->height; y++)
|
||||
{
|
||||
for (x=0; x<s->width; x++)
|
||||
{
|
||||
for (y=0; y<s->height; y++) {
|
||||
for (x=0; x<s->width; x++) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -35,3 +32,77 @@ for (y=0; y<s->height; y++)
|
||||
return FUNC_NOT_FINISH;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int Image_dither_4x4_0(Image_Desc *s, Image_Desc *d, int uh)
|
||||
{
|
||||
int x, y, r, g, b;
|
||||
int foo, sr, sg, sb;
|
||||
|
||||
fprintf(stderr, "* Image_dither_4x4_0 (%s) is experimental\n", __FILE__);
|
||||
fprintf(stderr, "* Image_dither_4x4_0 le parametre est %d\n", uh);
|
||||
|
||||
if ( (foo=Image_compare_desc(s, d)) ) {
|
||||
fprintf(stderr, "dither 4x4 0: images are differents %d\n", foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
Image_clear(d, 0, 0, 0);
|
||||
|
||||
for (y=0; y<s->height; y++) {
|
||||
for (x=0; x<s->width; x++) {
|
||||
|
||||
/* XXX */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return FUNC_NOT_FINISH;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int Image_dither_bayer8x8rnd(Image_Desc *s, Image_Desc *d, int shuff, int mono)
|
||||
{
|
||||
uint16_t matrice[16][16];
|
||||
int foo, itmp, m, n;
|
||||
int x, y, r, g, b, pix;
|
||||
|
||||
fprintf(stderr, "%s ( %p %p %d %d )\n", __func__, s, d, shuff, mono);
|
||||
|
||||
/* remplissage de la matrice */
|
||||
fprintf(stderr, " init matrice\n");
|
||||
for(foo=0; foo<256; foo++) {
|
||||
((uint16_t *)matrice)[foo] = foo;
|
||||
}
|
||||
/* brasssage de la matrice */
|
||||
fprintf(stderr, " shuffle matrice %d\n", shuff);
|
||||
for (foo=0; foo<shuff; foo++) { /* magic number ? */
|
||||
m = rand() & 0xff;
|
||||
n = rand() & 0xff;
|
||||
itmp = ((uint16_t *)matrice)[n];
|
||||
((uint16_t *)matrice)[n] = ((uint16_t *)matrice)[m];
|
||||
((uint16_t *)matrice)[m] = itmp;
|
||||
}
|
||||
|
||||
for (y=0; y<s->height; y++) {
|
||||
for (x=0; x<s->width; x++) {
|
||||
r = s->Rpix[y][x];
|
||||
g = s->Gpix[y][x];
|
||||
b = s->Bpix[y][x];
|
||||
if (mono) {
|
||||
pix = (r + g +b) / 3;
|
||||
d->Rpix[y][x] = d->Gpix[y][x] = d->Bpix[y][x] = \
|
||||
(pix > matrice[x%16][y%16]) * 255;
|
||||
}
|
||||
else {
|
||||
d->Rpix[y][x] = (r > matrice[x%16][y%16]) * 255;
|
||||
d->Gpix[y][x] = (g > matrice[x%16][y%16]) * 255;
|
||||
d->Bpix[y][x] = (b > matrice[x%16][y%16]) * 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, " done\n");
|
||||
|
||||
return FULL_NUCKED;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
dither4.c
|
||||
---------
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "../tthimage.h"
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_dither_4x4_0(Image_Desc *s, Image_Desc *d, int uh)
|
||||
{
|
||||
int x, y, r, g, b;
|
||||
int foo, sr, sg, sb;
|
||||
|
||||
fprintf(stderr, "* Image_dither_4x4_0 (%s) is experimental\n", __FILE__);
|
||||
fprintf(stderr, "* Image_dither_4x4_0 le parametre est %d\n", uh);
|
||||
|
||||
if ( (foo=Image_compare_desc(s, d)) )
|
||||
{
|
||||
fprintf(stderr, "dither 4x4 0: images are differents %d\n", foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
Image_clear(d, 0, 0, 0);
|
||||
|
||||
for (y=0; y<s->height; y++)
|
||||
{
|
||||
for (x=0; x<s->width; x++)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return FUNC_NOT_FINISH;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_dither_bayer8x8rnd(Image_Desc *s, Image_Desc *d, int shuff, int mono)
|
||||
{
|
||||
uint16_t matrice[16][16];
|
||||
int foo, itmp, m, n;
|
||||
int x, y, r, g, b, pix;
|
||||
|
||||
fprintf(stderr, "%s ( %p %p %d %d )\n", __func__, s, d, shuff, mono);
|
||||
|
||||
/* remplissage de la matrice */
|
||||
fprintf(stderr, " init matrice\n");
|
||||
for(foo=0; foo<256; foo++)
|
||||
{
|
||||
((uint16_t *)matrice)[foo] = foo;
|
||||
}
|
||||
/* brasssage de la matrice */
|
||||
fprintf(stderr, " shuffle matrice %d\n", shuff);
|
||||
for (foo=0; foo<shuff; foo++) /* magic number ? */
|
||||
{
|
||||
m = rand() & 0xff;
|
||||
n = rand() & 0xff;
|
||||
itmp = ((uint16_t *)matrice)[n];
|
||||
((uint16_t *)matrice)[n] = ((uint16_t *)matrice)[m];
|
||||
((uint16_t *)matrice)[m] = itmp;
|
||||
}
|
||||
|
||||
for (y=0; y<s->height; y++)
|
||||
{
|
||||
for (x=0; x<s->width; x++)
|
||||
{
|
||||
r = s->Rpix[y][x];
|
||||
g = s->Gpix[y][x];
|
||||
b = s->Bpix[y][x];
|
||||
if (mono)
|
||||
{
|
||||
pix = (r + g +b) / 3;
|
||||
d->Rpix[y][x] = d->Gpix[y][x] = d->Bpix[y][x] = \
|
||||
(pix > matrice[x%16][y%16]) * 255;
|
||||
}
|
||||
else
|
||||
{
|
||||
d->Rpix[y][x] = (r > matrice[x%16][y%16]) * 255;
|
||||
d->Gpix[y][x] = (g > matrice[x%16][y%16]) * 255;
|
||||
d->Bpix[y][x] = (b > matrice[x%16][y%16]) * 255;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, " done\n");
|
||||
|
||||
return FULL_NUCKED;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
@@ -19,8 +19,7 @@
|
||||
/*
|
||||
* the easy one.
|
||||
*/
|
||||
int
|
||||
Image_paint_A_rect(Image_Desc *img, Image_Rect *rect, RGBA *rgba)
|
||||
int Image_paint_A_rect(Image_Desc *img, Image_Rect *rect, RGBA *rgba)
|
||||
{
|
||||
int xd, yd, xf, yf, x, y;
|
||||
int r, g, b, a0, a1, nbre;
|
||||
@@ -42,10 +41,8 @@ a1 = rgba->a;
|
||||
|
||||
nbre = 0;
|
||||
|
||||
for (x=xd; x<xf; x++)
|
||||
{
|
||||
for (y=yd; y<yf; y++)
|
||||
{
|
||||
for (x=xd; x<xf; x++) {
|
||||
for (y=yd; y<yf; y++) {
|
||||
Image_getRGB(img, x, y, &r, &g, &b);
|
||||
/*
|
||||
* ok, compute now...
|
||||
@@ -58,18 +55,15 @@ for (x=xd; x<xf; x++)
|
||||
}
|
||||
}
|
||||
|
||||
/* fprintf(stderr, "%d points traités\n", nbre); */
|
||||
|
||||
return FUNC_IS_BETA;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/*
|
||||
* new 15 Janvier 2003.
|
||||
* première utilisation: l'écriture des titres des
|
||||
* premiere utilisation: l'ecriture des titres des
|
||||
* image de l'expovsition.
|
||||
*/
|
||||
int
|
||||
Image_fade_A_rect(Image_Desc *img, Image_Rect *rect, int alpha)
|
||||
int Image_fade_A_rect(Image_Desc *img, Image_Rect *rect, int alpha)
|
||||
{
|
||||
int xd, yd, xf, yf, x, y;
|
||||
int r, g, b ;
|
||||
@@ -85,10 +79,8 @@ fprintf(stderr, "Fade Alpha Rect: %d < X < %d %d < Y < %d\n",
|
||||
fprintf(stderr, " coefficient alpha = %d\n", alpha);
|
||||
#endif
|
||||
|
||||
for (x=xd; x<xf; x++)
|
||||
{
|
||||
for (y=yd; y<yf; y++)
|
||||
{
|
||||
for (x=xd; x<xf; x++) {
|
||||
for (y=yd; y<yf; y++) {
|
||||
Image_getRGB(img, x, y, &r, &g, &b);
|
||||
/*
|
||||
* ok, compute now...
|
||||
@@ -108,34 +100,29 @@ return FUNC_IS_BETA; /* need unit testing */
|
||||
* bon, une fonction pour tamponner une image quelconque avec une
|
||||
* image alpha, il serait temps de la mettre en place, nom ?
|
||||
*/
|
||||
int
|
||||
Image_tampon_alpha_0(Image_Desc *src, Image_Desc *tampon, Image_Desc *dst)
|
||||
int Image_tampon_alpha_0(Image_Desc *src, Image_Desc *tampon, Image_Desc *dst)
|
||||
{
|
||||
int x, y, rs, gs, bs, rt, gt, bt;
|
||||
int rd, gd, bd, clean_tampon;
|
||||
|
||||
clean_tampon = 0;
|
||||
/* if the 'tampon' is not defined, we have to imagine one */
|
||||
if (NULL==tampon)
|
||||
{
|
||||
if (NULL==tampon) {
|
||||
tampon = Image_clone(src, 0);
|
||||
fprintf(stderr, "fake tampon @ %p\n", tampon);
|
||||
Image_mirror(src, tampon, 0);
|
||||
clean_tampon = 1;
|
||||
}
|
||||
|
||||
for (y=0; y<src->height; y++)
|
||||
{
|
||||
for (x=0; x<src->width; x++)
|
||||
{
|
||||
for (y=0; y<src->height; y++) {
|
||||
for (x=0; x<src->width; x++) {
|
||||
Image_getRGB(src, x, y, &rs, &gs, &bs);
|
||||
Image_getRGB(tampon, x, y, &rt, >, &bt);
|
||||
rd = (rs * rt) / 256;
|
||||
}
|
||||
}
|
||||
|
||||
if (clean_tampon)
|
||||
{
|
||||
if (clean_tampon) {
|
||||
fprintf(stderr, "clean %p in %s\n", tampon, __func__);
|
||||
Image_DeAllocate(tampon); free(tampon);
|
||||
}
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
#define max(a,b) ((a)>(b)?(a):(b))
|
||||
#endif
|
||||
/*::------------------------------------------------------------------::*/
|
||||
static int
|
||||
iSign(int a)
|
||||
static int iSign(int a)
|
||||
{
|
||||
if (a<0) return -1;
|
||||
if (a>0) return 1;
|
||||
@@ -35,9 +34,8 @@ Image_plotRGB(i, x+xc, y+yc, 100, 100, 100);
|
||||
fprintf(stderr, "sym %d %d\n", x, y);
|
||||
}
|
||||
|
||||
/* le paramètre 'wrap' ne sert à rien */
|
||||
int
|
||||
Image_draw_circle(Image_Desc *i, int xc, int yc, int rayon, RGBA *q, int wrap)
|
||||
/* le parametre 'wrap' ne sert a rien */
|
||||
int Image_draw_circle(Image_Desc *i, int xc, int yc, int rayon, RGBA *q, int wrap)
|
||||
{
|
||||
int x, y, d;
|
||||
|
||||
@@ -48,16 +46,13 @@ fprintf(stderr, "%s : centre %d %d, rayon %d\n", __func__, xc, yc, rayon);
|
||||
y = rayon;
|
||||
d = 3 - 2 * rayon;
|
||||
|
||||
for ( x=0; x<y; )
|
||||
{
|
||||
for ( x=0; x<y; ) {
|
||||
symmetry(x, y, xc, yc, q, i);
|
||||
|
||||
if (d<0)
|
||||
{
|
||||
if (d<0) {
|
||||
d += 4 * x + 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
d += 4 * (y - x) * 10;
|
||||
--y;
|
||||
}
|
||||
@@ -67,19 +62,35 @@ for ( x=0; x<y; )
|
||||
return FUNC_NOT_FINISH;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/* New Mon 19 Dec 2022 12:56:44 PM CET */
|
||||
int Image_H_line(Image_Desc *i, int xa, int xb, int ypos, RGBA *col)
|
||||
{
|
||||
int ix;
|
||||
|
||||
#if 1
|
||||
fprintf(stderr, ">>> %s ( %d %d %d %p )\n", __func__, xa, xb, ypos, col);
|
||||
#endif
|
||||
|
||||
if (xa > xb) { ix=xa, xa=xb, xb=ix; }
|
||||
|
||||
for (ix=xa; ix<xb; ix++) {
|
||||
Image_plotRGB(i, ix, ypos, col->r, col->g, col->b);
|
||||
}
|
||||
return FUNC_IS_BETA;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/*
|
||||
* l'appel a la fonction isign devrait disparaitre pour optimiser
|
||||
* la vitesse du bouzin.
|
||||
*/
|
||||
int
|
||||
Image_draw_line(Image_Desc *i, int x1, int y1, int x2, int y2, RGBA *q)
|
||||
int Image_draw_line(Image_Desc *i, int x1, int y1, int x2, int y2, RGBA *q)
|
||||
{
|
||||
int dx, dy, ix, iy, inc;
|
||||
int foo, plotx, ploty, x, y;
|
||||
int plot;
|
||||
|
||||
#if DEBUG_LEVEL > 1
|
||||
printf("%s %4d %4d -----> %4d %4d\n", __func__, x1, y1, x2, y2);
|
||||
#if DEBUG_LEVEL
|
||||
printf(">>> %s ( %p %4d %4d %4d %4d\n", __func__, i, x1, y1, x2, y2);
|
||||
#endif
|
||||
|
||||
dx = x2 - x1; dy = y2 - y1;
|
||||
@@ -94,39 +105,33 @@ plotx = x1;
|
||||
ploty = y1;
|
||||
x = y = 0;
|
||||
|
||||
for (foo=0; foo<=inc; ++foo)
|
||||
{
|
||||
for (foo=0; foo<=inc; ++foo) {
|
||||
x += ix;
|
||||
y += iy;
|
||||
plot = 0;
|
||||
if (x > inc)
|
||||
{
|
||||
if (x > inc) {
|
||||
plot = 42;
|
||||
x -= inc;
|
||||
plotx += iSign(dx);
|
||||
}
|
||||
if (y > inc)
|
||||
{
|
||||
if (y > inc) {
|
||||
plot = 42;
|
||||
y -= inc;
|
||||
ploty += iSign(dy);
|
||||
}
|
||||
if (plot)
|
||||
{
|
||||
if (plot) {
|
||||
/* printf("%5d %5d %5d\n", foo, plotx, ploty ); */
|
||||
Image_plotRGB(i, plotx, ploty, q->r, q->g, q->b);
|
||||
}
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/*
|
||||
* XXX si je veux remplacer 'plotRGB' par un accès direct
|
||||
* XXX si je veux remplacer 'plotRGB' par un acces direct
|
||||
* XXX dans les buffers, il faut soigner les controles
|
||||
*/
|
||||
int
|
||||
Image_paint_rect(Image_Desc *img, Image_Rect *rect, int r, int g, int b)
|
||||
int Image_paint_rect(Image_Desc *img, Image_Rect *rect, int r, int g, int b)
|
||||
{
|
||||
int xd, yd, xf, yf, x, y;
|
||||
|
||||
@@ -140,9 +145,10 @@ yd = max(0, rect->y);
|
||||
xf = min((img->width), (rect->x+rect->w));
|
||||
yf = min((img->height), (rect->y+rect->h));
|
||||
/*
|
||||
* 24 Juin 2002: est-ce que le code ci-dessus a été sérieusement validé ?
|
||||
* 24 Juin 2002: est-ce que le code ci-dessus est vraiment valide ?
|
||||
* 24 Avril 2008: NON !
|
||||
* 26 janvier 2014 : toujours non...
|
||||
* 19 septembre 2022 : je n'ai pas de certitude a ce sujet
|
||||
*/
|
||||
|
||||
#if DEBUG_LEVEL > 2
|
||||
@@ -150,10 +156,8 @@ fprintf(stderr, "Paint Rect: %4d < X < %4d %4d < Y < %4d\n",
|
||||
xd, xf, yd, yf);
|
||||
#endif
|
||||
|
||||
for (x=xd; x<xf; x++)
|
||||
{
|
||||
for (y=yd; y<yf; y++)
|
||||
{
|
||||
for (x=xd; x<xf; x++) {
|
||||
for (y=yd; y<yf; y++) {
|
||||
/* Image_plotRGB(img, x, y, r, g, b); */
|
||||
(img->Rpix[y])[x] = r;
|
||||
(img->Gpix[y])[x] = g;
|
||||
@@ -167,9 +171,12 @@ return 0;
|
||||
/*
|
||||
* 27 Juin 2001: there was an off-by-one error in this func...
|
||||
* See also 'drawpatt.c' for others things.
|
||||
|
||||
###
|
||||
### THERE IS A OFF-BY-ONE IN THIS FUNCTION !
|
||||
###
|
||||
*/
|
||||
int
|
||||
Image_draw_rect(Image_Desc *img, Image_Rect *rect, int r, int g, int b)
|
||||
int Image_draw_rect(Image_Desc *img, Image_Rect *rect, int r, int g, int b)
|
||||
{
|
||||
int foo;
|
||||
int xd, yd, xf, yf;
|
||||
@@ -185,16 +192,14 @@ fprintf(stderr, "Draw a Rect: xd:%4d yd:%4d xf:%4d yf:%4d\n",
|
||||
xd, yd, xf, yf);
|
||||
#endif
|
||||
|
||||
for (foo=xd; foo<xf; foo++)
|
||||
{
|
||||
for (foo=xd; foo<xf; foo++) {
|
||||
/* if ( (rect->y >= 0) && (rect->y < img->height) ) */
|
||||
Image_plotRGB(img, foo, rect->y, r, g, b);
|
||||
/* if ( (rect->y+rect->h >= 0) && (rect->y+rect->h < img->height) ) */
|
||||
Image_plotRGB(img, foo, rect->y+rect->h-1, r, g, b);
|
||||
}
|
||||
|
||||
for (foo=yd; foo<yf; foo++)
|
||||
{
|
||||
for (foo=yd; foo<yf; foo++) {
|
||||
/* if ( (rect->x >= 0) && (rect->x < img->width) ) */
|
||||
Image_plotRGB(img, rect->x, foo, r, g, b);
|
||||
/* if ( (rect->x+rect->w >= 0) && (rect->x+rect->w < img->width) ) */
|
||||
@@ -205,8 +210,7 @@ return 0;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/* new 10 octobre 2008 - zone de Monredon (Betatech) */
|
||||
int
|
||||
Image_noise_rect(Image_Desc *img, Image_Rect *rect, int r, int g, int b)
|
||||
int Image_noise_rect(Image_Desc *img, Image_Rect *rect, int r, int g, int b)
|
||||
{
|
||||
int xd, yd, xf, yf, x, y;
|
||||
|
||||
@@ -221,10 +225,8 @@ yf = min((img->height-1), (rect->y+rect->h));
|
||||
fprintf(stderr, "%s: %d %d %d %d\n", __func__, xd, yd, xf, yf);
|
||||
#endif
|
||||
|
||||
for (x=xd; x<xf; x++)
|
||||
{
|
||||
for (y=yd; y<yf; y++)
|
||||
{
|
||||
for (x=xd; x<xf; x++) {
|
||||
for (y=yd; y<yf; y++) {
|
||||
(img->Rpix[y])[x] = rand() % r;
|
||||
(img->Gpix[y])[x] = rand() % g;
|
||||
(img->Bpix[y])[x] = rand() % b;
|
||||
@@ -237,4 +239,3 @@ return FUNC_IS_BETA;
|
||||
/*
|
||||
* kikoo lol a tous les goret-codeurs, et en particulier Mr Spleyt.
|
||||
*/
|
||||
|
||||
|
||||
102
Lib/effects.c
102
Lib/effects.c
@@ -32,20 +32,17 @@ int x, y, nx, ny, r, g, b, foo;
|
||||
int retry;
|
||||
#endif
|
||||
|
||||
if ( (foo=Image_compare_desc(source, but)) )
|
||||
{
|
||||
if ( (foo=Image_compare_desc(source, but)) ) {
|
||||
fprintf(stderr, "%s : images are differents %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
if (intensite < 1)
|
||||
{
|
||||
if (intensite < 1) {
|
||||
fprintf(stderr, "%s : bad intensity %d\n", __func__, intensite);
|
||||
intensite = 1;
|
||||
}
|
||||
|
||||
if (source == but)
|
||||
{
|
||||
if (source == but) {
|
||||
fprintf(stderr, "%s : Source & Target are the same image, bad effect expected...\n", __func__ );
|
||||
}
|
||||
|
||||
@@ -53,13 +50,10 @@ if (source == but)
|
||||
retry = 0;
|
||||
#endif
|
||||
|
||||
for (x=0; x<source->width; x++)
|
||||
{
|
||||
for (y=0; y<source->height; y++)
|
||||
{
|
||||
for (x=0; x<source->width; x++) {
|
||||
for (y=0; y<source->height; y++) {
|
||||
foo = -1;
|
||||
do
|
||||
{
|
||||
do {
|
||||
nx = x+(rand()%intensite)-(intensite/2);
|
||||
ny = y+(rand()%intensite)-(intensite/2);
|
||||
foo++;
|
||||
@@ -135,54 +129,46 @@ return OLL_KORRECT;
|
||||
j'ai rapidement besoin de cette fonction alors je code
|
||||
a la rache :-[ (on appelle aussi c,a le codage 123momo)
|
||||
*/
|
||||
int
|
||||
Image_mirror(Image_Desc *src, Image_Desc *dst, int reserved)
|
||||
int Image_mirror(Image_Desc *src, Image_Desc *dst, int reserved)
|
||||
{
|
||||
register int x;
|
||||
uint8_t *buffer;
|
||||
int foo, largeur, y;
|
||||
|
||||
if (reserved != 0)
|
||||
fprintf(stderr, "Image_Mirror: reserved must be zero !\n");
|
||||
fprintf(stderr, "%s: reserved must be zero !\n", __func__);
|
||||
|
||||
if ( (foo=Image_compare_desc(src, dst)) )
|
||||
{
|
||||
fprintf(stderr, "Image_Mirror: images are differents %d\n", foo);
|
||||
if ( (foo=Image_compare_desc(src, dst)) ) {
|
||||
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
largeur = src->width;
|
||||
|
||||
if ((buffer = (uint8_t *)malloc(largeur)) == NULL)
|
||||
{
|
||||
fprintf(stderr, "Image_Mirror: no memory for buffer");
|
||||
if ((buffer = (uint8_t *)malloc(largeur)) == NULL) {
|
||||
fprintf(stderr, "%s: no memory for buffer\n", __func__);
|
||||
return BUFFER_NO_MEM;
|
||||
}
|
||||
|
||||
for (y=0; y<src->height; y++)
|
||||
{
|
||||
if (src->Rpix != NULL)
|
||||
{
|
||||
for (y=0; y<src->height; y++) {
|
||||
if (src->Rpix != NULL) {
|
||||
for (x=0; x<largeur; x++)
|
||||
buffer[x] = (src->Rpix[y])[x];
|
||||
for (x=0; x<largeur; x++)
|
||||
(dst->Rpix[y])[x] = buffer[largeur-x-1];
|
||||
}
|
||||
if (src->Gpix != NULL)
|
||||
{
|
||||
if (src->Gpix != NULL) {
|
||||
for (x=0; x<largeur; x++)
|
||||
buffer[x] = (src->Gpix[y])[x];
|
||||
for (x=0; x<largeur; x++)
|
||||
(dst->Gpix[y])[x] = buffer[largeur-x-1];
|
||||
}
|
||||
if (src->Bpix != NULL)
|
||||
{
|
||||
if (src->Bpix != NULL) {
|
||||
for (x=0; x<largeur; x++)
|
||||
buffer[x] = (src->Bpix[y])[x];
|
||||
for (x=0; x<largeur; x++)
|
||||
(dst->Bpix[y])[x] = buffer[largeur-x-1];
|
||||
}
|
||||
if (src->Apix != NULL)
|
||||
{
|
||||
if (src->Apix != NULL) {
|
||||
for (x=0; x<largeur; x++)
|
||||
buffer[x] = (src->Apix[y])[x];
|
||||
for (x=0; x<largeur; x++)
|
||||
@@ -202,19 +188,16 @@ Image_upside_down(Image_Desc *src, Image_Desc *dst, int reserved)
|
||||
{
|
||||
int foo, y;
|
||||
|
||||
if ( (foo=Image_compare_desc(src, dst)) )
|
||||
{
|
||||
fprintf(stderr, "Image_UpsideDown: images are differents %d\n", foo);
|
||||
if ( (foo=Image_compare_desc(src, dst)) ) {
|
||||
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
if (0 != reserved)
|
||||
{
|
||||
if (0 != reserved) {
|
||||
fprintf(stderr, "%s gni ?\n", __func__);
|
||||
}
|
||||
|
||||
for (y=0; y<src->height; y++)
|
||||
{
|
||||
for (y=0; y<src->height; y++) {
|
||||
memcpy(dst->Rpix[y], src->Rpix[src->height-(y+1)], src->width);
|
||||
memcpy(dst->Gpix[y], src->Gpix[src->height-(y+1)], src->width);
|
||||
memcpy(dst->Bpix[y], src->Bpix[src->height-(y+1)], src->width);
|
||||
@@ -240,8 +223,7 @@ fprintf(stderr, "Scratching %ld times %p to %p\n", nombre, source, but);
|
||||
|
||||
Image_copy(source, but);
|
||||
|
||||
while (nombre--)
|
||||
{
|
||||
while (nombre--) {
|
||||
xs = rand() % source->width;
|
||||
ys = rand() % source->height;
|
||||
xd = rand() % source->width;
|
||||
@@ -261,21 +243,18 @@ Image_swap_lines( Image_Desc *src, Image_Desc * dst )
|
||||
{
|
||||
int foo, line;
|
||||
|
||||
if (src == dst)
|
||||
{
|
||||
fprintf(stderr, "Image swap lines: SRC & DST must be different\n");
|
||||
if (src == dst) {
|
||||
fprintf(stderr, "%s: SRC & DST must be different\n", __func__);
|
||||
return IMG_OVERWRITE;
|
||||
}
|
||||
|
||||
if ( (foo=Image_compare_desc(src, dst)) )
|
||||
{
|
||||
fprintf(stderr, "Image swap lines: images have differents sizes. %d\n",
|
||||
foo);
|
||||
if ( (foo=Image_compare_desc(src, dst)) ) {
|
||||
fprintf(stderr, "%s: images have differents sizes. %d\n",
|
||||
__func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
for (line=0; line<(src->height-1); line+=2)
|
||||
{
|
||||
for (line=0; line<(src->height-1); line+=2) {
|
||||
memcpy(dst->Rpix[line+1], src->Rpix[line], src->width);
|
||||
memcpy(dst->Rpix[line], src->Rpix[line+1], src->width);
|
||||
memcpy(dst->Gpix[line+1], src->Gpix[line], src->width);
|
||||
@@ -294,15 +273,13 @@ Image_swap_cols( Image_Desc *src, Image_Desc * dst )
|
||||
{
|
||||
int foo, line, col, tmp, wmax;
|
||||
|
||||
if (src == dst)
|
||||
{
|
||||
fprintf(stderr, "Image_SwapCols: SRC & DST must be different\n");
|
||||
if (src == dst) {
|
||||
fprintf(stderr, "%s: SRC & DST must be different\n", __func__);
|
||||
return IMG_OVERWRITE;
|
||||
}
|
||||
|
||||
if ( (foo=Image_compare_desc(src, dst)) )
|
||||
{
|
||||
fprintf(stderr, "Image_SwapCols: images are differents %d\n", foo);
|
||||
if ( (foo=Image_compare_desc(src, dst)) ) {
|
||||
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
@@ -312,10 +289,8 @@ else
|
||||
wmax = src->width;
|
||||
fprintf(stderr, "swap cols %d %d\n", src->width, wmax);
|
||||
|
||||
for (line=0; line<src->height; line++)
|
||||
{
|
||||
for (col=0; col<wmax; col+=2)
|
||||
{
|
||||
for (line=0; line<src->height; line++) {
|
||||
for (col=0; col<wmax; col+=2) {
|
||||
tmp = src->Rpix[line][col];
|
||||
dst->Rpix[line][col] = src->Rpix[line][col+1];
|
||||
dst->Rpix[line][col+1] = tmp;
|
||||
@@ -343,16 +318,13 @@ Image_swap_nibbles( Image_Desc *src, Image_Desc * dst )
|
||||
int foo;
|
||||
int x, y;
|
||||
|
||||
if ( (foo=Image_compare_desc(src, dst)) )
|
||||
{
|
||||
if ( (foo=Image_compare_desc(src, dst)) ) {
|
||||
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
for (x=0; x<src->width; x++)
|
||||
{
|
||||
for (y=0; y<src->height; y++)
|
||||
{
|
||||
for (x=0; x<src->width; x++) {
|
||||
for (y=0; y<src->height; y++) {
|
||||
dst->Rpix[y][x] = ((src->Rpix[y][x] & 0xf0) >> 4) |
|
||||
((src->Rpix[y][x] & 0x0f) << 4);
|
||||
|
||||
|
||||
@@ -19,8 +19,7 @@
|
||||
* la parametre 'table' est un tableau de 6 double. d'accord,
|
||||
* mais quel est donc son contenu ?
|
||||
*/
|
||||
int
|
||||
Image_sinwave_0( Image_Desc *source, Image_Desc * but, double *table )
|
||||
int Image_sinwave_0( Image_Desc *source, Image_Desc * but, double *table )
|
||||
{
|
||||
#if DEBUG_LEVEL > 1
|
||||
int foo;
|
||||
@@ -41,18 +40,15 @@ for (foo=0; foo<6; foo++)
|
||||
cx = (2.0 * M_PI) / (double)source->width;
|
||||
cy = (2.0 * M_PI) / (double)source->height;
|
||||
|
||||
for (x=0; x<source->width; x++)
|
||||
{
|
||||
for (x=0; x<source->width; x++) {
|
||||
fx = (double)x + (table[1] * sin(table[4] + (cx * table[0] * (double)x)));
|
||||
xb = floor(fx + 0.5);
|
||||
|
||||
for (y=0; y<source->height; y++)
|
||||
{
|
||||
for (y=0; y<source->height; y++) {
|
||||
fy = (double)y + (table[3] * sin(table[5] + cy * table[2] * (double)y));
|
||||
yb = floor(fy + 0.5);
|
||||
|
||||
if ( xb>0 && yb>0 && xb<but->width && yb<but->height )
|
||||
{
|
||||
if ( xb>0 && yb>0 && xb<but->width && yb<but->height ) {
|
||||
r = (source->Rpix[yb])[xb];
|
||||
g = (source->Gpix[yb])[xb];
|
||||
b = (source->Bpix[yb])[xb];
|
||||
@@ -61,11 +57,7 @@ for (x=0; x<source->width; x++)
|
||||
(but->Gpix[y])[x] = g;
|
||||
(but->Bpix[y])[x] = b;
|
||||
}
|
||||
else
|
||||
{
|
||||
outside++;
|
||||
/* ??? foo = Image_plotRGB(but, x, y, 0, 0, 0); */
|
||||
}
|
||||
else { outside++; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,8 +77,7 @@ return OLL_KORRECT;
|
||||
* Les parametres sont en deux groupes de 3 dans la table.
|
||||
* mais franchement, j'arrive plus a savoir a quoi ils servent.
|
||||
*/
|
||||
int
|
||||
Image_sinwave_1( Image_Desc *source, Image_Desc * but, double *table )
|
||||
int Image_sinwave_1( Image_Desc *source, Image_Desc * but, double *table )
|
||||
{
|
||||
int foo, x, y, xb, yb, r, g, b;
|
||||
long outside = 0;
|
||||
@@ -197,7 +188,7 @@ fprintf(stderr, ">> %s ( %p %p %d %d )\n", __func__, source, but, k1, k2);
|
||||
fprintf(stderr, "Degouline %d %d\n", k1, k2);
|
||||
|
||||
if ( (foo=Image_compare_desc(source, but)) ) {
|
||||
fprintf(stderr, "Image Degouline 2: images are differents %d\n", foo);
|
||||
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
|
||||
105
Lib/effects3.c
105
Lib/effects3.c
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
+---------------------------------------+
|
||||
| Effets speciaux sur les images |
|
||||
| troisième module |
|
||||
| troisieme module |
|
||||
+---------------------------------------+
|
||||
Thierry Boudet <oulala@chez.com>
|
||||
*/
|
||||
@@ -20,8 +20,7 @@
|
||||
* 11 Fev 2003: que vais-je mettre ici ?
|
||||
* 5 avr 2007: je commence a en avoir une idee plus precise.
|
||||
*/
|
||||
int
|
||||
Image_effect_x_0(Image_Desc *src, Image_Desc *dst, int kr, int kg, int kb)
|
||||
int Image_effect_x_0(Image_Desc *src, Image_Desc *dst, int kr, int kg, int kb)
|
||||
{
|
||||
int foo, x, y, r, g, b;
|
||||
int cr, cg, cb;
|
||||
@@ -30,9 +29,8 @@ int cr, cg, cb;
|
||||
fprintf(stderr, "*** Effect X_0: coeffs: %d %d %d\n", kr, kg, kb);
|
||||
#endif
|
||||
|
||||
if ( (foo=Image_compare_desc(src, dst)) )
|
||||
{
|
||||
fprintf(stderr, "Image effect x 0: images are differents %d\n", foo);
|
||||
if ( (foo=Image_compare_desc(src, dst)) ) {
|
||||
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
@@ -40,7 +38,10 @@ cr = cg = cb = 0; /* raz des compteurs */
|
||||
|
||||
for (y=0; y<dst->height; y++) {
|
||||
for (x=0; x<dst->width; x++) {
|
||||
Image_getRGB(src, x, y, &r, &g, &b);
|
||||
/* Image_getRGB(src, x, y, &r, &g, &b); */
|
||||
r = src->Rpix[y][x];
|
||||
g = src->Gpix[y][x];
|
||||
b = src->Bpix[y][x];
|
||||
if (r > kr) {
|
||||
foo = g; g = b; b = foo;
|
||||
cr ++;
|
||||
@@ -53,11 +54,14 @@ for (y=0; y<dst->height; y++) {
|
||||
foo = g; g = r; r = foo;
|
||||
cb ++;
|
||||
}
|
||||
Image_plotRGB(dst, x, y, r, g, b);
|
||||
/* Image_plotRGB(dst, x, y, r, g, b); */
|
||||
dst->Rpix[y][x] = r;
|
||||
dst->Gpix[y][x] = g;
|
||||
dst->Bpix[y][x] = b;
|
||||
}
|
||||
}
|
||||
|
||||
fprintf(stderr, "* %s : counts: %d %d %d\n", __func__, cr, cg, cb);
|
||||
/* fprintf(stderr, "* %s : counts: %d %d %d\n", __func__, cr, cg, cb); */
|
||||
|
||||
return FUNC_IS_BETA;
|
||||
}
|
||||
@@ -66,26 +70,22 @@ return FUNC_IS_BETA;
|
||||
/*
|
||||
* 3 avril 2007: je me rend compte que les parametres ne servent a rien.
|
||||
*/
|
||||
int
|
||||
Image_effect_x_1(Image_Desc *src, Image_Desc *dst)
|
||||
int Image_effect_x_1(Image_Desc *src, Image_Desc *dst)
|
||||
{
|
||||
int foo, x, y, r, g, b;
|
||||
|
||||
if ( (foo=Image_compare_desc(src, dst)) )
|
||||
{
|
||||
fprintf(stderr, "Image effect x 1: images are differents %d\n", foo);
|
||||
if ( (foo=Image_compare_desc(src, dst)) ) {
|
||||
fprintf(stderr, "I%s: images are differents %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
for (y=0; y<dst->height; y++)
|
||||
{
|
||||
for (x=0; x<dst->width; x++)
|
||||
{
|
||||
for (y=0; y<dst->height; y++) {
|
||||
for (x=0; x<dst->width; x++) {
|
||||
r = src->Rpix[y][x];
|
||||
g = src->Gpix[y][x];
|
||||
b = src->Bpix[y][x];
|
||||
|
||||
/* 2 fevrier 2003: je fait du n'importe quoi, là... */
|
||||
/* 2 fevrier 2003: je fait du n'importe quoi, la... */
|
||||
dst->Rpix[y][x] = g^b;
|
||||
dst->Gpix[y][x] = r^b;
|
||||
dst->Bpix[y][x] = r^g;
|
||||
@@ -96,18 +96,16 @@ return FUNC_IS_BETA;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/*
|
||||
* 1er Février 2003: encore une autre expérimentation, qui va être
|
||||
* basée sur la trigonométrie.
|
||||
* 1er Fevrier 2003: encore une autre experimentation, qui va etre
|
||||
* basee sur la trigonometrie.
|
||||
*/
|
||||
int
|
||||
Image_effect_x_2(Image_Desc *src, Image_Desc *dst, int kx, int ky, int kv)
|
||||
int Image_effect_x_2(Image_Desc *src, Image_Desc *dst, int kx, int ky, int kv)
|
||||
{
|
||||
int foo, x, y, r, g, b;
|
||||
double dr, dg, db, ar, ag, ab;
|
||||
|
||||
if ( (foo=Image_compare_desc(src, dst)) )
|
||||
{
|
||||
fprintf(stderr, "Image effect x 2: images are differents %d\n", foo);
|
||||
if ( (foo=Image_compare_desc(src, dst)) ) {
|
||||
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
@@ -135,7 +133,7 @@ for (y=0; y<dst->height; y++) {
|
||||
ab = atan2(dr, dg);
|
||||
|
||||
/*
|
||||
* et là, il y a des soucis d'echelle :)
|
||||
* et la il y a des soucis d'echelle :)
|
||||
* 15 mars 2005: pourquoi 156 ? (XXX)
|
||||
*/
|
||||
r = (int)(ar * 156.0);
|
||||
@@ -154,14 +152,13 @@ return FUNC_IS_BETA;
|
||||
/*
|
||||
* 30 Jan 2003: hop, j'improvise pendant que les patates cuisent :)
|
||||
* 4 Fev 2003: et je peaufine pendant que le poulet mijote :)
|
||||
* 27 Oct 2003: je debugge pendant que le thé infuse :)
|
||||
* 27 Oct 2003: je debugge pendant que le the infuse :)
|
||||
* 16 Mai 2005: je commence a ecrire la documentation.
|
||||
* 29 sept 2015: je devrais finir la doc d'ici 2 ans.
|
||||
* 19 aout 2022: je comprend pas ce que c'est censé faire :)
|
||||
* 19 aout 2022: je comprend pas ce que c'est cense faire :)
|
||||
*
|
||||
*/
|
||||
int
|
||||
Image_effect_x_3(Image_Desc *src, Image_Desc *dst, int kx, int ky, char *comp)
|
||||
int Image_effect_x_3(Image_Desc *src, Image_Desc *dst, int kx, int ky, char *comp)
|
||||
{
|
||||
int foo, sx, sy;
|
||||
int x, y, r, g, b;
|
||||
@@ -171,15 +168,13 @@ int cx, cy, dx, dy;
|
||||
fprintf(stderr, "%s : kx %d ky %d comp '%s'\n", __func__, kx, ky, comp);
|
||||
#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);
|
||||
return foo;
|
||||
}
|
||||
|
||||
if (strlen(comp) != 2)
|
||||
{
|
||||
fprintf(stderr, "eff x3: bad comp parameter '%s'\n", comp);
|
||||
if (strlen(comp) != 2) {
|
||||
fprintf(stderr, "%s: bad comp parameter '%s'\n", __func__, comp);
|
||||
fprintf(stderr, " must be a 2 chars string, from 'rgb'\n");
|
||||
return INVALID_PARAM;
|
||||
}
|
||||
@@ -193,25 +188,22 @@ sx = sy = 0;
|
||||
|
||||
/*
|
||||
* ici il faudrait une validation des deux lettres, mais j'ai la
|
||||
* flemme d'écrire ça maintenant. je vais plutôt aller boofer.
|
||||
* flemme d'ecrire ce genre de chos maintenant.
|
||||
* Je vais plutot aller boofer.
|
||||
*/
|
||||
|
||||
for (y=0; y<dst->height; y++)
|
||||
{
|
||||
for (x=0; x<dst->width; x++)
|
||||
{
|
||||
for (y=0; y<dst->height; y++) {
|
||||
for (x=0; x<dst->width; x++) {
|
||||
r = src->Rpix[y][x];
|
||||
g = src->Gpix[y][x];
|
||||
b = src->Bpix[y][x];
|
||||
|
||||
switch(cx)
|
||||
{
|
||||
switch(cx) {
|
||||
case 'r': dx = r; break;
|
||||
case 'g': dx = g; break;
|
||||
case 'b': dx = b; break;
|
||||
}
|
||||
switch(cy)
|
||||
{
|
||||
switch(cy) {
|
||||
case 'r': dy = r; break;
|
||||
case 'g': dy = g; break;
|
||||
case 'b': dy = b; break;
|
||||
@@ -221,15 +213,13 @@ for (y=0; y<dst->height; y++)
|
||||
sy = y + ((ky * (dy-128)) / 100);
|
||||
|
||||
if ( sx >= 0 && sx < dst->width &&
|
||||
sy >= 0 && sy < dst->height )
|
||||
{
|
||||
sy >= 0 && sy < dst->height ) {
|
||||
r = src->Rpix[sy][sx];
|
||||
g = src->Gpix[sy][sx];
|
||||
b = src->Bpix[sy][sx];
|
||||
Image_plotRGB(dst, x, y, r, g, b);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
Image_plotRGB(dst, x, y, r, r, r);
|
||||
}
|
||||
/*
|
||||
@@ -252,7 +242,7 @@ fprintf(stderr, "*** effect x4 is not ready for prime time ***\n");
|
||||
#endif
|
||||
|
||||
if ( (foo=Image_compare_desc(src, dst)) ) {
|
||||
fprintf(stderr, "Image effect x 4: images are differents %d\n", foo);
|
||||
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
@@ -285,8 +275,7 @@ return FUNC_IS_BETA;
|
||||
* faudrait que les gosses arretent de ma casser les oreilles avec leur
|
||||
* machine a batailles. putain de gamecube... */
|
||||
/* 23 aout 2022 : j'ai bien envie d'une SNES et d'un Trinitron */
|
||||
int
|
||||
Image_effect_x_5(Image_Desc *src, Image_Desc *dst, int kx, int ky, int kz)
|
||||
int Image_effect_x_5(Image_Desc *src, Image_Desc *dst, int kx, int ky, int kz)
|
||||
{
|
||||
int foo, sx, sy;
|
||||
int x, y, r, g, b;
|
||||
@@ -299,16 +288,13 @@ fprintf(stderr, ">>> %s ( %p %p %d %d %d )\n", __func__, src, dst,
|
||||
kx, ky, kz);
|
||||
#endif
|
||||
|
||||
if ( (foo=Image_compare_desc(src, dst)) )
|
||||
{
|
||||
if ( (foo=Image_compare_desc(src, dst)) ) {
|
||||
fprintf(stderr, "Image effect x 5: images are differents %d\n", foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
for (y=0; y<src->height; y++)
|
||||
{
|
||||
for (x=0; x<src->width; x++)
|
||||
{
|
||||
for (y=0; y<src->height; y++) {
|
||||
for (x=0; x<src->width; x++) {
|
||||
r = src->Rpix[y][x];
|
||||
g = src->Gpix[y][x];
|
||||
b = src->Bpix[y][x];
|
||||
@@ -322,8 +308,7 @@ for (y=0; y<src->height; y++)
|
||||
g2 = (int)(dg2 * 255.0);
|
||||
b2 = (int)(db2 * 255.0);
|
||||
#if DEBUG_LEVEL
|
||||
if (x==42 && y==42)
|
||||
{
|
||||
if (x==42 && y==42) {
|
||||
printf("{{{ pixels %3d %3d %3d }}}\n", r, g, b);
|
||||
printf("{{{ result %3d %3d %3d }}}\n", r2, g2, b2);
|
||||
}
|
||||
|
||||
15
Lib/equalhist.c
Normal file
15
Lib/equalhist.c
Normal file
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* Egalisation par cumul d'histogramme
|
||||
* ===================================
|
||||
*
|
||||
* new: Sat Aug 10 14:38:01 UTC 2024, aux Bourtoulots
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "../tthimage.h"
|
||||
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
|
||||
252
Lib/essais.c
252
Lib/essais.c
@@ -17,6 +17,50 @@
|
||||
#include "../tthimage.h"
|
||||
#include "essais.h"
|
||||
|
||||
/* ============================== */
|
||||
int essai_draw_paint_rect(char *outga)
|
||||
{
|
||||
Image_Desc *img;
|
||||
Image_Rect rect;
|
||||
int foo, x, y;
|
||||
|
||||
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, outga);
|
||||
|
||||
rect.x = 8; rect.y = 8;
|
||||
rect.w = 6; rect.h = 6;
|
||||
|
||||
if (NULL==(img=Image_alloc(64, 32, 3))) {
|
||||
abort();
|
||||
}
|
||||
|
||||
for (x=0; x<img->width; x+=2) {
|
||||
for (y=0; y<img->height; y+=2) {
|
||||
Image_plotRGB(img, x, y, 200, 200, 200);
|
||||
}
|
||||
}
|
||||
|
||||
foo = Image_draw_rect(img, &rect, 192, 128, 64);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s: err %d draw rect\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
rect.x = 24;
|
||||
foo = Image_paint_rect(img, &rect, 64, 128, 192);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s: err %d paint rect\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
foo = Image_TGA_save(outga, img, 0);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s: err %d save '%s'\n", __func__, foo, outga);
|
||||
return foo;
|
||||
}
|
||||
|
||||
return OLL_KORRECT;
|
||||
}
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/* nouveau vacances de fevrier 2010 */
|
||||
int Essayer_les_alphas(char *fname, int k)
|
||||
@@ -37,7 +81,7 @@ if (NULL==(dst=Image_clone(src, 0))) {
|
||||
}
|
||||
|
||||
foo = Image_tampon_alpha_0(src, NULL, dst);
|
||||
if (foo) Image_print_error(__func__, foo);
|
||||
if (foo) Image_print_error(fname, foo);
|
||||
|
||||
Image_TGA_save("Pictures/aaaa-tampon.tga", dst, 0);
|
||||
|
||||
@@ -101,7 +145,7 @@ Image_TGA_save("Pictures/aaaa-luminance-128.tga", dst, 0);
|
||||
foo = Image_luminance(src, dst, 200);
|
||||
Image_TGA_save("Pictures/aaaa-luminance-200.tga", dst, 0);
|
||||
foo = Image_luminance(src, dst, 500);
|
||||
if (foo) Image_print_error(__func__, foo);
|
||||
if (foo) Image_print_error((char *)__func__, foo);
|
||||
|
||||
Image_TGA_save("Pictures/aaaa-luminance-500.tga", dst, 0);
|
||||
|
||||
@@ -172,18 +216,17 @@ if (NULL==(src=Image_TGA_alloc_load(srcname))) {
|
||||
}
|
||||
/* on va creer le receptacle des horreurs */
|
||||
if (NULL==(dst=Image_clone(src, 0))) {
|
||||
fprintf(stderr, "%s: err clone\n", __func__);
|
||||
exit(5);
|
||||
}
|
||||
|
||||
/* ah bravo ! enfin un test unitaire appelable
|
||||
* depuis le test unitaire */
|
||||
for (idx=0; idx<20; idx++)
|
||||
{
|
||||
for (idx=0; idx<20; idx++) {
|
||||
foo = Image_essai_col_reduce(src, dst, 133, idx);
|
||||
printf("le retour de l'essai_col_reduce %d est %d\n", idx, foo);
|
||||
if (OLL_KORRECT==foo)
|
||||
{
|
||||
sprintf(fname, "Pictures/aaaa-colredux-%02d.tga", idx);
|
||||
if (OLL_KORRECT==foo) {
|
||||
sprintf(fname, "aaaa-colredux-%02d.tga", idx);
|
||||
Image_TGA_save(fname, dst, 0);
|
||||
}
|
||||
}
|
||||
@@ -331,7 +374,9 @@ if ( NULL == (nucked=Image_clone(origine, 1)) ) {
|
||||
}
|
||||
|
||||
foo = Image_essai_zoom(origine, nucked, 1.18, 0.42, 0);
|
||||
|
||||
if (foo) {
|
||||
fprintf(stderr, "In %s, essai zoom -> %d\n", __func__, foo);
|
||||
}
|
||||
Image_TGA_save("Pictures/aaaa-zoom.tga", nucked, 0);
|
||||
|
||||
Image_DeAllocate(nucked); free(nucked);
|
||||
@@ -425,7 +470,6 @@ int rotule, foo;
|
||||
Image_Desc *origine, *imgtmp;
|
||||
char chaine[100];
|
||||
int filtre[11];
|
||||
int w3, h3;
|
||||
Image_Rect rect;
|
||||
|
||||
static int datas_sobel[] =
|
||||
@@ -442,6 +486,8 @@ static int datas_prewitt[] =
|
||||
-1, -1, -1,
|
||||
1, 128
|
||||
};
|
||||
#if 0
|
||||
/* WHAT THE HELL is this data thing ? */
|
||||
static struct offxy
|
||||
{ int x, y; } offsets[] = {
|
||||
{ 1, 0 },
|
||||
@@ -453,6 +499,7 @@ static struct offxy
|
||||
{ 0, 1 },
|
||||
{ 0, 0 }
|
||||
};
|
||||
#endif
|
||||
|
||||
printf("========= Filtrage directionnel sur %s =======\n", srcname);
|
||||
|
||||
@@ -464,9 +511,6 @@ printf("image originale @ %p\n", origine);
|
||||
|
||||
imgtmp = Image_clone(origine, 1);
|
||||
|
||||
w3 = origine->width * 3;
|
||||
h3 = origine->height * 3;
|
||||
|
||||
if (flags) memcpy(filtre, datas_prewitt, sizeof(filtre));
|
||||
else memcpy(filtre, datas_sobel, sizeof(filtre));
|
||||
|
||||
@@ -537,32 +581,30 @@ int foo, ax, ay;
|
||||
|
||||
printf("====== essais Warping sur %s (k=%d) ====\n", srcname, k);
|
||||
|
||||
if (NULL == (src = Image_TGA_alloc_load(srcname)) )
|
||||
{
|
||||
if (NULL == (src = Image_TGA_alloc_load(srcname)) ) {
|
||||
fprintf(stderr, "Err loading '%s'\n", srcname);
|
||||
exit(5);
|
||||
}
|
||||
dst = Image_clone(src, 0);
|
||||
|
||||
foo = Image_warp_essai_0(src, dst, 33.5, 100, 100);
|
||||
Image_TGA_save("Pictures/warp-essai-0.tga", dst, 0);
|
||||
Image_TGA_save("warp-essai-0.tga", dst, 0);
|
||||
|
||||
foo = Image_center_rotate(src, dst, 21.5);
|
||||
Image_TGA_save("Pictures/warp-center-rotate.tga", dst, 0);
|
||||
Image_TGA_save("warp-center-rotate.tga", dst, 0);
|
||||
|
||||
ax = (src->width * 2) / 3;
|
||||
ay = (src->height * 2) / 3;
|
||||
foo = Image_shift_xy(src, dst, ax, ay);
|
||||
Image_TGA_save("Pictures/warp-shift-xy.tga", dst, 0);
|
||||
Image_TGA_save("warp-shift-xy.tga", dst, 0);
|
||||
foo = Image_shift_x(src, dst, ax);
|
||||
Image_TGA_save("Pictures/warp-shift-x.tga", dst, 0);
|
||||
Image_TGA_save("warp-shift-x.tga", dst, 0);
|
||||
foo = Image_shift_y(src, dst, ay);
|
||||
Image_TGA_save("Pictures/warp-shift-y.tga", dst, 0);
|
||||
Image_TGA_save("warp-shift-y.tga", dst, 0);
|
||||
|
||||
Image_DeAllocate(src); free(src);
|
||||
Image_DeAllocate(dst); free(dst);
|
||||
|
||||
|
||||
return 42;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
@@ -750,7 +792,7 @@ Image_DeAllocate(dst); free(dst);
|
||||
return 42;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int Test_classif(char *srcname, int k)
|
||||
int Test_Classif(char *srcname, int k)
|
||||
{
|
||||
Image_Desc *src, *dst;
|
||||
int foo;
|
||||
@@ -767,8 +809,7 @@ static Une_Classe_Sph classs[] =
|
||||
{ 0, 255, 0, DC, 0, 255, 0 }
|
||||
};
|
||||
|
||||
if (NULL == (src = Image_TGA_alloc_load(srcname)) )
|
||||
{
|
||||
if (NULL == (src = Image_TGA_alloc_load(srcname)) ) {
|
||||
fprintf(stderr, "Err loading '%s'\n", srcname);
|
||||
exit(5);
|
||||
}
|
||||
@@ -776,11 +817,11 @@ dst = Image_clone(src, 0);
|
||||
|
||||
foo = Image_classif_0(src, dst);
|
||||
Image_print_error("essai classif 0", foo);
|
||||
Image_TGA_save("Pictures/aaaa-classif0.tga", dst, 0);
|
||||
Image_TGA_save("aaaa-classif0.tga", dst, 0);
|
||||
|
||||
foo = Image_classif_1(src, dst, classs, 5, 0);
|
||||
Image_print_error("essai classif 1", foo);
|
||||
Image_TGA_save("Pictures/aaaa-classif1.tga", dst, 0);
|
||||
Image_TGA_save("aaaa-classif1.tga", dst, 0);
|
||||
|
||||
Image_DeAllocate(src); free(src);
|
||||
Image_DeAllocate(dst); free(dst);
|
||||
@@ -789,23 +830,29 @@ return 42;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/* new 24 avril 2007, essais sur le module rgbmask.c */
|
||||
int
|
||||
Test_rgbmask(char *srcname)
|
||||
int Test_RGBmask(char *srcname)
|
||||
{
|
||||
Image_Desc *source, *image ;
|
||||
int foo;
|
||||
|
||||
fprintf(stderr, "=============== %s on %s ==============\n", __func__, srcname);
|
||||
|
||||
|
||||
source = Image_TGA_alloc_load(srcname);
|
||||
image = Image_clone(source, 0);
|
||||
|
||||
foo = Image_rgbmask_H(source, image, 0);
|
||||
Image_TGA_save("Pictures/aaaa-rgbmaskH.tga", image, 0);
|
||||
Image_TGA_save("aaaa-rgbmaskH.tga", image, 0);
|
||||
foo = Image_rgbmask_V(source, image, 0);
|
||||
Image_TGA_save("Pictures/aaaa-rgbmaskV.tga", image, 0);
|
||||
Image_TGA_save("aaaa-rgbmaskV.tga", image, 0);
|
||||
foo = Image_rgbmask_2(source, image, 0);
|
||||
Image_TGA_save("Pictures/aaaa-rgbmask2.tga", image, 0);
|
||||
Image_TGA_save("aaaa-rgbmask2.tga", image, 0);
|
||||
foo = Image_rgbmask_R(source, image, 0);
|
||||
Image_TGA_save("Pictures/aaaa-rgbmaskR.tga", image, 0);
|
||||
Image_TGA_save("aaaa-rgbmaskR.tga", image, 0);
|
||||
|
||||
Image_DeAllocate(source); free(source);
|
||||
Image_DeAllocate(image); free(image);
|
||||
|
||||
|
||||
return 42;
|
||||
}
|
||||
@@ -941,9 +988,9 @@ return 0;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/*
|
||||
* 2023-09-30 this function need more work
|
||||
*/
|
||||
int
|
||||
Test_copie_de_rectangles(char *nomsource)
|
||||
int Test_copie_de_rectangles(char *nomsource)
|
||||
{
|
||||
Image_Desc *source, *image, *finale;
|
||||
int foo, w, h, x, y;
|
||||
@@ -1006,15 +1053,47 @@ Image_DeAllocate(finale); free(finale);
|
||||
return 0;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Test_Egalisations(char *nomsource, int k)
|
||||
/* new: Sat Aug 10 15:32:01 UTC 2024 */
|
||||
int Essai_Televisions(char *nomsource, int k)
|
||||
{
|
||||
Image_Desc *image, *resultat;
|
||||
int foo;
|
||||
|
||||
fprintf(stderr, "================ Televisions %s %d ========\n", nomsource, k);
|
||||
|
||||
|
||||
image = Image_TGA_alloc_load(nomsource);
|
||||
printf("%s : image loaded %p\n", __func__, image);
|
||||
resultat = Image_clone(image, 0);
|
||||
printf("%s : image cloned %p\n", __func__, resultat);
|
||||
|
||||
foo = Image_TV_old(image, resultat, 127, 127, 127);
|
||||
printf("\tTV old -> %d\n", foo);
|
||||
Image_TGA_save("aaaa_tv_old.tga", resultat, 0);
|
||||
|
||||
foo = Image_TV_pix_0(image, resultat, 7, 7, 0);
|
||||
printf("\tTV pix 0 -> %d\n", foo);
|
||||
Image_TGA_save("aaaa_tv_pix_0.tga", resultat, 0);
|
||||
|
||||
foo = Image_TV_cplus_v1(image, resultat, 7);
|
||||
printf("\tTV cplus v1 -> %d\n", foo);
|
||||
Image_TGA_save("aaaa_tv_cplusV1.tga", resultat, 0);
|
||||
|
||||
|
||||
Image_DeAllocate(image); free(image);
|
||||
Image_DeAllocate(resultat); free(resultat);
|
||||
|
||||
return FULL_NUCKED;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int Test_Egalisations(char *nomsource, int k)
|
||||
{
|
||||
Image_Desc *image, *deuxieme, *troisieme;
|
||||
int x, y;
|
||||
|
||||
fprintf(stderr, "============= Egalisations %s %d =====\n", nomsource, k);
|
||||
fprintf(stderr, "================ Egalisations %s %d =====\n", nomsource, k);
|
||||
|
||||
image= Image_TGA_alloc_load(nomsource);
|
||||
image = Image_TGA_alloc_load(nomsource);
|
||||
printf("image loaded %p\n", image);
|
||||
|
||||
deuxieme = Image_clone(image, 0);
|
||||
@@ -1025,19 +1104,18 @@ troisieme = Image_clone(image, 0);
|
||||
printf("image 3 cloned %p\n", troisieme);
|
||||
Image_egalise_RGB(image, troisieme, 0);
|
||||
|
||||
for (x=0; x<image->width; x++)
|
||||
{
|
||||
if (x < image->width/3)
|
||||
{
|
||||
for (y=0; y<image->height; y++)
|
||||
for (x=0; x<image->width; x++) {
|
||||
if (x < image->width/3) {
|
||||
for (y=0; y<image->height; y++) {
|
||||
Image_pixel_copy(image, x, y, troisieme, x, y);
|
||||
}
|
||||
}
|
||||
else
|
||||
if (x > image->width/3*2)
|
||||
{
|
||||
for (y=0; y<image->height; y++)
|
||||
if (x > image->width/3*2) {
|
||||
for (y=0; y<image->height; y++) {
|
||||
Image_pixel_copy(deuxieme, x, y, troisieme, x, y);
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG_LEVEL > 2
|
||||
printf("%4d\r", x); fflush(stdout);
|
||||
@@ -1046,7 +1124,7 @@ for (x=0; x<image->width; x++)
|
||||
|
||||
printf("saving resultat...\n");
|
||||
Image_marque_1(troisieme, "Egalisations", 0);
|
||||
Image_TGA_save("Pictures/aaaa_egal.tga", troisieme, 0);
|
||||
Image_TGA_save("aaaa_egal.tga", troisieme, 0);
|
||||
Image_DeAllocate(image); free(image);
|
||||
Image_DeAllocate(deuxieme); free(deuxieme);
|
||||
Image_DeAllocate(troisieme); free(troisieme);
|
||||
@@ -1054,30 +1132,30 @@ Image_DeAllocate(troisieme); free(troisieme);
|
||||
return 42;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Test_Dithering(char *nomsource, int k)
|
||||
int Test_Dithering(char *nomsource, int k)
|
||||
{
|
||||
Image_Desc *source, *image, *deuxieme, *finale;
|
||||
Image_Rect rect;
|
||||
int foo;
|
||||
int foo, wf, hf;
|
||||
int x2, y2;
|
||||
RGBA ink, pap;
|
||||
|
||||
fprintf(stderr, "========== Dithering on %s (%d) =======\n", nomsource, k);
|
||||
fprintf(stderr, "============== Dithering on %s (%d) =======\n", nomsource, k);
|
||||
|
||||
source = Image_TGA_alloc_load(nomsource);
|
||||
if (NULL == source)
|
||||
{
|
||||
if (NULL == source) {
|
||||
fprintf(stderr, "%s:%s err load %s\n", __FILE__, __func__, nomsource);
|
||||
exit(5);
|
||||
}
|
||||
#if DEBUG_LEVEL
|
||||
Image_dump_descriptor(source, "just after load");
|
||||
#endif
|
||||
|
||||
/*
|
||||
* est-ce bien necessaire ?
|
||||
*/
|
||||
/* Image_egalise_RGB(source, source, 0); */
|
||||
|
||||
wf = source->width; hf = (source->height) * 3;
|
||||
x2 = source->width / 2; y2 = source->height / 2;
|
||||
rect.w = x2; rect.h = y2;
|
||||
rect.x = 0; rect.y = 0;
|
||||
@@ -1085,24 +1163,22 @@ rect.x = 0; rect.y = 0;
|
||||
ink.r = 255, ink.g = 255, ink.b = 100; ink.a = 255;
|
||||
pap.r = 30, pap.g = 30, pap.b = 155; pap.a = 255;
|
||||
|
||||
finale = Image_alloc(source->width, (source->height)*3, 3);
|
||||
if (NULL == finale)
|
||||
{
|
||||
finale = Image_alloc(wf, hf, 3);
|
||||
if (NULL == finale) {
|
||||
fprintf(stderr, "%s:%s:%d err alloc image\n",
|
||||
__FILE__, __func__, __LINE__);
|
||||
exit(5);
|
||||
}
|
||||
printf("image finale allocated %p\n", finale);
|
||||
Image_clear(finale, 0, 200, 0);
|
||||
printf("image finale %dx%d allocated at %p\n", wf, hf, finale);
|
||||
|
||||
image = Image_MakeHalfSize(source, 0);
|
||||
if (NULL == image)
|
||||
{
|
||||
if (NULL == image) {
|
||||
fprintf(stderr, "%s:%s:%d err halfsize image\n",
|
||||
__FILE__, __func__, __LINE__);
|
||||
exit(5);
|
||||
}
|
||||
|
||||
printf("image Half -> %p\n", image);
|
||||
printf("%s: image Half at %p\n", __func__, image);
|
||||
|
||||
Image_DeAllocate(source); free(source);
|
||||
Image_copy_rect(image, &rect, finale, 0, 0);
|
||||
@@ -1148,17 +1224,20 @@ Image_txt1_box_0(finale, "3x3 2", x2, y2*3, 4, &pap, &ink, 0);
|
||||
foo = Image_dither_bayer8x8rnd(image, deuxieme, 5000, 0);
|
||||
printf("retour Dither bayer8x8rnd = %d\n", foo);
|
||||
Image_copy_rect(deuxieme, &rect, finale, x2, y2*4);
|
||||
Image_txt1_box_0(finale, "bayer 8x8 rnd rgb", x2, y2*4, 4, &pap, &ink, 0);
|
||||
Image_txt1_box_0(finale, "bayer8xrnd rgb", x2, y2*4, 4, &pap, &ink, 0);
|
||||
|
||||
foo = Image_dither_bayer8x8rnd(image, deuxieme, 5000, 1);
|
||||
printf("retour Dither bayer8x8rnd = %d\n", foo);
|
||||
Image_copy_rect(deuxieme, &rect, finale, 0, y2*4);
|
||||
Image_txt1_box_0(finale, "bayer 8x8 rnd grey", 0, y2*4, 4, &pap, &ink, 0);
|
||||
Image_txt1_box_0(finale, "bayer8x8rndgrey", 0, y2*4, 4, &pap, &ink, 0);
|
||||
|
||||
Image_TGA_save("Pictures/aaaa_dithering.tga", finale, 0);
|
||||
printf("++++++ test dither\n");
|
||||
Image_dump_descriptor(finale, "just before save");
|
||||
Image_TGA_save("aaaa_dithering.tga", finale, 0);
|
||||
Image_DeAllocate(image); free(image);
|
||||
Image_DeAllocate(deuxieme); free(deuxieme);
|
||||
Image_DeAllocate(finale); free(finale);
|
||||
printf("++++++ fin essais dither\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1177,8 +1256,7 @@ return -1;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/* new 21 juillet 2007 - ave St Exupery */
|
||||
int
|
||||
Test_Effects_A(char *nomsource, int flag)
|
||||
int Test_Effects_A(char *nomsource, int flag)
|
||||
{
|
||||
Image_Desc *source, *image, *deuxieme, *finale;
|
||||
int foo;
|
||||
@@ -1187,8 +1265,7 @@ RGBA ink, pap;
|
||||
|
||||
printf("=== %s %s === %s === %d ===\n", __FILE__, __func__, nomsource, flag);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
if (flag) {
|
||||
fprintf(stderr, "%s: flag is %d ?\n", __func__, flag);
|
||||
}
|
||||
|
||||
@@ -1196,8 +1273,7 @@ ink.r = 255, ink.g = 255, ink.b = 100; ink.a = 255;
|
||||
pap.r = 30, pap.g = 30, pap.b = 155; pap.a = 255;
|
||||
|
||||
source = Image_TGA_alloc_load(nomsource);
|
||||
if (NULL==source)
|
||||
{
|
||||
if (NULL==source) {
|
||||
fprintf(stderr, "%s : il manque '%s'\n", __func__, nomsource);
|
||||
exit(1);
|
||||
}
|
||||
@@ -1273,8 +1349,7 @@ Image_DeAllocate(finale); free(finale);
|
||||
return 42;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Test_des_tamppools(char *imgname, int param)
|
||||
int Test_des_tamppools(char *imgname, int param)
|
||||
{
|
||||
void *ptr;
|
||||
int foo;
|
||||
@@ -1297,30 +1372,31 @@ int Test_des_filtres(char *srcname, int k)
|
||||
Image_Desc *src, *dst;
|
||||
int foo;
|
||||
|
||||
printf("======= LES FILTRES ===[ %s ]==[ %d ]====\n", srcname, k);
|
||||
printf("=============== Filtres =====[ %s ]====[ %d ]====\n", srcname, k);
|
||||
|
||||
src = Image_TGA_alloc_load(srcname);
|
||||
if (NULL == src)
|
||||
{
|
||||
if (NULL == src) {
|
||||
fprintf(stderr, "%s can't load %s\n", __func__, srcname);
|
||||
return 666;
|
||||
}
|
||||
dst = Image_clone(src, 1);
|
||||
if (NULL == dst)
|
||||
{
|
||||
if (NULL == dst) {
|
||||
fprintf(stderr, "mem failure in %s\n", __func__);
|
||||
abort();
|
||||
}
|
||||
|
||||
foo = Image_lissage_3x3(src, dst);
|
||||
Image_TGA_save("Pictures/filtre-liss3x3.tga", dst, 0);
|
||||
Image_TGA_save("filtre-liss3x3.tga", dst, 0);
|
||||
if (foo) { fprintf(stderr, "%s: liss3x3 -> %d\n", __func__, foo); }
|
||||
foo = Image_filtre_Prewitt(src, dst, 5);
|
||||
Image_TGA_save("Pictures/filtre-prewitt-5.tga", dst, 0);
|
||||
Image_TGA_save("filtre-prewitt-5.tga", dst, 0);
|
||||
foo = Image_filtre_passe_haut(src, dst);
|
||||
Image_TGA_save("Pictures/filtre-passe-haut.tga", dst, 0);
|
||||
Image_TGA_save("filtre-passe-haut.tga", dst, 0);
|
||||
|
||||
/*
|
||||
foo = Image_filtre_Sobel_4(src, dst, 0);
|
||||
Image_TGA_save("Pictures/filtre-sobel-4.tga", dst, 0);
|
||||
Image_TGA_save("filtre-sobel-4.tga", dst, 0);
|
||||
*/
|
||||
|
||||
Image_DeAllocate(src); free(src);
|
||||
Image_DeAllocate(dst); free(dst);
|
||||
@@ -1416,3 +1492,17 @@ Image_DeAllocate(dst); free(dst);
|
||||
return -1;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/* ============================== */
|
||||
|
||||
void essai_gradients(void)
|
||||
{
|
||||
int foo;
|
||||
|
||||
foo = Image_plot_H_gradient("foo.tga", 640, 200);
|
||||
fprintf(stderr, "plot h gradient -> %d\n", foo);
|
||||
foo = Image_plot_V_gradient("foo.tga", 900, 200);
|
||||
fprintf(stderr, "plot v gradient -> %d\n", foo);
|
||||
}
|
||||
/* ============================== */
|
||||
/*::------------------------------------------------------------------::*/
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ int Essai_des_lut15bits(char *srcname, int k);
|
||||
int Essai_des_mires(char *, int, int);
|
||||
int Essai_des_zooms(char *srcname, int k);
|
||||
|
||||
int Test_Classif(char *srcname, int k);
|
||||
|
||||
int Essai_des_7_segments(char *srcname, int flag);
|
||||
int Essai_des_distances(char *srcname, int nbre, int flag);
|
||||
int Essai_des_cadres(char *srcname, int flags);
|
||||
@@ -44,7 +46,7 @@ int Test_des_df3(char *txt, int k);
|
||||
int Test_vignettes(char *srcname, int k);
|
||||
|
||||
int Test_classif(char *srcname, int k);
|
||||
int Test_rgbmask(char *srcname);
|
||||
int Test_RGBmask(char *srcname);
|
||||
void Test_rgb2xyz(void);
|
||||
|
||||
int Essai_des_marquages(char *srcname, int nombre, char *texte);
|
||||
@@ -68,7 +70,7 @@ int Test_des_pixeliz(char *srcname, int flags);
|
||||
int Essai_des_bitblt(char *srcname, int k);
|
||||
int Essai_des_gadgrect(char *srcname, int k);
|
||||
|
||||
int Essai_Television(char *source, int k);
|
||||
int Essai_Televisions(char *source, int k);
|
||||
|
||||
/* dans essais2;c */
|
||||
int Essai_des_big_chars(char *fname, int k);
|
||||
|
||||
39
Lib/falsecolors.c
Normal file
39
Lib/falsecolors.c
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* FALSECOLORS.C
|
||||
*
|
||||
* new: Wed Oct 4 07:32:36 UTC 2023
|
||||
*
|
||||
* see also calcluts.c
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "../tthimage.h"
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int Image_gen_fc_lut(float maxval, int nbslots, RGB_map *plut)
|
||||
{
|
||||
int idx, ilut;
|
||||
float fval;
|
||||
|
||||
fprintf(stderr, ">>> %s ( %f %d %p )\n", __func__, maxval, nbslots, plut);
|
||||
|
||||
/* RAZ de les luts */
|
||||
memset(plut, 0, sizeof(RGB_map));
|
||||
|
||||
for (idx=0; idx<nbslots; idx++) {
|
||||
fval = (float)idx / (float)nbslots;
|
||||
ilut = (int)(fval*256.0);
|
||||
fprintf(stderr, " %3d %8.6f %3d\n", idx, fval, ilut);
|
||||
}
|
||||
|
||||
return FULL_NUCKED;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/*::------------------------------------------------------------------::*/
|
||||
132
Lib/filtres.c
132
Lib/filtres.c
@@ -9,8 +9,7 @@
|
||||
#include "../tthimage.h"
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
void
|
||||
Image_filtre_display(FILE *ou, int *mat)
|
||||
void Image_filtre_display(FILE *ou, int *mat)
|
||||
{
|
||||
int cumul, foo;
|
||||
|
||||
@@ -28,8 +27,7 @@ fprintf(ou, "\t+--------------------+------------------+\n");
|
||||
fflush(ou);
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
void
|
||||
Image_rotate_filtre(int *m)
|
||||
void Image_rotate_filtre(int *m)
|
||||
{
|
||||
register int foo;
|
||||
|
||||
@@ -44,8 +42,7 @@ m[2] = m[1];
|
||||
m[1] = foo;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_convolueur3(Image_Desc *in, Image_Desc *out, int *mat)
|
||||
int Image_convolueur3(Image_Desc *in, Image_Desc *out, int *mat)
|
||||
{
|
||||
int foo;
|
||||
|
||||
@@ -57,22 +54,19 @@ foo = Image_convolueur_2(in, out, mat, "rgb");
|
||||
return foo;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_convolueur_2(Image_Desc *in, Image_Desc *out, int *mat, char *planes)
|
||||
int Image_convolueur_2(Image_Desc *in, Image_Desc *out, int *mat, char *planes)
|
||||
{
|
||||
int foo, x, y;
|
||||
long lval;
|
||||
int masque = 0;
|
||||
|
||||
if (in == out)
|
||||
{
|
||||
fprintf(stderr, "convolueur 2: out overwrite in.\n");
|
||||
if (in == out) {
|
||||
fprintf(stderr, "%s: out overwrite in.\n", __func__);
|
||||
return IMG_OVERWRITE;
|
||||
}
|
||||
|
||||
if ( (foo=Image_compare_desc(in, out)) )
|
||||
{
|
||||
fprintf(stderr, "Convolueur: images are differents %d\n", foo);
|
||||
if ( (foo=Image_compare_desc(in, out)) ) {
|
||||
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
@@ -85,9 +79,8 @@ Image_dump_descriptor(out, "image de sortie convolueur");
|
||||
Image_filtre_display(stdout, mat);
|
||||
#endif
|
||||
|
||||
if (mat[9] == 0)
|
||||
{
|
||||
fprintf(stderr, "Convolueur: fuck, divisor is ZERO !\n");
|
||||
if (mat[9] == 0) {
|
||||
fprintf(stderr, "%s: fsck, divisor is ZERO !\n", __func__);
|
||||
/*
|
||||
! c'est sur, avec un message comme c,a je vais pas
|
||||
! pouvoir transmettre mon code aux australiens
|
||||
@@ -99,10 +92,8 @@ if (mat[9] == 0)
|
||||
/*
|
||||
* preparation of the binary mask from the parameter string
|
||||
*/
|
||||
for (foo=0; foo<(int)strlen(planes); foo++)
|
||||
{
|
||||
switch (planes[foo])
|
||||
{
|
||||
for (foo=0; foo<(int)strlen(planes); foo++) {
|
||||
switch (planes[foo]) {
|
||||
case 'r': case 'R':
|
||||
masque |= 8;
|
||||
break;
|
||||
@@ -122,18 +113,14 @@ for (foo=0; foo<(int)strlen(planes); foo++)
|
||||
printf("masque convolueur = %02x\n", masque);
|
||||
#endif
|
||||
|
||||
if ( (masque & 1) && (in->Apix == NULL) )
|
||||
{
|
||||
fprintf(stderr, "Convolueur2: filtering NULL alpha plane is _bad_\n");
|
||||
if ( (masque & 1) && (in->Apix == NULL) ) {
|
||||
fprintf(stderr, "%s: filtering NULL alpha plane is _bad_\n", __func__);
|
||||
return WRONG_CHANNEL;
|
||||
}
|
||||
|
||||
for (y=1; y<((in->height)-1); y++)
|
||||
{
|
||||
for (x=1; x<((in->width)-1); x++)
|
||||
{
|
||||
if (masque & 8)
|
||||
{
|
||||
for (y=1; y<((in->height)-1); y++) {
|
||||
for (x=1; x<((in->width)-1); x++) {
|
||||
if (masque & 8) {
|
||||
lval = mat[0] * in->Rpix[y-1][x-1] +
|
||||
mat[1] * in->Rpix[y-1][x] +
|
||||
mat[2] * in->Rpix[y-1][x+1] +
|
||||
@@ -150,8 +137,7 @@ for (y=1; y<((in->height)-1); y++)
|
||||
out->Rpix[y][x] = (uint8_t)lval;
|
||||
}
|
||||
|
||||
if (masque & 4)
|
||||
{
|
||||
if (masque & 4) {
|
||||
lval = mat[0] * in->Gpix[y-1][x-1] +
|
||||
mat[1] * in->Gpix[y-1][x] +
|
||||
mat[2] * in->Gpix[y-1][x+1] +
|
||||
@@ -168,8 +154,7 @@ for (y=1; y<((in->height)-1); y++)
|
||||
out->Gpix[y][x] = (uint8_t)lval;
|
||||
}
|
||||
|
||||
if (masque & 2)
|
||||
{
|
||||
if (masque & 2) {
|
||||
lval = mat[0] * in->Bpix[y-1][x-1] +
|
||||
mat[1] * in->Bpix[y-1][x] +
|
||||
mat[2] * in->Bpix[y-1][x+1] +
|
||||
@@ -186,8 +171,7 @@ for (y=1; y<((in->height)-1); y++)
|
||||
out->Bpix[y][x] = (uint8_t)lval;
|
||||
}
|
||||
|
||||
if (masque & 1)
|
||||
{
|
||||
if (masque & 1) {
|
||||
lval = mat[0] * in->Apix[y-1][x-1] +
|
||||
mat[1] * in->Apix[y-1][x] +
|
||||
mat[2] * in->Apix[y-1][x+1] +
|
||||
@@ -211,13 +195,11 @@ out->modified = 1;
|
||||
return OLL_KORRECT;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_raz_sides(Image_Desc *im)
|
||||
int Image_raz_sides(Image_Desc *im)
|
||||
{
|
||||
int foo;
|
||||
|
||||
for (foo=0; foo<im->width; foo++)
|
||||
{
|
||||
for (foo=0; foo<im->width; foo++) {
|
||||
(im->Rpix[0])[foo] = 0;
|
||||
(im->Gpix[0])[foo] = 0;
|
||||
(im->Bpix[0])[foo] = 0;
|
||||
@@ -226,8 +208,7 @@ for (foo=0; foo<im->width; foo++)
|
||||
(im->Bpix[im->height-1])[foo] = 0;
|
||||
}
|
||||
|
||||
for (foo=0; foo<im->height; foo++)
|
||||
{
|
||||
for (foo=0; foo<im->height; foo++) {
|
||||
(im->Rpix[foo])[0] = 0;
|
||||
(im->Gpix[foo])[0] = 0;
|
||||
(im->Bpix[foo])[0] = 0;
|
||||
@@ -243,27 +224,22 @@ return OLL_KORRECT;
|
||||
/*
|
||||
* Arf, le grand classique :)
|
||||
*/
|
||||
int
|
||||
Image_lissage_3x3(Image_Desc *in, Image_Desc *out)
|
||||
int Image_lissage_3x3(Image_Desc *in, Image_Desc *out)
|
||||
{
|
||||
int foo, x, y;
|
||||
|
||||
if (in == out)
|
||||
{
|
||||
fprintf(stderr, "Lissage 3x3: out overwrite in\n");
|
||||
if (in == out) {
|
||||
fprintf(stderr, "%s: out overwrite in\n", __func__);
|
||||
return IMG_OVERWRITE;
|
||||
}
|
||||
|
||||
if ( (foo=Image_compare_desc(in, out)) )
|
||||
{
|
||||
fprintf(stderr, "Lissage 3x3: images have differents size, %d\n", foo);
|
||||
if ( (foo=Image_compare_desc(in, out)) ) {
|
||||
fprintf(stderr, "%s: images have differents size, %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
for (y=1; y<((in->height)-1); y++)
|
||||
{
|
||||
for (x=1; x<((in->width)-1); x++)
|
||||
{
|
||||
for (y=1; y<((in->height)-1); y++) {
|
||||
for (x=1; x<((in->width)-1); x++) {
|
||||
|
||||
foo = in->Rpix[y-1][x-1] + in->Rpix[y-1][x] + in->Rpix[y-1][x+1] +
|
||||
in->Rpix[y] [x-1] + in->Rpix[y] [x] + in->Rpix[y] [x+1] +
|
||||
@@ -292,11 +268,9 @@ return OLL_KORRECT;
|
||||
/*
|
||||
* new 14 Jan 2000
|
||||
*/
|
||||
int
|
||||
Image_filtre_Prewitt(Image_Desc *src, Image_Desc *dst, int rotation)
|
||||
int Image_filtre_Prewitt(Image_Desc *src, Image_Desc *dst, int rotation)
|
||||
{
|
||||
static int Prewitt[] =
|
||||
{
|
||||
static int Prewitt[] = {
|
||||
1, 1, 1,
|
||||
0, 0, 0,
|
||||
-1, -1, -1,
|
||||
@@ -318,11 +292,9 @@ return OLL_KORRECT;
|
||||
/*
|
||||
* XXX cette fonction est incorrecte XXX
|
||||
*/
|
||||
int
|
||||
Image_filtre_Sobel(Image_Desc *src, Image_Desc *dst, int rotation)
|
||||
int Image_filtre_Sobel(Image_Desc *src, Image_Desc *dst, int rotation)
|
||||
{
|
||||
static int Sobel[] =
|
||||
{
|
||||
static int Sobel[] = {
|
||||
1, 2, 1,
|
||||
0, 0, 0,
|
||||
-1, -2, -1,
|
||||
@@ -343,13 +315,11 @@ return OLL_KORRECT;
|
||||
* Voir aussi 'sobel4.c' */
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/* new 15 Jan 2000 */
|
||||
int
|
||||
Image_filtre_passe_bas(Image_Desc *src, Image_Desc *dst)
|
||||
int Image_filtre_passe_bas(Image_Desc *src, Image_Desc *dst)
|
||||
{
|
||||
int foo;
|
||||
|
||||
static int PasseBas[] =
|
||||
{
|
||||
static int PasseBas[] = {
|
||||
1, 2, 1,
|
||||
2, 4, 2,
|
||||
1, 2, 1,
|
||||
@@ -363,14 +333,12 @@ return foo;
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/* nouveau: 18 Janvier 2001
|
||||
moral à zéro, il faut que je fasse pédaler le 486 ! */
|
||||
int
|
||||
Image_filtre_random(Image_Desc *src, Image_Desc *dst, int p1, int p2)
|
||||
int Image_filtre_random(Image_Desc *src, Image_Desc *dst, int p1, int p2)
|
||||
{
|
||||
int filtre[11];
|
||||
int foo, somme, v, delta;
|
||||
|
||||
if (p1 == p2)
|
||||
{
|
||||
if (p1 == p2) {
|
||||
fprintf(stderr, "%s: p1=%d must be different from p2=%d\n",
|
||||
__func__, p1, p2);
|
||||
return INVALID_PARAM;
|
||||
@@ -383,8 +351,7 @@ delta = abs(p2 - p1);
|
||||
fprintf(stderr, "%s: delta is %d\n", __func__, delta);
|
||||
#endif
|
||||
|
||||
for (foo=0; foo<9; foo++)
|
||||
{
|
||||
for (foo=0; foo<9; foo++) {
|
||||
v = (rand()%delta)+p1;
|
||||
filtre[foo] = v;
|
||||
somme += v;
|
||||
@@ -405,15 +372,14 @@ return FUNC_IS_BETA;
|
||||
/* nouveau: 3 Fevrier 2001
|
||||
on s'inspire de la precedente.
|
||||
*/
|
||||
int
|
||||
Image_filtre_random_2(Image_Desc *src, Image_Desc *dst,
|
||||
int Image_filtre_random_2(Image_Desc *src, Image_Desc *dst,
|
||||
int p1, int p2, int p3, int p4)
|
||||
{
|
||||
int filtre[11];
|
||||
int foo, somme, v, delta, deltb;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, "Filtre Random 2: %d %d / %d %d\n", p1, p2, p3, p4);
|
||||
fprintf(stderr, "%s: %d %d / %d %d\n", __func__, p1, p2, p3, p4);
|
||||
#endif
|
||||
|
||||
delta = abs(p2 - p1);
|
||||
@@ -423,18 +389,14 @@ fprintf(stderr, "Filtre Random 2: delta are %d %d\n", delta, deltb);
|
||||
#endif
|
||||
|
||||
somme = 0;
|
||||
for (foo=0; foo<9; foo++)
|
||||
{
|
||||
if (foo != 4)
|
||||
{
|
||||
for (foo=0; foo<9; foo++) {
|
||||
if (foo != 4) {
|
||||
v = (rand()%delta)+p1;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
v = (rand()%deltb)+p3;
|
||||
}
|
||||
filtre[foo] = v;
|
||||
|
||||
somme += v;
|
||||
}
|
||||
|
||||
@@ -448,12 +410,10 @@ foo = Image_convolueur_2(src, dst, filtre, "rgb");
|
||||
return FUNC_IS_BETA;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_filtre_passe_haut(Image_Desc *src, Image_Desc *dst)
|
||||
int Image_filtre_passe_haut(Image_Desc *src, Image_Desc *dst)
|
||||
{
|
||||
int foo;
|
||||
static int PasseHaut[] =
|
||||
{
|
||||
static int PasseHaut[] = {
|
||||
-1, -1, -1,
|
||||
-1, 8, -1,
|
||||
-1, -1, -1,
|
||||
|
||||
97
Lib/foo.c
97
Lib/foo.c
@@ -2,18 +2,103 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "../tthimage.h"
|
||||
|
||||
/* ============================== */
|
||||
|
||||
/* new Wed Aug 14 19:17:20 UTC 2024
|
||||
*
|
||||
* parameters :
|
||||
* ip: Image_Desc * of input picture
|
||||
* ix, iy: coordinate of the pixel in this pic.
|
||||
* op, ox, oy : same things for output picture
|
||||
*/
|
||||
#define PIXEL_COPY(ip, ix, iy, op, ox, oy) \
|
||||
do { \
|
||||
(op->Rpix[oy])[ox] = (ip->Rpix[iy])[ix]; \
|
||||
(op->Gpix[oy])[ox] = (ip->Gpix[iy])[ix]; \
|
||||
(op->Bpix[oy])[ox] = (ip->Bpix[iy])[ix]; \
|
||||
} while (0)
|
||||
|
||||
#define SZPIC 4096
|
||||
|
||||
void essai_pixcopy(int usemacro)
|
||||
{
|
||||
Image_Desc *alice, *bob;
|
||||
int x, y, foo;
|
||||
double T0, T1, perpix;
|
||||
long count;
|
||||
char *fname;
|
||||
|
||||
alice = Image_alloc(SZPIC, SZPIC, IMAGE_RGB);
|
||||
bob = Image_alloc(SZPIC, SZPIC, IMAGE_RGB);
|
||||
|
||||
Image_pattern_000(alice, 0);
|
||||
Image_TGA_save("alice.tga", alice, 0);
|
||||
|
||||
T0 = tthi_dtime();
|
||||
count = 0L;
|
||||
|
||||
if (usemacro) {
|
||||
for (y=0; y<SZPIC; y++) {
|
||||
for (x=0; x<SZPIC; x++) {
|
||||
PIXEL_COPY(alice, x, y, bob, x, y);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
fname = "bob1.tga";
|
||||
}
|
||||
else {
|
||||
for (y=0; y<SZPIC; y++) {
|
||||
for (x=0; x<SZPIC; x++) {
|
||||
Image_pixel_copy(alice, x, y, bob, x, y);
|
||||
count++;
|
||||
}
|
||||
}
|
||||
fname = "bob0.tga";
|
||||
}
|
||||
|
||||
T1 = tthi_dtime();
|
||||
|
||||
foo = Image_TGA_save(fname, bob, 0);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s: save -> %d\n", __func__, foo);
|
||||
}
|
||||
|
||||
perpix = ((T1-T0) / (double)count) * 1e6;
|
||||
fprintf(stderr, "%s : %10ld pixels, elapsed %9.6f seconds ==> %9.6f µs/pix\n",
|
||||
usemacro ? "macro" : "func ",
|
||||
count, T1-T0, perpix);
|
||||
|
||||
/* end */
|
||||
}
|
||||
|
||||
/* ============================== */
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Image_print_version(2);
|
||||
Image_print_sizeof_structs("foo");
|
||||
int i;
|
||||
|
||||
if (2==argc)
|
||||
Image_t16x24_essai("16x24thin", argv[1], "16x24.tga");
|
||||
else
|
||||
Image_t16x24_essai("16x24thin", "0123456789abcdef", "16x24.tga");
|
||||
fprintf(stderr, "*********** %s ************\n", argv[0]);
|
||||
|
||||
if (argc > 1) {
|
||||
fprintf(stderr, "argument: %s\n", argv[1]);
|
||||
Image_print_version(2);
|
||||
Image_print_sizeof_structs("foo");
|
||||
}
|
||||
else {
|
||||
for (i=0; i<5; i++) {
|
||||
essai_pixcopy(0);
|
||||
essai_pixcopy(1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
foo = essai_show_t16x24(NULL);
|
||||
fprintf(stderr, "essai show t16x24 --> %d\n", foo);
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
27
Lib/functions.c
Normal file
27
Lib/functions.c
Normal file
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* miscellaneous functions
|
||||
* -----------------------
|
||||
*
|
||||
* new: Thu Aug 15 09:55:36 UTC 2024
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
#include "../tthimage.h"
|
||||
|
||||
/* ------------------------------------------------------------------- */
|
||||
/*
|
||||
* for what FSCKING reason, this func is not in the stdlib ???
|
||||
*/
|
||||
double tthi_dtime(void)
|
||||
{
|
||||
struct timeval t;
|
||||
double d;
|
||||
(void)gettimeofday(&t, NULL);
|
||||
d = (double)t.tv_sec + (double)t.tv_usec / 1e6;
|
||||
return d;
|
||||
}
|
||||
/* ------------------------------------------------------------------- */
|
||||
/* ------------------------------------------------------------------- */
|
||||
@@ -105,7 +105,7 @@ return FULL_NUCKED;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/*
|
||||
* attr,yion parametres bizarres
|
||||
* attention parametres bizarres
|
||||
*/
|
||||
int Image_gadrct_poke_from_tga(char *namesrc, Image_Rect *fromrect,
|
||||
Image_Desc *dst, int xdst, int ydst, int flags)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include "tthimage.h"
|
||||
#include "../tthimage.h"
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/*
|
||||
@@ -32,5 +32,3 @@ for (foo=0; foo<256; foo++)
|
||||
return FULL_NUCKED;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
|
||||
11
Lib/glitch.c
11
Lib/glitch.c
@@ -29,9 +29,9 @@ switch (code)
|
||||
abort();
|
||||
break;
|
||||
}
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, "%s -> %d\n", __func__, foo);
|
||||
#endif
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s got a %d\n", __func__, foo);
|
||||
}
|
||||
|
||||
return FULL_NUCKED;
|
||||
}
|
||||
@@ -53,9 +53,9 @@ for (nbre=0; nbre<k; nbre++)
|
||||
{
|
||||
x = rand() % src->width;
|
||||
y = rand() % src->height;
|
||||
d = rand() & 3;
|
||||
Image_getRGB(src, x, y, &r, &g, &b);
|
||||
|
||||
d = rand() & 3;
|
||||
switch (d)
|
||||
{
|
||||
case 0:
|
||||
@@ -124,6 +124,9 @@ for (nbre=0; nbre<k; nbre++)
|
||||
for (v=y; v<src->height; v++)
|
||||
Image_plotRGB(dst, x, v, r, g, b);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "blurg in %s\n", __func__);
|
||||
return PASTIS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
60
Lib/gradient.c
Normal file
60
Lib/gradient.c
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
gradient.c
|
||||
----------
|
||||
|
||||
new: Sun Sep 17 20:47:57 UTC 2023
|
||||
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "../tthimage.h"
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int Image_plot_H_gradient(char *fname, int w, int h)
|
||||
{
|
||||
Image_Desc *img;
|
||||
int x, y, pix, foo;
|
||||
float fval;
|
||||
|
||||
if ( (img = Image_alloc(w, h, IMAGE_RGB)) == NULL ) {
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, "%s: alloc of img failed, file=%s\n", __func__, fname);
|
||||
#endif
|
||||
return IMAGE_NO_MEM;
|
||||
}
|
||||
|
||||
for (x=0; x<w; x++) {
|
||||
fval = (float)x / (float)(w-1);
|
||||
pix = (int)(fval * 255.0);
|
||||
#if DEBUG_LEVEL > 1
|
||||
printf("%5d %6.3f %5d\n", x, fval, pix);
|
||||
#endif
|
||||
for (y=0; y<h; y++) {
|
||||
(img->Rpix[y])[x] = pix;
|
||||
(img->Gpix[y])[x] = pix;
|
||||
(img->Bpix[y])[x] = pix;
|
||||
}
|
||||
}
|
||||
|
||||
foo = Image_TGA_save(fname, img, 0);
|
||||
if (foo) {
|
||||
fprintf(stderr, "%s: err write to '%s'\n", __func__, fname);
|
||||
return FULL_NUCKED;
|
||||
}
|
||||
|
||||
Image_DeAllocate(img); free(img);
|
||||
|
||||
return FUNC_IS_BETA;
|
||||
}
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int Image_plot_V_gradient(char *fname, int w, int h)
|
||||
{
|
||||
|
||||
return FUNC_IS_ALPHA;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
168
Lib/image.c
168
Lib/image.c
@@ -13,25 +13,24 @@
|
||||
#include "../tthimage.h"
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
void
|
||||
Image_print_version(int flag)
|
||||
void Image_print_version(int flag)
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
fflush(stdout);
|
||||
printf("-+- This is the `tthimage' library v%s (wtfyw 2022) tTh\n",
|
||||
fprintf(stderr, "-+- This is the `tthimage' library v%s (wtfyw 2024) tTh\n",
|
||||
IMAGE_VERSION_STRING);
|
||||
if (flag)
|
||||
{
|
||||
/* this information is only correct IF you touch image.c before
|
||||
* running 'make' utility */
|
||||
printf(" + compiled : %s, %s\n", __DATE__, __TIME__);
|
||||
fprintf(stderr, " + compiled : %s, %s\n", __DATE__, __TIME__);
|
||||
}
|
||||
if (flag > 1)
|
||||
{
|
||||
printf(" + DESTDIR = %s\n", DESTDIR);
|
||||
printf(" + SHAREDIR = %s\n", SHAREDIR);
|
||||
printf(" + CC OPTS = %s\n", CC_OPTS);
|
||||
fprintf(stderr, " + DESTDIR = %s\n", DESTDIR);
|
||||
fprintf(stderr, " + SHAREDIR = %s\n", SHAREDIR);
|
||||
fprintf(stderr, " + CC OPTS = %s\n", CC_OPTS);
|
||||
}
|
||||
fflush(stdout);
|
||||
|
||||
@@ -94,8 +93,7 @@ return 0;
|
||||
* on the structure who describe the image.
|
||||
* - - - > don't "free" this pointer, please.
|
||||
*/
|
||||
Image_Desc *
|
||||
Image_alloc(int width, int height, int type)
|
||||
Image_Desc * Image_alloc(int width, int height, int type)
|
||||
{
|
||||
Image_Desc *header;
|
||||
int foo;
|
||||
@@ -193,19 +191,18 @@ return header;
|
||||
/*
|
||||
This fonction build another image from a model.
|
||||
*/
|
||||
Image_Desc *
|
||||
Image_clone (Image_Desc *src, int copy)
|
||||
Image_Desc * Image_clone (Image_Desc *src, int copy)
|
||||
{
|
||||
Image_Desc *image;
|
||||
|
||||
if ( src==NULL )
|
||||
if ( NULL == src )
|
||||
{
|
||||
fprintf(stderr, "Image_clone: source descriptor is NULL\n");
|
||||
exit(5);
|
||||
}
|
||||
|
||||
image = Image_alloc(src->width, src->height, src->type);
|
||||
if ( image==NULL )
|
||||
if ( NULL == image )
|
||||
{
|
||||
fprintf(stderr, "Image_clone: cloned descriptor is NULL\n");
|
||||
exit(5);
|
||||
@@ -247,20 +244,16 @@ return FUNC_IS_ALPHA;
|
||||
* Helas, cette fonction ne marche que sur les images RGB
|
||||
* et comment la rendre compatible tout-types sans tout casser ?
|
||||
*/
|
||||
int
|
||||
Image_clear( Image_Desc *image, int r, int g, int b )
|
||||
int Image_clear( Image_Desc *image, int r, int g, int b )
|
||||
{
|
||||
int x, y;
|
||||
|
||||
if (image->type == IMAGE_RGB)
|
||||
{
|
||||
for (y=0; y<image->height; y++)
|
||||
{
|
||||
if (image->type == IMAGE_RGB) {
|
||||
for (y=0; y<image->height; y++) {
|
||||
/*
|
||||
* XXX here we can go faster with a few memset
|
||||
*/
|
||||
for (x=0; x<image->width; x++)
|
||||
{
|
||||
for (x=0; x<image->width; x++) {
|
||||
(image->Rpix[y])[x] = r;
|
||||
(image->Gpix[y])[x] = g;
|
||||
(image->Bpix[y])[x] = b;
|
||||
@@ -270,12 +263,9 @@ if (image->type == IMAGE_RGB)
|
||||
return 0; /* ok, this 'return' here is a "spleyterie" :) */
|
||||
}
|
||||
|
||||
if (image->type == IMAGE_RGBA)
|
||||
{
|
||||
for (y=0; y<image->height; y++)
|
||||
{
|
||||
for (x=0; x<image->width; x++)
|
||||
{
|
||||
if (image->type == IMAGE_RGBA) {
|
||||
for (y=0; y<image->height; y++) {
|
||||
for (x=0; x<image->width; x++) {
|
||||
(image->Rpix[y])[x] = r;
|
||||
(image->Gpix[y])[x] = g;
|
||||
(image->Bpix[y])[x] = b;
|
||||
@@ -290,12 +280,40 @@ fprintf(stderr, "%s : invalid image type %d : %s\n", __func__,
|
||||
return IMAGE_BAD_TYPE;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/* new: Sat Sep 23 19:07:03 UTC 2023
|
||||
*
|
||||
*/
|
||||
int Image_set_rgb(Image_Desc *img, RGBA *rgba)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p %p ) %d %d %d\n", __func__, img,
|
||||
rgba, rgba->r, rgba->g, rgba->b);
|
||||
#endif
|
||||
|
||||
if (IMAGE_RGB != img->type) {
|
||||
fprintf(stderr, "%s : invalid image type %d : %s\n", __func__,
|
||||
img->type, Image_type2str(img->type));
|
||||
return IMAGE_BAD_TYPE;
|
||||
}
|
||||
|
||||
for (y=0; y<img->height; y++) {
|
||||
for (x=0; x<img->width; x++) {
|
||||
/* please, use memset here */
|
||||
(img->Rpix[y])[x] = rgba->r;
|
||||
(img->Gpix[y])[x] = rgba->g;
|
||||
(img->Bpix[y])[x] = rgba->b;
|
||||
}
|
||||
}
|
||||
return FUNC_IS_BETA;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/*
|
||||
* every image in memory have a comment field, who is writen
|
||||
* in TGA and PNM file when image is saved.
|
||||
*/
|
||||
int
|
||||
Image_set_comment(Image_Desc *image, char *text)
|
||||
int Image_set_comment(Image_Desc *image, char *text)
|
||||
{
|
||||
if (strlen(text) > IMG_OBJCOMMENT_LEN)
|
||||
return STRING_TOO_LONG;
|
||||
@@ -304,8 +322,7 @@ return OLL_KORRECT;
|
||||
}
|
||||
/* 10 nov 2001: no #define for this not-so-magic 254 value ? */
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_plot_gray(Image_Desc *img, int x, int y, int v)
|
||||
int Image_plot_gray(Image_Desc *img, int x, int y, int v)
|
||||
{
|
||||
if ( x<0 || y<0 || x>=img->width || y>=img->height )
|
||||
{
|
||||
@@ -325,8 +342,7 @@ int Image_plotRGB(Image_Desc *img, int x, int y, int r, int g, int b)
|
||||
fprintf(stderr, "PLOTRGB %d %d\n", x, y);
|
||||
#endif
|
||||
|
||||
if ( x<0 || y<0 || x>=img->width || y>=img->height )
|
||||
{
|
||||
if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
|
||||
fprintf(stderr, "Errplot RGB X=%d, Y=%d %d, %d, %d\n", x, y, r, g, b);
|
||||
#if FORCE_ABORT
|
||||
abort();
|
||||
@@ -341,8 +357,7 @@ return OLL_KORRECT;
|
||||
|
||||
int Image_plotRGBA(Image_Desc *img, int x, int y, int r, int g, int b, int a)
|
||||
{
|
||||
if ( x<0 || y<0 || x>=img->width || y>=img->height )
|
||||
{
|
||||
if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
|
||||
/* may be an #if DEBUG_LEVEL here ? */
|
||||
fprintf(stderr, "Errplot RGBA X %4d Y %4d %d, %d, %d, %d\n",
|
||||
x, y, r, g, b, a);
|
||||
@@ -360,11 +375,9 @@ if ( x<0 || y<0 || x>=img->width || y>=img->height )
|
||||
return OLL_KORRECT;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_getRGB(Image_Desc *img, int x, int y, int *pr, int *pg, int *pb)
|
||||
int Image_getRGB(Image_Desc *img, int x, int y, int *pr, int *pg, int *pb)
|
||||
{
|
||||
if ( x<0 || y<0 || x>=img->width || y>=img->height )
|
||||
{
|
||||
if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
|
||||
/* may be an #if DEBUG_LEVEL here ? */
|
||||
fprintf(stderr, "ERR GETRGB X %4d Y %4d\n", x, y);
|
||||
#if FORCE_ABORT
|
||||
@@ -380,11 +393,9 @@ if ( x<0 || y<0 || x>=img->width || y>=img->height )
|
||||
return OLL_KORRECT;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_getRGBA(Image_Desc *img, int x, int y, int *pr, int *pg, int *pb, int *pa)
|
||||
int Image_getRGBA(Image_Desc *img, int x, int y, int *pr, int *pg, int *pb, int *pa)
|
||||
{
|
||||
if ( x<0 || y<0 || x>=img->width || y>=img->height )
|
||||
{
|
||||
if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
|
||||
fprintf(stderr, "ERR GETRGBA X %4d Y %4d\n", x, y);
|
||||
#if FORCE_ABORT
|
||||
abort();
|
||||
@@ -392,10 +403,9 @@ if ( x<0 || y<0 || x>=img->width || y>=img->height )
|
||||
return OUT_OF_IMAGE;
|
||||
}
|
||||
|
||||
if (img->type != IMAGE_RGBA)
|
||||
{
|
||||
fprintf(stderr, "Image get RGBA: bad image type: %d, %s\n",
|
||||
img->type, Image_type2str(img->type));
|
||||
if (img->type != IMAGE_RGBA) {
|
||||
fprintf(stderr, "%s: bad image type: %d, %s\n",
|
||||
__func__, img->type, Image_type2str(img->type));
|
||||
#if FORCE_ABORT
|
||||
abort();
|
||||
#endif
|
||||
@@ -416,16 +426,14 @@ return OLL_KORRECT;
|
||||
*/
|
||||
int Image_plot_channel(Image_Desc *img, char channel, int x, int y, int value)
|
||||
{
|
||||
if ( x<0 || y<0 || x>=img->width || y>=img->height )
|
||||
{
|
||||
if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, "ERR PLOTCHANNEL X %4d Y %4d\n", x, y);
|
||||
#endif
|
||||
return OUT_OF_IMAGE;
|
||||
}
|
||||
|
||||
switch (channel)
|
||||
{
|
||||
switch (channel) {
|
||||
case 'r': case 'R': (img->Rpix[y])[x] = (uint8_t)(value&0xff); break;
|
||||
case 'g': case 'G': (img->Gpix[y])[x] = (uint8_t)(value&0xff); break;
|
||||
case 'b': case 'B': (img->Bpix[y])[x] = (uint8_t)(value&0xff); break;
|
||||
@@ -439,44 +447,36 @@ return OLL_KORRECT;
|
||||
/*
|
||||
lecture d'une des composantes de l'image.
|
||||
*/
|
||||
int
|
||||
Image_R_pixel(Image_Desc *img, int x, int y)
|
||||
int Image_R_pixel(Image_Desc *img, int x, int y)
|
||||
{
|
||||
if ( x<0 || y<0 || x>=img->width || y>=img->height )
|
||||
{
|
||||
if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
|
||||
fprintf(stderr, "ERR READ R PIX X%d Y%d\n", x, y);
|
||||
return OUT_OF_IMAGE;
|
||||
}
|
||||
return (int)((img->Rpix[y])[x]);
|
||||
}
|
||||
|
||||
int
|
||||
Image_G_pixel(Image_Desc *img, int x, int y)
|
||||
int Image_G_pixel(Image_Desc *img, int x, int y)
|
||||
{
|
||||
if ( x<0 || y<0 || x>=img->width || y>=img->height )
|
||||
{
|
||||
if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
|
||||
fprintf(stderr, "ERR READ G PIX X%d Y%d\n", x, y);
|
||||
return OUT_OF_IMAGE;
|
||||
}
|
||||
return (int)((img->Gpix[y])[x]);
|
||||
}
|
||||
|
||||
int
|
||||
Image_B_pixel(Image_Desc *img, int x, int y)
|
||||
int Image_B_pixel(Image_Desc *img, int x, int y)
|
||||
{
|
||||
if ( x<0 || y<0 || x>=img->width || y>=img->height )
|
||||
{
|
||||
if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
|
||||
fprintf(stderr, "ERR READ B PIX X%d Y%d\n", x, y);
|
||||
return OUT_OF_IMAGE;
|
||||
}
|
||||
return (int)((img->Bpix[y])[x]);
|
||||
}
|
||||
|
||||
int
|
||||
Image_A_pixel(Image_Desc *img, int x, int y)
|
||||
int Image_A_pixel(Image_Desc *img, int x, int y)
|
||||
{
|
||||
if ( x<0 || y<0 || x>=img->width || y>=img->height )
|
||||
{
|
||||
if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
|
||||
fprintf(stderr, "ERR A PIX X%d Y%d\n", x, y);
|
||||
return OUT_OF_IMAGE;
|
||||
}
|
||||
@@ -487,19 +487,16 @@ return (int)((img->Apix[y])[x]);
|
||||
cette fonction ne marche que si les deux images
|
||||
sont allouees et de meme dimensions.
|
||||
*/
|
||||
int
|
||||
Image_copy(Image_Desc *src, Image_Desc *dst)
|
||||
int Image_copy(Image_Desc *src, Image_Desc *dst)
|
||||
{
|
||||
int foo;
|
||||
|
||||
if ( (foo=Image_compare_desc(src, dst)) )
|
||||
{
|
||||
fprintf(stderr, "Image_Copy: images are differents %d\n", foo);
|
||||
if ( (foo=Image_compare_desc(src, dst)) ) {
|
||||
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
for (foo=0; foo<src->height; foo++)
|
||||
{
|
||||
for (foo=0; foo<src->height; foo++) {
|
||||
memcpy(dst->Rpix[foo], src->Rpix[foo], src->width);
|
||||
memcpy(dst->Gpix[foo], src->Gpix[foo], src->width);
|
||||
memcpy(dst->Bpix[foo], src->Bpix[foo], src->width);
|
||||
@@ -521,10 +518,9 @@ return 0;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/*
|
||||
* no boundary control ?
|
||||
* no boundary control ? XXX
|
||||
*/
|
||||
int
|
||||
Image_pixel_copy(Image_Desc *s, int x, int y, Image_Desc *d, int i, int j)
|
||||
int Image_pixel_copy(Image_Desc *s, int x, int y, Image_Desc *d, int i, int j)
|
||||
{
|
||||
|
||||
(d->Rpix[j])[i] = (s->Rpix[y])[x];
|
||||
@@ -538,21 +534,18 @@ return OLL_KORRECT;
|
||||
* Le nom de cette fonction n'a pas trop de rapport avec ce qu'elle fait,
|
||||
* mais elle permet de faire reculer Crash Coredump.
|
||||
*/
|
||||
int
|
||||
Image_compare_desc(Image_Desc *a, Image_Desc *b)
|
||||
int Image_compare_desc(Image_Desc *a, Image_Desc *b)
|
||||
{
|
||||
char *fmt = "Image at %p have no 'Dead Beef' in it\n";
|
||||
char *fmt = "%s: Image at %p have no 'Dead Beef' in it\n";
|
||||
|
||||
if ( (a==NULL) || (b==NULL) ) return NULL_DESCRIPTOR;
|
||||
|
||||
if ( a->magic != MAGIC_OF_IMAGE )
|
||||
{
|
||||
fprintf(stderr, fmt, a);
|
||||
if ( a->magic != MAGIC_OF_IMAGE ) {
|
||||
fprintf(stderr, fmt, __func__, a);
|
||||
return NOT_AN_IMAGE_DESC;
|
||||
}
|
||||
if ( b->magic != MAGIC_OF_IMAGE )
|
||||
{
|
||||
fprintf(stderr, fmt, a);
|
||||
if ( b->magic != MAGIC_OF_IMAGE ) {
|
||||
fprintf(stderr, fmt, __func__, a);
|
||||
return NOT_AN_IMAGE_DESC;
|
||||
}
|
||||
|
||||
@@ -570,8 +563,7 @@ return OLL_KORRECT;
|
||||
c'est qu'il reste un pointeur fou chez
|
||||
l'appelant ...
|
||||
*/
|
||||
int
|
||||
Image_DeAllocate(Image_Desc *im)
|
||||
int Image_DeAllocate(Image_Desc *im)
|
||||
{
|
||||
int line;
|
||||
|
||||
|
||||
@@ -38,12 +38,10 @@ Image_marque_1(Image_Desc *img, char *texte, int flags)
|
||||
RGBA papier, encre;
|
||||
int len;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
if (flags)
|
||||
{
|
||||
fprintf(stderr, "*** %s 'flags' must be ZERO ***\n", __func__);
|
||||
}
|
||||
#endif
|
||||
|
||||
len = strlen(texte);
|
||||
if (len < 1) return FULL_NUCKED;
|
||||
@@ -110,22 +108,19 @@ fprintf(stderr, "%s: '%s' %s\n", __func__, texte, ptr);
|
||||
#endif
|
||||
|
||||
papier.r = papier.g = papier.b = papier.a = 0;
|
||||
if (rgba == NULL)
|
||||
{
|
||||
if (NULL == rgba) {
|
||||
encre.r = encre.g = encre.b = 90, encre.a = 255;
|
||||
rgba = &encre;
|
||||
}
|
||||
|
||||
if (flags & 1)
|
||||
{
|
||||
if (flags & 1) {
|
||||
rect.x = rect.y = 3;
|
||||
rect.h = 11; rect.w = l1*8+2;
|
||||
Image_paint_rect(img, &rect, 255, 255, 255);
|
||||
}
|
||||
Image_trace_chaine_1(img, texte, 5, 6, "libimage.fonte", &papier, rgba);
|
||||
|
||||
if (flags & 1)
|
||||
{
|
||||
if (flags & 1) {
|
||||
rect.x = 3; rect.y = 16;
|
||||
rect.h = 11; rect.w = l2*8+2;
|
||||
Image_paint_rect(img, &rect, 255, 255, 255);
|
||||
@@ -133,10 +128,6 @@ if (flags & 1)
|
||||
|
||||
Image_trace_chaine_1(img, ptr, 5, 18, NULL, &papier, rgba);
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, "done %s\n", __func__);
|
||||
#endif
|
||||
|
||||
img->modified = 1;
|
||||
|
||||
return FUNC_IS_BETA;
|
||||
@@ -145,8 +136,7 @@ return FUNC_IS_BETA;
|
||||
/*
|
||||
* Pour centrer la grille, il faut jouer sur 'ox' et 'oy' ?
|
||||
*/
|
||||
int
|
||||
Image_grille(Image_Desc *im, int stx, int ox, int sty, int oy, RGBA *ink)
|
||||
int Image_grille(Image_Desc *im, int stx, int ox, int sty, int oy, RGBA *ink)
|
||||
{
|
||||
int x, y, foo;
|
||||
RGBA encre;
|
||||
@@ -167,16 +157,13 @@ if (ink == NULL) {
|
||||
fprintf(stderr, "%s X: %d %d Y: %d %d\n", __func__, ox, stx, oy, sty);
|
||||
#endif
|
||||
|
||||
for (x=ox; x<im->width; x+=stx)
|
||||
{
|
||||
for (x=ox; x<im->width; x+=stx) {
|
||||
for (foo=0; foo<im->height; foo++)
|
||||
Image_plotRGB(im, x, foo, ink->r, ink->g, ink->b);
|
||||
}
|
||||
|
||||
for (y=oy; y<im->height; y+=sty)
|
||||
{
|
||||
for (foo=0; foo<im->width; foo++)
|
||||
{
|
||||
for (y=oy; y<im->height; y+=sty) {
|
||||
for (foo=0; foo<im->width; foo++) {
|
||||
Image_plotRGB(im, foo, y, ink->r, ink->g, ink->b);
|
||||
}
|
||||
}
|
||||
@@ -189,14 +176,12 @@ return FUNC_IS_BETA;
|
||||
/*
|
||||
* Pour centrer la grille, il faut jouer sur 'ox' et 'oy' ?
|
||||
*/
|
||||
int
|
||||
Image_grille_xor(Image_Desc *im, int stx, int ox, int sty, int oy, RGBA *ink)
|
||||
int Image_grille_xor(Image_Desc *im, int stx, int ox, int sty, int oy, RGBA *ink)
|
||||
{
|
||||
int x, y, foo;
|
||||
RGBA encre;
|
||||
|
||||
if (ink == NULL)
|
||||
{
|
||||
if (ink == NULL) {
|
||||
fprintf(stderr, "%s is using default XOR values\n", __func__);
|
||||
encre.r = encre.g = encre.b = encre.a = 0xff;
|
||||
ink = &encre;
|
||||
@@ -206,18 +191,14 @@ if (ink == NULL)
|
||||
fprintf(stderr, "%s X %d %d Y %d %d\n", __func__, ox, stx, oy, sty);
|
||||
#endif
|
||||
|
||||
for (x=ox; x<im->width; x+=stx)
|
||||
{
|
||||
for (foo=0; foo<im->height; foo++)
|
||||
{
|
||||
for (x=ox; x<im->width; x+=stx) {
|
||||
for (foo=0; foo<im->height; foo++) {
|
||||
Image_XOR_pixel(im, x, foo, ink->r, ink->g, ink->b);
|
||||
}
|
||||
}
|
||||
|
||||
for (y=oy; y<im->height; y+=sty)
|
||||
{
|
||||
for (foo=0; foo<im->width; foo++)
|
||||
{
|
||||
for (y=oy; y<im->height; y+=sty) {
|
||||
for (foo=0; foo<im->width; foo++) {
|
||||
Image_XOR_pixel(im, foo, y, ink->r, ink->g, ink->b);
|
||||
}
|
||||
}
|
||||
|
||||
79
Lib/mircol.c
79
Lib/mircol.c
@@ -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++)
|
||||
@@ -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;
|
||||
|
||||
53
Lib/morpho.c
53
Lib/morpho.c
@@ -27,33 +27,24 @@ static struct
|
||||
* =============================
|
||||
* 23 avril 2007: switched to direct pixel access.
|
||||
*/
|
||||
int
|
||||
Image_expand_max(Image_Desc *src, Image_Desc *dst, int factor)
|
||||
int Image_expand_max(Image_Desc *src, Image_Desc *dst, int factor)
|
||||
{
|
||||
int foo, x, y, maxr, maxg, maxb;
|
||||
int r, g, b;
|
||||
|
||||
if ( (foo=Image_compare_desc(src, dst)) )
|
||||
{
|
||||
if ( (foo=Image_compare_desc(src, dst)) ) {
|
||||
fprintf(stderr, "%s: images non compatibles\n", __func__);
|
||||
return foo;
|
||||
}
|
||||
|
||||
if ( 0 != factor )
|
||||
{
|
||||
if ( 0 != factor ) {
|
||||
fprintf(stderr, "%s: factor (%d) must be 0\n", __func__, factor);
|
||||
}
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, "expanding MAX %p to %p\n", src, dst);
|
||||
#endif
|
||||
|
||||
for (y=1; y<src->height-1; y++)
|
||||
{
|
||||
for (x=1; x<src->width-1; x++)
|
||||
{
|
||||
for (y=1; y<src->height-1; y++) {
|
||||
for (x=1; x<src->width-1; x++) {
|
||||
maxr = maxg = maxb = 0;
|
||||
for (foo=0; foo<9; foo++)
|
||||
{
|
||||
for (foo=0; foo<9; foo++) {
|
||||
/* XXX Faster pussy cat !
|
||||
Image_getRGB(src, x+deltas[foo].x, y+deltas[foo].y,
|
||||
&r, &g, &b);
|
||||
@@ -78,19 +69,16 @@ dst->modified = 1;
|
||||
return 0;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_expand_min(Image_Desc *src, Image_Desc *dst, int factor)
|
||||
int Image_expand_min(Image_Desc *src, Image_Desc *dst, int factor)
|
||||
{
|
||||
int foo, x, y, minr, ming, minb;
|
||||
int r, g, b;
|
||||
|
||||
if ( (foo=Image_compare_desc(src, dst)) )
|
||||
{
|
||||
if ( (foo=Image_compare_desc(src, dst)) ) {
|
||||
return foo;
|
||||
}
|
||||
|
||||
if ( 0 != factor )
|
||||
{
|
||||
if ( 0 != factor ) {
|
||||
fprintf(stderr, "%s: factor (%d) must be 0\n", __func__, factor);
|
||||
}
|
||||
|
||||
@@ -98,13 +86,10 @@ if ( 0 != factor )
|
||||
fprintf(stderr, "expanding MIN %p to %p\n", src, dst);
|
||||
#endif
|
||||
|
||||
for (y=1; y<src->height-1; y++)
|
||||
{
|
||||
for (x=1; x<src->width-1; x++)
|
||||
{
|
||||
for (y=1; y<src->height-1; y++) {
|
||||
for (x=1; x<src->width-1; x++) {
|
||||
minr = ming = minb = 1664;
|
||||
for (foo=0; foo<9; foo++)
|
||||
{
|
||||
for (foo=0; foo<9; foo++) {
|
||||
Image_getRGB(src, x+deltas[foo].x, y+deltas[foo].y,
|
||||
&r, &g, &b);
|
||||
|
||||
@@ -133,8 +118,7 @@ Image_sortmat_display(FILE *ou, struct sort_pixel *table)
|
||||
fprintf(ou, "%s ( %p )\n", __func__, table);
|
||||
}
|
||||
|
||||
int
|
||||
Image_Gray_Sorted_Points(Image_Desc *src, Image_Desc *dst, int *filtre)
|
||||
int Image_Gray_Sorted_Points(Image_Desc *src, Image_Desc *dst, int *filtre)
|
||||
{
|
||||
int x, y, r, g, b;
|
||||
int foo, gris;
|
||||
@@ -145,13 +129,10 @@ struct sort_pixel pixels[9];
|
||||
fprintf(stderr, "Image Gray Sorted Points: %p -> %p\n", src, dst);
|
||||
#endif
|
||||
|
||||
for (y=1; y<src->height-1; y++)
|
||||
{
|
||||
for (x=1; x<src->width-1; x++)
|
||||
{
|
||||
for (y=1; y<src->height-1; y++) {
|
||||
for (x=1; x<src->width-1; x++) {
|
||||
/* collecte des infos sur les voisins. */
|
||||
for (foo=0; foo<9; foo++)
|
||||
{
|
||||
for (foo=0; foo<9; foo++) {
|
||||
Image_getRGB(src, x+deltas[foo].x, y+deltas[foo].y,
|
||||
&r, &g, &b);
|
||||
|
||||
|
||||
19
Lib/msglib.c
19
Lib/msglib.c
@@ -9,13 +9,11 @@
|
||||
#include "../tthimage.h"
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
char *
|
||||
Image_type2str(int type)
|
||||
char * Image_type2str(int type)
|
||||
{
|
||||
char *pstr;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
switch (type) {
|
||||
case IMAGE_RGB: pstr = "RGB"; break;
|
||||
case IMAGE_RGBA: pstr = "RGBA"; break;
|
||||
case IMAGE_GRAY: pstr = "Gray"; break;
|
||||
@@ -29,14 +27,12 @@ switch (type)
|
||||
return pstr;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
char *
|
||||
Image_err2str(int codeerr)
|
||||
char * Image_err2str(int codeerr)
|
||||
{
|
||||
char *pstr;
|
||||
static char chaine[100];
|
||||
|
||||
switch (codeerr)
|
||||
{
|
||||
switch (codeerr) {
|
||||
case -1: pstr = "error: invalid error"; break;
|
||||
case OLL_KORRECT: pstr = "no error"; break;
|
||||
case 42: pstr = "Universal answer"; break;
|
||||
@@ -114,7 +110,8 @@ switch (codeerr)
|
||||
sprintf(chaine, "error code %d is unknow", codeerr);
|
||||
pstr = chaine;
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, "* WTF ? Error %d unknow ?\n", codeerr);
|
||||
fprintf(stderr, "%s: WTF ? Error %d unknow ?\n",
|
||||
__func__, codeerr);
|
||||
#if FORCE_ABORT
|
||||
abort();
|
||||
#endif
|
||||
@@ -125,8 +122,7 @@ return pstr;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/* new 14 Feb 2000 */
|
||||
void
|
||||
Image_print_error(char * texte, int err)
|
||||
void Image_print_error(char * texte, int err)
|
||||
{
|
||||
FILE *fp;
|
||||
char *errtxt;
|
||||
@@ -145,4 +141,3 @@ fprintf(fp, "%s '%s': %d, %s\n", err ? "Error :" : "Waouh !",
|
||||
fflush(fp);
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
|
||||
|
||||
92
Lib/op2x2.c
92
Lib/op2x2.c
@@ -13,12 +13,10 @@
|
||||
* 6 Fev 2001: on aimerait bien avoir la doc de cette fonction
|
||||
* 27 Juillet 2008: on attend toujours...
|
||||
*/
|
||||
int
|
||||
Image_2x2_contours_0(Image_Desc *im)
|
||||
int Image_2x2_contours_0(Image_Desc *im)
|
||||
{
|
||||
int x, y, q;
|
||||
int tbl[] =
|
||||
{
|
||||
int tbl[] = {
|
||||
0, 1, 1, 1,
|
||||
1, 1, 0, 1,
|
||||
1, 0, 1, 1,
|
||||
@@ -29,10 +27,8 @@ int tbl[] =
|
||||
fprintf(stderr, "%s : w=%d h=%d\n", __func__, im->width, im->height);
|
||||
#endif
|
||||
|
||||
for (x=0; x<(im->width-1); x++)
|
||||
{
|
||||
for (y=0; y<(im->height-1); y++)
|
||||
{
|
||||
for (x=0; x<(im->width-1); x++) {
|
||||
for (y=0; y<(im->height-1); y++) {
|
||||
q = ((im->Rpix[y] [x] ? 0 : 1) << 3 ) |
|
||||
((im->Rpix[y] [x+1] ? 0 : 1) << 2 ) |
|
||||
((im->Rpix[y+1][x] ? 0 : 1) << 1 ) |
|
||||
@@ -58,14 +54,13 @@ return OLL_KORRECT;
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/* updated 31 august 2008 */
|
||||
/* le seul bit utilise dans l'image source est le bit 7 */
|
||||
int
|
||||
Image_2x2_contours_1(Image_Desc *src, Image_Desc *dst)
|
||||
int Image_2x2_contours_1(Image_Desc *src, Image_Desc *dst)
|
||||
{
|
||||
int foo;
|
||||
int x, y, q;
|
||||
|
||||
if ( (foo=Image_compare_desc(src, dst)) )
|
||||
{
|
||||
if ( (foo=Image_compare_desc(src, dst)) ) {
|
||||
fprintf(stderr, "%s: err compare %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
#if DEBUG_LEVEL
|
||||
@@ -73,10 +68,8 @@ fprintf(stderr, "*** %s *** catastrophic function :)\n", __func__);
|
||||
#endif
|
||||
Image_clear(dst, 0, 0, 0);
|
||||
|
||||
for (x=0; x<(src->width-1); x++)
|
||||
{
|
||||
for (y=0; y<(src->height-1); y++)
|
||||
{
|
||||
for (x=0; x<(src->width-1); x++) {
|
||||
for (y=0; y<(src->height-1); y++) {
|
||||
q = ((0x80 & (src->Rpix[y] [x] ) ? 0 : 1) << 3 ) |
|
||||
((0x80 & (src->Rpix[y] [x+1]) ? 0 : 1) << 2 ) |
|
||||
((0x80 & (src->Rpix[y+1][x] ) ? 0 : 1) << 1 ) |
|
||||
@@ -101,8 +94,7 @@ return FUNC_IS_BETA;
|
||||
/*
|
||||
* 6 Fev 2001: on aimerait bien avoir la doc de cette fonction
|
||||
*/
|
||||
int
|
||||
Image_2x2_contrast(Image_Desc *src, Image_Desc *dst)
|
||||
int Image_2x2_contrast(Image_Desc *src, Image_Desc *dst)
|
||||
{
|
||||
int foo, x, y, r, g, b;
|
||||
int mir, mig, mib, mar, mag, mab;
|
||||
@@ -110,19 +102,16 @@ int mir, mig, mib, mar, mag, mab;
|
||||
int dx[4] = { 0, 1, 0, 1 };
|
||||
int dy[4] = { 0, 0, 1, 1 };
|
||||
|
||||
if ( (foo=Image_compare_desc(src, dst)) )
|
||||
{
|
||||
if ( (foo=Image_compare_desc(src, dst)) ) {
|
||||
fprintf(stderr, "%s: err compare %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
for (y=0; y<src->height-1; y++)
|
||||
{
|
||||
for (x=0; x<src->width-1; x++)
|
||||
{
|
||||
for (y=0; y<src->height-1; y++) {
|
||||
for (x=0; x<src->width-1; x++) {
|
||||
mir = mig = mib = 342;
|
||||
mar = mag = mab = -42;
|
||||
for (foo=0; foo<4; foo++)
|
||||
{
|
||||
for (foo=0; foo<4; foo++) {
|
||||
r = (src->Rpix[y+dy[foo]])[x+dx[foo]];
|
||||
g = (src->Gpix[y+dy[foo]])[x+dx[foo]];
|
||||
b = (src->Bpix[y+dy[foo]])[x+dx[foo]];
|
||||
@@ -148,8 +137,7 @@ return FUNC_IS_BETA;
|
||||
/*
|
||||
* 6 Fev 2001: on aimerait bien avoir la doc de cette fonction
|
||||
*/
|
||||
int
|
||||
Image_2x2_lissage(Image_Desc *src, Image_Desc *dst)
|
||||
int Image_2x2_lissage(Image_Desc *src, Image_Desc *dst)
|
||||
{
|
||||
int foo, x, y;
|
||||
int tir, tig, tib;
|
||||
@@ -157,8 +145,8 @@ int tir, tig, tib;
|
||||
int dx[4] = { 0, 1, 0, 1 };
|
||||
int dy[4] = { 0, 0, 1, 1 };
|
||||
|
||||
if ( (foo=Image_compare_desc(src, dst)) )
|
||||
{
|
||||
if ( (foo=Image_compare_desc(src, dst)) ) {
|
||||
fprintf(stderr, "%s: err compare %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
@@ -166,13 +154,10 @@ if ( (foo=Image_compare_desc(src, dst)) )
|
||||
* attention, il faut bien reflechir avant de tenter d'inverser l'ordre
|
||||
* de parcours en ligne & colonne !
|
||||
*/
|
||||
for (y=0; y<src->height-1; y++)
|
||||
{
|
||||
for (x=0; x<src->width-1; x++)
|
||||
{
|
||||
for (y=0; y<src->height-1; y++) {
|
||||
for (x=0; x<src->width-1; x++) {
|
||||
tir = tig = tib = 0;
|
||||
for (foo=0; foo<4; foo++)
|
||||
{
|
||||
for (foo=0; foo<4; foo++) {
|
||||
tir += (src->Rpix[y+dy[foo]])[x+dx[foo]];
|
||||
tig += (src->Gpix[y+dy[foo]])[x+dx[foo]];
|
||||
tib += (src->Bpix[y+dy[foo]])[x+dx[foo]];
|
||||
@@ -189,21 +174,17 @@ return OLL_KORRECT;
|
||||
/*
|
||||
* 8 Feb 2001: another kludge (without doc)
|
||||
*/
|
||||
int
|
||||
Image_2x2_rot4pix(Image_Desc *src, Image_Desc *dst, int rot)
|
||||
int Image_2x2_rot4pix(Image_Desc *src, Image_Desc *dst, int rot)
|
||||
{
|
||||
int x, y, foo, bar, r, g, b;
|
||||
|
||||
int dx[4] = { 0, 1, 0, 1 };
|
||||
int dy[4] = { 0, 0, 1, 1 };
|
||||
|
||||
for (y=0; y<src->height-1; y+=2)
|
||||
{
|
||||
for (x=0; x<src->width-1; x+=2)
|
||||
{
|
||||
for (foo=0; foo<4; foo++)
|
||||
{
|
||||
bar = (foo+rot)%4;
|
||||
for (y=0; y<src->height-1; y+=2) {
|
||||
for (x=0; x<src->width-1; x+=2) {
|
||||
for (foo=0; foo<4; foo++) {
|
||||
bar = (foo+rot)%4; /* XXX ? */
|
||||
r = (src->Rpix[y+dy[foo]])[x+dx[foo]];
|
||||
g = (src->Gpix[y+dy[foo]])[x+dx[foo]];
|
||||
b = (src->Bpix[y+dy[foo]])[x+dx[foo]];
|
||||
@@ -217,25 +198,4 @@ for (y=0; y<src->height-1; y+=2)
|
||||
return FUNC_IS_BETA;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int Image_2x2_shiftUL(Image_Desc *src, Image_Desc *dst)
|
||||
{
|
||||
int foo;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, "this func (%s) is a kluge\n", __func__);
|
||||
#endif
|
||||
|
||||
if ( (foo=Image_compare_desc(src, dst)) )
|
||||
{
|
||||
return foo;
|
||||
}
|
||||
|
||||
/* 1er septembre 2008: je n'ai pas la moindre idee de ce que j'ai
|
||||
* voulu faire ici :) */
|
||||
|
||||
/* 26 novembre 2009: j'arrive pas a me rappeler du pourquoi de
|
||||
* ce que doit faire cette fonction */
|
||||
|
||||
return FULL_NUCKED;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
|
||||
100
Lib/operat.c
100
Lib/operat.c
@@ -5,8 +5,8 @@
|
||||
25 Aout 1999: certaines fonctions utilisent 'alloca'.
|
||||
|
||||
4 Fevrier 2001: je me rend compte que certaines interfaces sont trop
|
||||
simplistes, et que définir des structures contenant de multiples
|
||||
paramètres ne serait peut-être pas une mauvaise idée...
|
||||
simplistes, et que definir des structures contenant de multiples
|
||||
parametres ne serait peut-etre pas une mauvaise idee...
|
||||
|
||||
16 Oct 2001: je deplace quelques fonctions dans d'autres modules.
|
||||
|
||||
@@ -26,8 +26,7 @@
|
||||
/*
|
||||
* XXX il y a un "Zero Divide" cache dans cette fonction !
|
||||
*/
|
||||
int
|
||||
Image_adjust_minmax_0(Image_Desc *src, Image_Desc *dst, int yo,
|
||||
int Image_adjust_minmax_0(Image_Desc *src, Image_Desc *dst, int yo,
|
||||
int minstone, int maxstone)
|
||||
{
|
||||
long histR[256], histG[256], histB[256];
|
||||
@@ -36,8 +35,7 @@ int foo;
|
||||
long mini, maxi, kmini, kmaxi, delta;
|
||||
int idxmini, idxmaxi, val, lut[256], level;
|
||||
|
||||
if (yo != 0)
|
||||
{
|
||||
if (yo != 0) {
|
||||
fprintf(stderr, "Yo is %d\n", yo);
|
||||
}
|
||||
|
||||
@@ -58,11 +56,9 @@ fprintf(stderr, " K maxi = %ld\n", kmaxi);
|
||||
|
||||
mini = 0;
|
||||
idxmini = 0;
|
||||
for (foo=0; foo<256; foo++)
|
||||
{
|
||||
for (foo=0; foo<256; foo++) {
|
||||
mini += (histR[foo] + histG[foo] + histB[foo]);
|
||||
if (mini > kmini)
|
||||
{
|
||||
if (mini > kmini) {
|
||||
fprintf(stderr, "MINI %3d %ld\n", foo, mini);
|
||||
idxmini = foo;
|
||||
break;
|
||||
@@ -71,11 +67,9 @@ for (foo=0; foo<256; foo++)
|
||||
|
||||
maxi = 0;
|
||||
idxmaxi = 255;
|
||||
for (foo=255; foo>=0; foo--)
|
||||
{
|
||||
for (foo=255; foo>=0; foo--) {
|
||||
maxi += (histR[foo] + histG[foo] + histB[foo]);
|
||||
if (maxi > kmaxi)
|
||||
{
|
||||
if (maxi > kmaxi) {
|
||||
fprintf(stderr, "MAXI %3d %ld\n", foo, maxi);
|
||||
idxmaxi = foo;
|
||||
break;
|
||||
@@ -87,8 +81,7 @@ fprintf(stderr, "idxmini=%d idxmaxi=%d delta=%ld\n", idxmini, idxmaxi, delta);
|
||||
|
||||
for (foo=0; foo<idxmini; foo++) lut[foo] = 0;
|
||||
level = 0;
|
||||
for (foo=idxmini; foo<=idxmaxi; foo++)
|
||||
{
|
||||
for (foo=idxmini; foo<=idxmaxi; foo++) {
|
||||
val = (level*255) / delta;
|
||||
lut[foo] = val;
|
||||
level++;
|
||||
@@ -110,27 +103,23 @@ return FUNC_IS_BETA;
|
||||
* et une fonction de plus ecrite a la rache, avec un nom qui
|
||||
* ne veut probablement rien dire :)
|
||||
*/
|
||||
int
|
||||
Image_luminance(Image_Desc *src, Image_Desc *dst, int factor)
|
||||
int Image_luminance(Image_Desc *src, Image_Desc *dst, int factor)
|
||||
{
|
||||
int foo;
|
||||
int x, y;
|
||||
|
||||
#if DEBUG_LEVEL > 1
|
||||
fprintf(stderr, "%s ( %p %p %d )\n", __func__, src, dst, factor);
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, dst, factor);
|
||||
fprintf(stderr, "luminance factor: %d %f\n", factor, (float)factor / 256.0);
|
||||
#endif
|
||||
|
||||
fprintf(stderr, "luminance factor: %d %f\n", factor, (float)factor / 256.0);
|
||||
|
||||
if ( (foo=Image_compare_desc(src, dst)) ) {
|
||||
fprintf(stderr, "Image Luminance: images are differents %d\n", foo);
|
||||
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
for (y=0; y<src->height; y++)
|
||||
{
|
||||
for (x=0; x<src->width; x++)
|
||||
{
|
||||
for (y=0; y<src->height; y++) {
|
||||
for (x=0; x<src->width; x++) {
|
||||
dst->Rpix[y][x] = (src->Rpix[y][x] * factor) / 256;
|
||||
dst->Gpix[y][x] = (src->Gpix[y][x] * factor) / 256;
|
||||
dst->Bpix[y][x] = (src->Bpix[y][x] * factor) / 256;
|
||||
@@ -143,7 +132,7 @@ return FUNC_IS_BETA;
|
||||
}
|
||||
/*
|
||||
* p'taing, c'est tellement crade qu'il faut:
|
||||
* 1) retrouver d'ou ça vient
|
||||
* 1) retrouver d'ou c,a vient
|
||||
* 2) la virer illico !...
|
||||
*/
|
||||
/*::------------------------------------------------------------------::*/
|
||||
@@ -156,8 +145,7 @@ return FUNC_IS_BETA;
|
||||
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
|
||||
le parametre 'yoyo' n'est pas utilise actuellement.
|
||||
*/
|
||||
int
|
||||
Image_egalise_RGB(Image_Desc *src, Image_Desc *dst, int yoyo)
|
||||
int Image_egalise_RGB(Image_Desc *src, Image_Desc *dst, int yoyo)
|
||||
{
|
||||
int foo;
|
||||
long *histr, *histg, *histb;
|
||||
@@ -165,11 +153,11 @@ int *cumlr, *cumlg, *cumlb;
|
||||
long cr, cg, cb, s;
|
||||
|
||||
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)) ) {
|
||||
fprintf(stderr, "Image Egalise RGB: images are differents %d\n", foo);
|
||||
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
@@ -189,7 +177,7 @@ cr = cg = cb = 0L;
|
||||
s = (src->width * src->height);
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, "Image Egalise 0: surface = %ld\n", s);
|
||||
fprintf(stderr, "%s: surface = %ld\n", __func__, s);
|
||||
#endif
|
||||
|
||||
for (foo=0; foo<256; foo++) {
|
||||
@@ -201,8 +189,7 @@ for (foo=0; foo<256; foo++) {
|
||||
#if DEBUG_LEVEL > 1
|
||||
fprintf(stderr, "* histo RGB: cumuls: %d %d %d surface: %ld\n",
|
||||
cumlr[255], cumlg[255], cumlb[255], s);
|
||||
for (foo=0; foo<256; foo++)
|
||||
{
|
||||
for (foo=0; foo<256; foo++) {
|
||||
fprintf(stderr, "%3d | %7ld %7ld %7ld | %7d %7d %7d\n",
|
||||
foo,
|
||||
histr[foo], histg[foo], histb[foo],
|
||||
@@ -223,17 +210,15 @@ return 0;
|
||||
|
||||
le parametre 'yoyo' n'est pas utilise actuellement.
|
||||
*/
|
||||
int
|
||||
Image_egalise_mono_0(Image_Desc *src, Image_Desc *dst, int yoyo)
|
||||
int Image_egalise_mono_0(Image_Desc *src, Image_Desc *dst, int yoyo)
|
||||
{
|
||||
int foo;
|
||||
long c, cc, s3;
|
||||
long *histr, *histg, *histb;
|
||||
int cumul[256];
|
||||
|
||||
if ( (foo=Image_compare_desc(src, dst)) )
|
||||
{
|
||||
fprintf(stderr, "Image_Egalise_Mono_0: images are differents %d\n", foo);
|
||||
if ( (foo=Image_compare_desc(src, dst)) ) {
|
||||
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
@@ -252,8 +237,7 @@ Image_histo_RGB(src, histr, histg, histb);
|
||||
s3 = (3 * src->width * src->height);
|
||||
|
||||
cc = 0L;
|
||||
for (foo=0; foo<256; foo++)
|
||||
{
|
||||
for (foo=0; foo<256; foo++) {
|
||||
c = histr[foo] + histg[foo] + histb[foo];
|
||||
cc += c;
|
||||
cumul[foo] = (int)((cc*255) / s3);
|
||||
@@ -268,17 +252,13 @@ return 0;
|
||||
complement d'une image complete (c.a.d tous
|
||||
les canaux contenus dans cette image)
|
||||
*/
|
||||
int
|
||||
Image_negate(Image_Desc *image, Image_Desc *resultat)
|
||||
int Image_negate(Image_Desc *image, Image_Desc *resultat)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
if (image->type == 3)
|
||||
{
|
||||
for (y=0; y<image->height; y++)
|
||||
{
|
||||
for (x=0; x<image->width; x++)
|
||||
{
|
||||
if (image->type == 3) {
|
||||
for (y=0; y<image->height; y++) {
|
||||
for (x=0; x<image->width; x++) {
|
||||
resultat->Rpix[y][x] = image->Rpix[y][x] ^ 0xff;
|
||||
resultat->Gpix[y][x] = image->Gpix[y][x] ^ 0xff;
|
||||
resultat->Bpix[y][x] = image->Bpix[y][x] ^ 0xff;
|
||||
@@ -287,8 +267,9 @@ if (image->type == 3)
|
||||
return 0;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Image Negate: unknow image type %d, %s\n",
|
||||
image->type, Image_type2str(image->type));
|
||||
fprintf(stderr, "%s: unknow image type %d, %s\n",
|
||||
__func__, image->type, Image_type2str(image->type));
|
||||
|
||||
return IMAGE_BAD_TYPE;
|
||||
}
|
||||
|
||||
@@ -568,27 +549,22 @@ return retval;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
|
||||
int
|
||||
Image_seuil_RGB(Image_Desc *s, Image_Desc *d, int r, int g, int b)
|
||||
int Image_seuil_RGB(Image_Desc *s, Image_Desc *d, int r, int g, int b)
|
||||
{
|
||||
int foo, x, y;
|
||||
|
||||
if ( (s->type != 3) || (d->type != 3) )
|
||||
{
|
||||
if ( (s->type != 3) || (d->type != 3) ) {
|
||||
fprintf(stderr, "Image Seuil RGB: an image is not of type 3\n");
|
||||
return IMAGE_BAD_TYPE;
|
||||
}
|
||||
|
||||
if ( (foo=Image_compare_desc(s, d)) != 0 )
|
||||
{
|
||||
if ( (foo=Image_compare_desc(s, d)) != 0 ) {
|
||||
fprintf(stderr, "Image Seuil RGB: images are differents %d\n", foo);
|
||||
return foo;
|
||||
}
|
||||
|
||||
for (y=0; y<s->height; y++)
|
||||
{
|
||||
for (x=0; x<s->width; x++)
|
||||
{
|
||||
for (y=0; y<s->height; y++) {
|
||||
for (x=0; x<s->width; x++) {
|
||||
if(s->Rpix[y][x] > r) d->Rpix[y][x] = 255;
|
||||
else d->Rpix[y][x] = 0;
|
||||
if(s->Gpix[y][x] > g) d->Gpix[y][x] = 255;
|
||||
|
||||
@@ -18,12 +18,14 @@
|
||||
* Les colors maps sont censees etre compatible avec celles
|
||||
* de FRACTINT, mais il faudrait verifier.
|
||||
*/
|
||||
int
|
||||
Image_save_color_Map(char *file, char *name, RGB_map *map)
|
||||
int Image_save_color_Map(char *file, char *name, RGB_map *map)
|
||||
{
|
||||
int foo;
|
||||
FILE *fp;
|
||||
|
||||
fprintf(stderr, ">>> %s ( '%s' '%s' %p )\n", __func__,
|
||||
file, name, map);
|
||||
|
||||
if ( (fp=fopen(file, "w")) == NULL ) {
|
||||
fprintf(stderr, "Save Color Map: err fopen\n");
|
||||
return FILE_CREATE_ERR;
|
||||
@@ -74,22 +76,26 @@ return OLL_KORRECT;
|
||||
* What is the 'right thing' to do when we get more than
|
||||
* 256 lines of data ? return an error ?
|
||||
*/
|
||||
int
|
||||
Image_load_color_Map(char *file, char *name, RGB_map *where)
|
||||
int Image_load_color_Map(char *file, char *name, RGB_map *where)
|
||||
{
|
||||
FILE *fp;
|
||||
int nbre, r, g, b, foo, errcode;
|
||||
char buffer[256];
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, ">>> %s ( '%s' '%s' %p )\n", __func__,
|
||||
file, name, where);
|
||||
#endif
|
||||
|
||||
if ( name != NULL ) {
|
||||
if (strlen(name)>IMG_OBJNAME_LEN) return STRING_TOO_LONG;
|
||||
strcpy(where->name, name);
|
||||
}
|
||||
else strcpy(where->name, "no name");
|
||||
else strcpy(where->name, "<noname>");
|
||||
|
||||
/*
|
||||
* patch du 11 Décembre 2001: on utilise une fonction qui recherche le
|
||||
* fichier dans differents endroits. Cf 'mustopen.c' pour + de détails.
|
||||
* patch du 11 Decembre 2001: on utilise une fonction qui recherche le
|
||||
* fichier dans differents endroits. Cf 'mustopen.c' pour + de details.
|
||||
*/
|
||||
if ((fp=Image_must_fopen(file, "r", 0)) == NULL) {
|
||||
/* safety poke */
|
||||
@@ -128,13 +134,12 @@ return errcode;
|
||||
*
|
||||
* XXX voir aussi indexcol.x XXX
|
||||
*/
|
||||
int
|
||||
Image_attach_Map(Image_Desc *im, char *nom_map, int flags)
|
||||
int Image_attach_Map(Image_Desc *im, char *nom_map, int flags)
|
||||
{
|
||||
RGB_map map;
|
||||
int foo;
|
||||
|
||||
fprintf(stderr, "Image attach Map: cette fonction n'est pas finie\n");
|
||||
fprintf(stderr, "%s: cette fonction n'est pas finie\n", __func__);
|
||||
foo = Image_load_color_Map(nom_map, "", &map);
|
||||
if (foo == 0) {
|
||||
fprintf(stderr, "Attach Map: foo is zero ?\n");
|
||||
@@ -145,8 +150,7 @@ return FUNC_NOT_FINISH;
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/* new 31 Juillet 2000 */
|
||||
|
||||
int
|
||||
Image_make_random_Map(char *nom, RGB_map *map, int nbre)
|
||||
int Image_make_random_Map(char *nom, RGB_map *map, int nbre)
|
||||
{
|
||||
int foo;
|
||||
|
||||
@@ -170,8 +174,7 @@ return OLL_KORRECT;
|
||||
/* 21 Sept 2000
|
||||
Make a 2x2x2 color palette.
|
||||
*/
|
||||
int
|
||||
Image_make_222_Map(char *nom, RGB_map *map, int noise)
|
||||
int Image_make_222_Map(char *nom, RGB_map *map, int noise)
|
||||
{
|
||||
int foo, r, g, b;
|
||||
|
||||
@@ -200,13 +203,12 @@ return OLL_KORRECT;
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/* 15 Mai 2001
|
||||
* A big classic: the three-sinus color map.
|
||||
* paramètres:
|
||||
* parametres:
|
||||
* 0,1,2 R,G,B period
|
||||
* 3,4,5 R,G,B phase
|
||||
* 6,7 reserved
|
||||
*/
|
||||
int
|
||||
Image_palette_3sinus(char *nom, RGB_map *ou, double pars[8])
|
||||
int Image_palette_3sinus(char *nom, RGB_map *ou, double pars[8])
|
||||
{
|
||||
int foo;
|
||||
double dfoo, dra, dga, dba;
|
||||
@@ -235,8 +237,7 @@ return FUNC_IS_BETA;
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/* new 18 Dec 2001
|
||||
*/
|
||||
int
|
||||
Image_mix_palettes(RGB_map *p1, RGB_map *p2, RGB_map *d, char *txt, int k)
|
||||
int Image_mix_palettes(RGB_map *p1, RGB_map *p2, RGB_map *d, char *txt, int k)
|
||||
{
|
||||
int idx, k2;
|
||||
int r1, g1, b1, r2, g2, b2;
|
||||
@@ -248,8 +249,7 @@ fprintf(stderr, "Image mix palette: work in progress...\n");
|
||||
k2 = 10000 - k;
|
||||
|
||||
for (idx=0; idx<256; idx++) {
|
||||
if (idx < p1->nbre)
|
||||
{
|
||||
if (idx < p1->nbre) {
|
||||
r1 = p1->red[idx];
|
||||
g1 = p1->green[idx];
|
||||
b1 = p1->blue[idx];
|
||||
@@ -284,7 +284,7 @@ return FUNC_IS_BETA;
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/* new 01 aout 2008 */
|
||||
|
||||
/* XXX HACK XXX */
|
||||
/* XXX HACK XXX */ /* please explain ! */
|
||||
double round(double);
|
||||
/* XXX HACK XXX */
|
||||
|
||||
@@ -394,6 +394,6 @@ for (foo=0; foo<p->nbre; foo++) {
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return FULL_NUCKED;
|
||||
return FUNC_IS_BETA;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
|
||||
@@ -9,8 +9,7 @@
|
||||
#include "../tthimage.h"
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_pattern_000(Image_Desc *img, int foo)
|
||||
int Image_pattern_000(Image_Desc *img, int foo)
|
||||
{
|
||||
int x, y, xx, yy, r, g, b;
|
||||
|
||||
@@ -18,11 +17,9 @@ int x, y, xx, yy, r, g, b;
|
||||
fprintf(stderr, "%s : foo = %d\n", __func__, foo);
|
||||
#endif
|
||||
|
||||
for (x=0; x<img->width; x++)
|
||||
{
|
||||
for (x=0; x<img->width; x++) {
|
||||
xx = (x * 256) / img->width;
|
||||
for (y=0; y<img->height; y++)
|
||||
{
|
||||
for (y=0; y<img->height; y++) {
|
||||
yy = (y * 256) / img->height;
|
||||
r = xx & yy & foo;
|
||||
g = ((xx * yy) & 0xf8 );
|
||||
@@ -37,8 +34,7 @@ for (x=0; x<img->width; x++)
|
||||
return FUNC_IS_BETA;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_pattern_001(Image_Desc *img, int foo)
|
||||
int Image_pattern_001(Image_Desc *img, int foo)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
@@ -50,11 +46,10 @@ for (x=0; x<img->width; x++)
|
||||
for (y=0; y<img->height; y++)
|
||||
Image_plotRGB(img, x, y, x^y^foo, (x*y)>>4, x&y);
|
||||
|
||||
return FUNC_NOT_FINISH;
|
||||
return FUNC_IS_BETA;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_pattern_002(Image_Desc *img, int foo)
|
||||
int Image_pattern_002(Image_Desc *img, int foo)
|
||||
{
|
||||
int x, y, x2, y2;
|
||||
|
||||
@@ -62,11 +57,9 @@ int x, y, x2, y2;
|
||||
fprintf(stderr, "Pattern 002: %d\n", foo);
|
||||
#endif
|
||||
|
||||
for (x=0; x<img->width; x++)
|
||||
{
|
||||
for (x=0; x<img->width; x++) {
|
||||
x2 = (x * 256) / img->width;
|
||||
for (y=0; y<img->height; y++)
|
||||
{
|
||||
for (y=0; y<img->height; y++) {
|
||||
y2 = (y * 256) / img->height;
|
||||
Image_plotRGB(img, x, y, (x2/2)&(y2/2)&foo, (x2*y2)>>3, x2^y2);
|
||||
}
|
||||
@@ -75,8 +68,7 @@ for (x=0; x<img->width; x++)
|
||||
return FUNC_IS_BETA;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_pattern_003(Image_Desc *img, int foo)
|
||||
int Image_pattern_003(Image_Desc *img, int foo)
|
||||
{
|
||||
int x, x2, y, y2;
|
||||
|
||||
@@ -85,11 +77,9 @@ fprintf(stderr, "Pattern 003: foo is %d\n", foo);
|
||||
#endif
|
||||
|
||||
/* added some ugly code the 28 february 2008 */
|
||||
for (x=0; x<img->width; x++)
|
||||
{
|
||||
for (x=0; x<img->width; x++) {
|
||||
x2 = (x * 256) / img->width;
|
||||
for (y=0; y<img->height; y++)
|
||||
{
|
||||
for (y=0; y<img->height; y++) {
|
||||
y2 = (y * 256) / img->height;
|
||||
Image_plotRGB(img, x, y, (x2/4)&(y2/4)&foo, (x2*y2)>>5, x2^y2);
|
||||
}
|
||||
@@ -98,8 +88,7 @@ for (x=0; x<img->width; x++)
|
||||
return FUNC_NOT_FINISH;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_pattern_004(Image_Desc *img, int a, int b, int c, int d)
|
||||
int Image_pattern_004(Image_Desc *img, int a, int b, int c, int d)
|
||||
{
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, "Pattern 004: %d, %d, %d, %d\n", a, b, c, d);
|
||||
@@ -122,11 +111,9 @@ if (NULL == map) {
|
||||
return NULL_POINTER;
|
||||
}
|
||||
|
||||
for (y=0; y<img->height; y++)
|
||||
{
|
||||
for (y=0; y<img->height; y++) {
|
||||
fy = (double)y;
|
||||
for (x=0; x<img->width; x++)
|
||||
{
|
||||
for (x=0; x<img->width; x++) {
|
||||
fx = (double)x;
|
||||
|
||||
idx = (int)(127.0+(sin(fx)*cos(fy)*254.99));
|
||||
@@ -140,8 +127,7 @@ for (y=0; y<img->height; y++)
|
||||
return FUNC_NOT_FINISH;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_pattern_042(Image_Desc *img, int foo)
|
||||
int Image_pattern_042(Image_Desc *img, int foo)
|
||||
{
|
||||
int x, y, r, g, b;
|
||||
|
||||
@@ -150,10 +136,8 @@ fprintf(stderr, "Pattern 042: threshold level is %d\n", foo);
|
||||
#endif
|
||||
|
||||
r = g = b = 42;
|
||||
for (x=0; x<img->width; x++)
|
||||
{
|
||||
for (y=0; y<img->height; y++)
|
||||
{
|
||||
for (x=0; x<img->width; x++) {
|
||||
for (y=0; y<img->height; y++) {
|
||||
r += rand() % 4;
|
||||
if (r > foo) r = 0;
|
||||
|
||||
|
||||
@@ -16,15 +16,15 @@
|
||||
/*
|
||||
* c'est quasiment impossible de documenter cette fonction.
|
||||
*/
|
||||
int
|
||||
Image_pattern_100(Image_Desc *dst, int kr, int kg, int kb)
|
||||
int Image_pattern_100(Image_Desc *dst, int kr, int kg, int kb)
|
||||
{
|
||||
int x, y, r,g, b;
|
||||
|
||||
for (x=0; x<dst->width; x++)
|
||||
{
|
||||
for (y=0; y<dst->height; y++)
|
||||
{
|
||||
fprintf(stderr, ">>> %s ( %p %d %d %d )\n", __func__,
|
||||
dst, kr, kg, kb);
|
||||
|
||||
for (x=0; x<dst->width; x++) {
|
||||
for (y=0; y<dst->height; y++) {
|
||||
r = abs(x+y-(dst->width/3)) * kr;
|
||||
g = abs(x-y-(dst->height/3)) * kg;
|
||||
b = (rand() % 42) + kb;
|
||||
@@ -36,19 +36,19 @@ for (x=0; x<dst->width; x++)
|
||||
return FUNC_IS_BETA;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_pattern_101(Image_Desc *dst, int kr, int kg, int kb)
|
||||
int Image_pattern_101(Image_Desc *dst, int kr, int kg, int kb)
|
||||
{
|
||||
int x, y, r,g, b;
|
||||
|
||||
fprintf(stderr, ">>> %s ( %p %d %d %d )\n", __func__,
|
||||
dst, kr, kg, kb);
|
||||
|
||||
if (kr == 0) kr = 1;
|
||||
if (kg == 0) kg = 1;
|
||||
if (kb == 0) kb = 1;
|
||||
|
||||
for (x=0; x<dst->width; x++)
|
||||
{
|
||||
for (y=0; y<dst->height; y++)
|
||||
{
|
||||
for (x=0; x<dst->width; x++) {
|
||||
for (y=0; y<dst->height; y++) {
|
||||
if (x < dst->width/2)
|
||||
{ r=x/kr; g=y/kg; b=x/kb; }
|
||||
else
|
||||
@@ -59,18 +59,15 @@ for (x=0; x<dst->width; x++)
|
||||
return FUNC_IS_BETA;
|
||||
}
|
||||
/*::------------------------------------------------------------------::*/
|
||||
int
|
||||
Image_pattern_102(Image_Desc *dst, int param, int kr, int kg, int kb)
|
||||
int Image_pattern_102(Image_Desc *dst, int param, int kr, int kg, int kb)
|
||||
{
|
||||
int x, y, r,g, b;
|
||||
|
||||
for (x=0; x<dst->width; x++)
|
||||
{
|
||||
for (y=0; y<dst->height; y++)
|
||||
{
|
||||
for (x=0; x<dst->width; x++) {
|
||||
for (y=0; y<dst->height; y++) {
|
||||
r = x ^ kr;
|
||||
g = y ^ kg;
|
||||
b = (x+y) ^ kb;
|
||||
b = (x+y+param) ^ kb;
|
||||
Image_plotRGB(dst, x, y, r, g, b);
|
||||
}
|
||||
}
|
||||
@@ -80,26 +77,20 @@ return FUNC_NOT_FINISH;
|
||||
/*::------------------------------------------------------------------::*/
|
||||
/* hop, 31 mars 2008, une petite evolution stochastique de base...
|
||||
* */
|
||||
int
|
||||
Image_pattern_103(Image_Desc *dst, int param, int kr, int kg, int kb)
|
||||
int Image_pattern_103(Image_Desc *dst, int param, int kr, int kg, int kb)
|
||||
{
|
||||
int x, y, r, g, b;
|
||||
long surface;
|
||||
double dx, dy;
|
||||
|
||||
#if DEBUG_LEVEL
|
||||
fprintf(stderr, "%s: acting on image %p\n", __func__, dst);
|
||||
#endif
|
||||
|
||||
surface = dst->width * dst->height;
|
||||
|
||||
for (x=0; x<dst->width; x++)
|
||||
{
|
||||
for (x=0; x<dst->width; x++) {
|
||||
dx = (double)x / (double)dst->width;
|
||||
for (y=0; y<dst->height; y++)
|
||||
{
|
||||
for (y=0; y<dst->height; y++) {
|
||||
dy = (double)x / (double)dst->height;
|
||||
r = (int)round(256.0 * sqrt(dx * dy)); /* XXX */
|
||||
r = (int)(256.0 * sqrt(dx * dy)); /* XXX */
|
||||
g = b = rand() & 0xf0;
|
||||
Image_plotRGB(dst, x, y, r, g, b);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,12 @@ int x, y, v, delta;
|
||||
|
||||
delta = high - low;
|
||||
|
||||
if (0 == delta) {
|
||||
fprintf(stderr, "%s: bad low/high parameters %d %d <- delta is 0\n",
|
||||
__func__, low, high);
|
||||
return DIVISOR_IS_ZERO;
|
||||
}
|
||||
|
||||
for (x=0; x<dst->width; x++)
|
||||
{
|
||||
for (y=0; y<dst->height; y++)
|
||||
@@ -44,6 +50,12 @@ int x, y, r, g, b, delta;
|
||||
|
||||
delta = high - low;
|
||||
|
||||
if (0 == delta) {
|
||||
fprintf(stderr, "%s: bad low/high parameters %d %d <- delta is 0\n",
|
||||
__func__, low, high);
|
||||
return DIVISOR_IS_ZERO;
|
||||
}
|
||||
|
||||
for (x=0; x<dst->width; x++)
|
||||
{
|
||||
for (y=0; y<dst->height; y++)
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#define DEBUG_LEVEL 1
|
||||
#endif
|
||||
|
||||
#include "tthimage.h"
|
||||
#include "../tthimage.h"
|
||||
|
||||
/*::------------------------------------------------------------------::*/
|
||||
#define LIBPCX_VERSION "0.0.12"
|
||||
|
||||
@@ -52,8 +52,7 @@ return FUNC_IS_BETA;
|
||||
/*
|
||||
* fonction d'appel de test
|
||||
*/
|
||||
int
|
||||
Image_pixeliz_X(Image_Desc *src, Image_Desc *dst)
|
||||
int Image_pixeliz_X(Image_Desc *src, Image_Desc *dst)
|
||||
{
|
||||
int foo;
|
||||
|
||||
@@ -73,8 +72,7 @@ return foo;
|
||||
/*
|
||||
* fonction d'appel de test
|
||||
*/
|
||||
int
|
||||
Image_pixeliz_Y(Image_Desc *src, Image_Desc *dst)
|
||||
int Image_pixeliz_Y(Image_Desc *src, Image_Desc *dst)
|
||||
{
|
||||
int foo;
|
||||
|
||||
|
||||
@@ -27,6 +27,8 @@ return FULL_NUCKED;
|
||||
int Image_rot_pixel(Image_Desc *img, int x, int y, int r, int g, int b)
|
||||
{
|
||||
|
||||
fprintf(stderr, "%s is wtf\n", __func__);
|
||||
|
||||
if ( (x<0) || (y<0) || (x>=img->width) || (y>=img->height) )
|
||||
{
|
||||
fprintf(stderr, "%s : out of pic (%d, %d)\n", __func__, x, y);
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user