Compare commits

..

92 Commits

Author SHA1 Message Date
tTh
58b8fa878c add new ugly tools 2024-11-17 10:44:07 +01:00
tTh
d298f63e7e add 2 missing tools 2024-11-15 17:47:09 +01:00
tTh
0b8cf14126 add missing binaries 2024-11-15 16:45:52 +01:00
tTh
b3da0e6ec0 cosmetic 2024-11-15 11:35:39 +01:00
tTh
97ad716bd2 little work on documentation 2024-11-14 10:11:11 +01:00
tTh
ae54fb932a + Test_Classif 2024-08-16 18:13:36 +02:00
tTh
5418e01820 cosmetic 2024-08-16 13:30:19 +02:00
tTh
24b3d4de11 tweaking... 2024-08-16 13:10:58 +02:00
tTh
5ffc94c17d more blabla 2024-08-16 13:09:18 +02:00
tTh
6fddb97ee4 re-enable tga_info 2024-08-16 13:06:51 +02:00
tTh
725ccf3c87 tweaking the speedtest 2024-08-16 03:22:55 +02:00
tTh
f4c3825186 nice fail, bro 2024-08-15 20:40:01 +02:00
tTh
d6877097d0 + rgb decomp 2024-08-15 15:18:10 +02:00
tTh
8c30ea844f add warning 2024-08-15 14:18:47 +02:00
tTh
82a7050d07 public version of crazy benchmarking 2024-08-15 13:43:12 +02:00
tTh
1b442ece82 add patterns files 2024-08-15 13:39:00 +02:00
tTh
1750225cf9 enable optimize 2024-08-15 13:36:35 +02:00
tTh
8a163578ad added "tthi_dtime" profiling helper 2024-08-15 12:08:37 +02:00
tTh
a01eebd240 explain Contribs 2024-08-15 11:33:51 +02:00
tTh
65f396bedd small tweaking 2024-08-15 11:20:58 +02:00
tTh
402c80962a filter profiling garbage 2024-08-15 11:18:22 +02:00
tTh
3a3311647b disrupter le désordre 2024-08-15 11:17:35 +02:00
tTh
d6632ade7e cleaning 2024-08-12 12:32:58 +02:00
tTh
38173616ba sunday cosmetic commit 2024-08-11 11:21:23 +02:00
tTh
ce04418ef1 working on big test proggy 2024-08-11 11:20:04 +02:00
tTh
e2b830b537 compute and display the call tree 2024-08-11 10:32:10 +02:00
tTh
1762a35868 cosmetic 2024-08-10 17:49:57 +02:00
tTh
acb36a45b3 add televisions tests 2024-08-10 17:48:52 +02:00
tTh
4a3f107263 marging bug fixed in TV_pix_0 function 2024-08-10 17:48:08 +02:00
tTh
cd5f42b76e oups! sorry... 2024-08-10 16:06:55 +02:00
tTh
0b094bf7b8 cosmetic 2024-08-10 14:56:50 +02:00
tTh
7e09d1b490 error handling + cosmetic 2024-07-31 22:24:32 +02:00
tTh
5b2320b421 more doc 2024-07-31 22:21:54 +02:00
tTh
e3347cb775 directory marker 2024-07-21 01:08:15 +02:00
tTh
ee6a416f9e testing quadtree recurse 2024-07-21 01:06:37 +02:00
tTh
43368bf900 remove an obsolete function 2024-07-20 12:01:12 +02:00
tTh
4f41ae399b kill warning, better return value 2024-07-18 08:57:50 +02:00
tTh
7aab0e030a add molly-guard message 2024-07-18 08:56:48 +02:00
tTh
e841207907 remove useless msg 2024-07-18 08:55:57 +02:00
tTh
53a108561f one more... 2024-07-17 02:39:21 +02:00
tTh
8d36957956 cleanup 2024-07-17 00:47:19 +02:00
tTh
b367f42b9e cosmetic 2024-07-16 19:07:37 +02:00
tTh
b264cffb02 hide trace msg 2024-07-16 19:01:12 +02:00
tTh
449705c0ee check error on header read 2024-07-16 18:58:11 +02:00
tTh
d9d2db45b0 add cos010 to tga_equalize 2024-04-09 22:20:46 +02:00
tTh
96ddcfccaf cosmetic 2024-04-09 08:36:33 +02:00
tTh
ff4b7acff8 clean before use 2024-04-08 05:35:19 +02:00
tTh
dda374fc7d oups... 2024-04-07 12:50:57 +02:00
tTh
0c17de9f93 porno canal+ 2024-04-01 18:26:46 +02:00
tTh
b9102e2991 is tga_to_text working ? 2024-02-27 03:32:41 +01:00
tTh
298643ede5 tga to text, version 0 2024-02-27 00:43:44 +01:00
tTh
86cb7eaa4a wip wip wip wip 2023-11-18 19:58:21 +01:00
tTh
2246a5d744 wip wip wip 2023-11-18 19:56:25 +01:00
tTh
56941f1215 breakin a srand usage 2023-11-14 13:09:27 +01:00
tTh
39903d1067 removing garbage 2023-11-14 13:07:06 +01:00
tTh
a67809b4e8 experiment on falsecolors 2023-11-14 13:06:02 +01:00
tTh
378a1046a0 add a func for testing paint_rec 2023-11-14 13:04:56 +01:00
tTh
4ab69cced3 better help message 2023-10-12 12:34:28 +02:00
tTh
9ca6acd176 add 3 fractint maps 2023-10-12 11:20:30 +02:00
tTh
8fae30abc7 cosmetic 2023-10-11 22:36:16 +02:00
tTh
54e6a7e58a ok blz 2023-10-11 22:26:07 +02:00
tTh
32fc223f2c add a new struct, kill old funcs 2023-10-06 19:47:49 +02:00
tTh
6744a631c1 remove useless file 2023-10-05 21:54:49 +02:00
tTh
cced0a8811 use default if not provided by caller 2023-10-02 18:26:11 +02:00
tTh
56250127bc merged two files 2023-09-30 03:01:07 +02:00
tTh
2594cabf94 more clean 2023-09-28 23:50:23 +02:00
tTh
21de0960e8 reuse an old func 2023-09-26 11:17:04 +02:00
tTh
d09291bd4e added a (slow) function 2023-09-25 13:28:13 +02:00
tTh
7b0384a3b7 Image_print_version now go to stderr 2023-09-23 20:00:14 +02:00
tTh
ba7ba3d666 working on patterns 2023-09-22 14:20:26 +02:00
tTh
806c9b0071 a few cleanup + new patterns 2023-09-22 14:15:52 +02:00
tTh
7b10854729 add a zerodivide mollyguard 2023-09-18 15:29:40 +02:00
tTh
226d1b39a9 bla... 2023-09-18 09:50:37 +02:00
tTh
3f1f5fc49b cosmetic 2023-09-18 09:09:13 +02:00
tTh
5f61f21362 remove unsuded vars 2023-09-18 09:08:01 +02:00
tTh
7977766a52 cosmetic 2023-09-18 08:50:48 +02:00
tTh
907f538cff add a gradient generator 2023-09-18 08:46:13 +02:00
tTh
42fafdc570 cosmetic 2023-09-18 08:27:49 +02:00
tTh
395b262c92 add "cos01" contrast adjustement 2023-09-17 22:36:08 +02:00
tTh
bef1c6c5e3 add tga_extract 2023-09-12 18:19:12 +02:00
tTh
d260117865 more cleanup... 2023-01-31 00:21:05 +01:00
tTh
ca0acf0c26 shootgun debug 2022-12-29 14:17:22 +01:00
tTh
15124ad892 to be finished, please 2022-12-26 05:50:19 +01:00
tTh
00e796bf5e shootgun debug session #539 2022-12-19 13:54:39 +01:00
tTh
c1c954100e a big Oups ! 2022-11-29 12:52:18 +01:00
tTh
35e5947fdb you can now set the image size in genplot2 2022-11-26 11:39:22 +01:00
tTh
5f80203592 wip 2022-11-26 11:13:34 +01:00
tTh
d5d9aa8c43 change a default 2022-11-08 01:39:58 +01:00
tTh
2c4612411b refactoring zoom code 2022-10-28 05:59:49 +02:00
tTh
f70037a143 essai_show_t16x24 2022-10-28 05:54:07 +02:00
tTh
4efe885d9a tweaking & cleaning 2022-10-28 05:53:07 +02:00
tTh
ca9947e7cc cosmetic 2022-10-28 05:07:32 +02:00
119 changed files with 3916 additions and 1428 deletions

1
.gitignore vendored
View File

@@ -3,6 +3,7 @@
libtthimage.a libtthimage.a
cscope.out cscope.out
gmon.out
Lib/foo Lib/foo
Lib/testtga Lib/testtga

16
Contribs/ExplodeVidz.md Normal file
View 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
View 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
View 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;
}
/* -------------------------------------------------------- */

View File

@@ -198,6 +198,31 @@
..************.. ..************..
..************.. ..************..
................ ................
55
................
..************..
..************..
................
.............**.
.............**.
.............**.
.............**.
.............**.
.............**.
................
................
................
................
.............**.
.............**.
.............**.
.............**.
.............**.
.............**.
................
................
................
................
56 56
................ ................
..************.. ..************..
@@ -223,6 +248,31 @@
..************.. ..************..
..************.. ..************..
................ ................
57
................
..************..
..************..
................
.**..........**.
.**..........**.
.**..........**.
.**..........**.
.**..........**.
.**..........**.
................
..************..
..************..
................
.............**.
.............**.
.............**.
.............**.
.............**.
.............**.
................
..************..
..************..
................
60 60
................ ................
................ ................

256
Datas/neon.map Normal file
View 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
View 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
View 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

View File

@@ -1,4 +1,4 @@
# libtthimage # libtthimage, la doc
Les fichiers [HTML](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. qui seront peut-être mise à jour au prochain grand refactoring.
@@ -13,11 +13,11 @@ Certaines options de compilation sont dans le fichier de
[paramètres](../Paramakes.mk) pour les différents fichiers make. [paramètres](../Paramakes.mk) pour les différents fichiers make.
Je vous conseille de vérifier leurs pertinences, et en particulier Je vous conseille de vérifier leurs pertinences, et en particulier
les options `-p` et `-pg` que j'oublie parfois d'enlever avant les options `-p` et `-pg` que j'oublie parfois d'enlever avant
le _/push_. le _push_.
Le script [build.sh](../build.sh) tente d'automatiser les Le script [build.sh](../build.sh) tente d'automatiser les
compilations de la bibilothèque, des tests et des outils compilations de la bibilothèque, des tests et des outils
en ligne de commande. en ligne de commande. Il est encore loin d'être parfait.
## Installation ## Installation
@@ -28,4 +28,4 @@ dans le fichier Paramakes.mk !
## Utilisation ## Utilisation
??? ??? *Insérez ici quelques exemples d'utilisation des tools.*

3
Lib/.gitignore vendored
View File

@@ -1,3 +1,6 @@
*.png *.png
*.gif
cflow.txt
reduce.map

View File

@@ -17,7 +17,7 @@ int foo, numbit, mask;
int failed; int failed;
#if DEBUG_LEVEL #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); img, xpos, ypos, bits, k);
#endif #endif
@@ -123,8 +123,8 @@ static int patterns[] =
/* 0 1 2 3 4 5 6 7 8 9 */ /* 0 1 2 3 4 5 6 7 8 9 */
int foo, idx, bits; int foo, idx, bits;
#if DEBEUG_LEVEL > 1 #if DEBUG_LEVEL > 1
fprintf(stderr, "%s digit 0x%2x sizeof(patterns) -> %d\n", __func__, fprintf(stderr, "%s: digit 0x%2x sizeof(patterns) -> %d\n", __func__,
chiffre, sizeof(patterns)); chiffre, sizeof(patterns));
#endif #endif
@@ -159,12 +159,12 @@ int foo;
char digit; char digit;
#if DEBUG_LEVEL > 1 #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 #endif
len = strlen(numstr); len = strlen(numstr);
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL > 1
fprintf(stderr, " len = %d\n", len); fprintf(stderr, " len = %d\n", len);
#endif #endif
for (idx=0; idx<len; idx++) for (idx=0; idx<len; idx++)
@@ -189,7 +189,7 @@ int foo, bar;
int iter; int iter;
#if DEBUG_LEVEL #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 #endif
iter = 0; /* safe value */ iter = 0; /* safe value */

View File

@@ -8,7 +8,7 @@ include ../Paramakes.mk
DEPS = ../tthimage.h ../Paramakes.mk Makefile 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) dither.o: dither.c $(DEPS)
dither2.o: dither2.c $(DEPS) dither2.o: dither2.c $(DEPS)
dither3.o: dither3.c $(DEPS) dither3.o: dither3.c $(DEPS)
dither4.o: dither4.c $(DEPS)
doublesz.o: doublesz.c $(DEPS) doublesz.o: doublesz.c $(DEPS)
drawalpha.o: drawalpha.c $(DEPS) drawalpha.o: drawalpha.c $(DEPS)
drawing.o: drawing.c $(DEPS) drawing.o: drawing.c $(DEPS)
@@ -64,9 +63,12 @@ extractbits.o: extractbits.c $(DEPS)
filtadapt.o: filtadapt.c $(DEPS) filtadapt.o: filtadapt.c $(DEPS)
filtres.o: filtres.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) gadgrect.o: gadgrect.c $(DEPS)
glitch.o: glitch.c $(DEPS) glitch.o: glitch.c $(DEPS)
gradient.o: gradient.c $(DEPS)
halfsize.o: halfsize.c $(DEPS) halfsize.o: halfsize.c $(DEPS)
@@ -109,6 +111,7 @@ ptlist.o: ptlist.c $(DEPS)
quadpics.o: quadpics.c $(DEPS) quadpics.o: quadpics.c $(DEPS)
readjpeg.o: readjpeg.c $(DEPS)
recurse.o: recurse.c $(DEPS) recurse.o: recurse.c $(DEPS)
rgbmask.o: rgbmask.c $(DEPS) rgbmask.o: rgbmask.c $(DEPS)
@@ -124,7 +127,6 @@ text1.o: text1.c $(DEPS)
text16x24.o: text16x24.c $(DEPS) text16x24.o: text16x24.c $(DEPS)
tga.o: tga.c $(DEPS) tga.o: tga.c $(DEPS)
tools.o: tools.c $(DEPS) tools.o: tools.c $(DEPS)
trigo.o: trigo.c $(DEPS)
turtle.o: turtle.c $(DEPS) turtle.o: turtle.c $(DEPS)
vignetize.o: vignetize.c $(DEPS) vignetize.o: vignetize.c $(DEPS)
@@ -132,7 +134,6 @@ vignetize.o: vignetize.c $(DEPS)
warp0.o: warp0.c $(DEPS) warp0.o: warp0.c $(DEPS)
warp1.o: warp1.c $(DEPS) warp1.o: warp1.c $(DEPS)
warp2.o: warp2.c $(DEPS) warp2.o: warp2.c $(DEPS)
warp3.o: warp3.c $(DEPS)
zoom.o: zoom.c $(DEPS) zoom.o: zoom.c $(DEPS)
@@ -149,11 +150,12 @@ OBJECTS = 7seg.o \
combine6.o combine_rnd.o \ combine6.o combine_rnd.o \
contrast.o \ contrast.o \
detect.o distances.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 \ doublesz.o drawalpha.o drawing.o drawpatt.o \
effects.o effects2.o effects3.o extractbits.o \ effects.o effects2.o effects3.o extractbits.o \
filtadapt.o filtres.o \ filtadapt.o filtres.o falsecolors.o \
gadgrect.o glitch.o \ functions.o \
gadgrect.o glitch.o gradient.o \
halfsize.o \ halfsize.o \
image.o imprime.o \ image.o imprime.o \
luts15bits.o \ luts15bits.o \
@@ -169,15 +171,16 @@ OBJECTS = 7seg.o \
pov_hf15e.o pov_hf15e.o pov_hf15f.o pov_synth.o \ pov_hf15e.o pov_hf15e.o pov_hf15f.o pov_synth.o \
ptlist.o \ ptlist.o \
quadpics.o \ quadpics.o \
recurse.o rgbmask.o \ readjpeg.o recurse.o rgbmask.o \
scale.o sobel4.o stereo.o \ scale.o sobel4.o stereo.o \
tamppool.o tele_2.o television.o \ tamppool.o tele_2.o television.o \
text0.o text1.o text16x24.o \ text0.o text1.o text16x24.o \
tga.o tools.o trigo.o turtle.o \ tga.o tools.o turtle.o \
vignetize.o \ vignetize.o \
warp0.o warp1.o warp2.o warp3.o \ warp0.o warp1.o warp2.o \
zoom.o zoom.o
# build the static library
../libtthimage.a: $(OBJECTS) ../libtthimage.a: $(OBJECTS)
$(AR) rs $@ $? $(AR) rs $@ $?
$(RANLIB) $@ $(RANLIB) $@
@@ -185,7 +188,7 @@ OBJECTS = 7seg.o \
#----------------------------------------------------------------- #-----------------------------------------------------------------
foo: foo.c $(DEPS) ../libtthimage.a 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 t_png: t_png.c $(DEPS) ../libtthimage.a
gcc $(CFLAGS) $< ../libtthimage.a -lpng -lz -o $@ gcc $(CFLAGS) $< ../libtthimage.a -lpng -lz -o $@
@@ -198,7 +201,10 @@ testbmp: testbmp.c $(DEPS) ../libtthimage.a
essais.o: essais.c $(DEPS) essais.h essais.o: essais.c $(DEPS) essais.h
gcc $(CFLAGS) $< -c 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 $@ gcc $(CFLAGS) $< essais.o ../libtthimage.a -lm -o $@
#----------------------------------------------------------------- #-----------------------------------------------------------------

View File

@@ -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. 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.

View File

@@ -7,8 +7,9 @@
Et c,a va me forcer a installer libpng Et c,a va me forcer a installer libpng
-------------------------------------- --------------------------------------
15May01: on attend toujours libPNG 15May01: on attend toujours libPNG
07Dec01: pfeue, libPNG toujours pas là... 07Dec01: pfeue, libPNG toujours pas la...
03Fev14: ... please wait more ... 03Fev14: ... please wait more ...
04Oct22: on the way, stay tuned.
*/ */
#include <stdio.h> #include <stdio.h>

View File

@@ -8,7 +8,7 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int Image_alpha_setvalue(Image_Desc *dst, int v_alpha) int Image_alpha_setvalue(Image_Desc *dst, int v_alpha)

View File

@@ -40,7 +40,6 @@ return FUNC_NOT_FINISH;
int int
Image_anmo_grille(Image_Desc *dst) Image_anmo_grille(Image_Desc *dst)
{ {
int x, y;
if (dst->magic != MAGIC_OF_IMAGE) if (dst->magic != MAGIC_OF_IMAGE)
{ {

View File

@@ -2,17 +2,17 @@
BASIC_IO Sept 2001 BASIC_IO Sept 2001
-------- --------- -------- ---------
Ce module a été écrit pour tenter de régler les Ce module a ete ecrit pour tenter de regler les
problèmes de "boutisme" pour que ça puisse aussi problemes de "boutisme" pour que c,a puisse aussi
tourner sur les vrais processeurs, parce que, bon, 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 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". un peu beaucoup du "try and test".
D'autre part, comment ça va se passer sur des CPUs D'autre part, comment les choses vont se passer sur
à 64 (ou 128) bits ? des CPUs a 64 (ou 128) bits ?
------------------------------------------------- -------------------------------------------------
9 oct 2001: pourquoi pas de fonction pour ecrire des BYTEs ? 9 oct 2001: pourquoi pas de fonction pour ecrire des BYTEs ?
@@ -136,7 +136,7 @@ for (foo=0; foo<4; foo++)
*pvalue = value; *pvalue = value;
return FUNC_IS_BETA; return FUNC_IS_BETA; /* XXX ? */
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int Image_basicIO_write_I_long(FILE *fp, long value) int Image_basicIO_write_I_long(FILE *fp, long value)

View File

@@ -20,30 +20,34 @@
* et les parametres x et y disent ou recopier les pixels dans l'image * et les parametres x et y disent ou recopier les pixels dans l'image
* de destination. * de destination.
*/ */
int int Image_get_rect(Image_Desc *s, Image_Rect *z, Image_Desc *d, int x, int y)
Image_get_rect(Image_Desc *s, Image_Rect *z, Image_Desc *d, int x, int y)
{ {
int xfoo, yfoo; /* oh! des 'foo' 2D :-) */ int xfoo, yfoo; /* oh! des 'foo' 2D :-) */
int xs, ys; int xs, ys;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %p %d %d )\n", __func__, s, z, d, x, y);
#endif
/*
* NEED MORE EXPLANATION XXX !
*/
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL > 1
fprintf(stderr, "GET RECT src %p %4d, %4d, %4d, %4d\n", fprintf(stderr, "GET RECT src %p %4d, %4d, %4d, %4d\n",
s, z->x, z->y, z->w, z->h); s, z->x, z->y, z->w, z->h);
fprintf(stderr, " dst %p %4d, %4d\n", d, x, y); fprintf(stderr, " dst %p %4d, %4d\n", d, x, y);
#endif #endif
if ( (z->w > d->width) || (z->h > d->height) ) if ( (z->w > d->width) || (z->h > d->height) ) {
{ fprintf(stderr, "%s: oups, bad rect\n", __func__);
return 666; return 666;
} }
for (yfoo=0; yfoo<z->h; yfoo++) for (yfoo=0; yfoo<z->h; yfoo++) {
{
ys = yfoo + z->y; ys = yfoo + z->y;
if (ys<0 || ys>s->height-1) if (ys<0 || ys>s->height-1)
continue; continue;
for (xfoo=0; xfoo<z->w; xfoo++) for (xfoo=0; xfoo<z->w; xfoo++) {
{
xs = xfoo + z->x; xs = xfoo + z->x;
if (xs<0 || xs>s->width-1) if (xs<0 || xs>s->width-1)
continue; continue;
@@ -55,23 +59,27 @@ return 0;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
* 2023-09-30: je comprend rien a ce truc !
*
* recopie d'un rectangle d'une image source par dessus * recopie d'un rectangle d'une image source par dessus
* une image destination. * une image destination.
*/ */
int int Image_put_rect(Image_Desc *s, Image_Rect *z, Image_Desc *d, int x, int y)
Image_put_rect(Image_Desc *s, Image_Rect *z, Image_Desc *d, int x, int y)
{ {
int xfoo, yfoo; int xfoo, yfoo;
int xs, ys, xd, yd; int xs, ys, xd, yd;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %p %d %d )\n", __func__, s, z, d, x, y);
#endif
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL > 1
fprintf(stderr, "PUT RECT src %p %4d, %4d, %4d, %4d\n", fprintf(stderr, "PUT RECT src %p %4d, %4d, %4d, %4d\n",
s, z->x, z->y, z->w, z->h); s, z->x, z->y, z->w, z->h);
fprintf(stderr, " dst %p %4d, %4d\n", d, x, y); fprintf(stderr, " dst %p %4d, %4d\n", d, x, y);
#endif #endif
for (yfoo=0; yfoo<z->h; yfoo++) for (yfoo=0; yfoo<z->h; yfoo++) {
{
ys = yfoo + z->y; ys = yfoo + z->y;
if (ys<0 || ys>s->height-1) if (ys<0 || ys>s->height-1)
continue; continue;
@@ -80,8 +88,7 @@ for (yfoo=0; yfoo<z->h; yfoo++)
if (yd<0 || yd>d->height-1) if (yd<0 || yd>d->height-1)
continue; continue;
for (xfoo=0; xfoo<z->w; xfoo++) for (xfoo=0; xfoo<z->w; xfoo++) {
{
xs = xfoo + z->x; xs = xfoo + z->x;
if (xs<0 || xs>s->width-1) if (xs<0 || xs>s->width-1)
continue; continue;
@@ -94,33 +101,27 @@ for (yfoo=0; yfoo<z->h; yfoo++)
} }
} }
return FUNC_IS_ALPHA; return FUNC_IS_ALPHA; /* AH BRAVO */
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
* coredumper dlmkt ! * coredumper dlmkt !
*/ */
int int Image_copy_rect(Image_Desc *s, Image_Rect *z, Image_Desc *d, int x, int y)
Image_copy_rect(Image_Desc *s, Image_Rect *z, Image_Desc *d, int x, int y)
{ {
int xs, ys, xd, yd, xx, yy; int xs, ys, xd, yd, xx, yy;
int foo; int foo;
#if DEBUG_LEVEL > 1 fprintf(stderr, ">>> %s ( %p %p %p %d %d )\n", __func__, s, z, d, x, y );
fprintf(stderr, "%s s=%p z=%p d=%p x,y=%d,%d\n", __func__,
s, z, d, x, y);
#endif
if (d->magic != MAGIC_OF_IMAGE) if (d->magic != MAGIC_OF_IMAGE) {
{
fprintf(stderr, "%s: need Dead Beef\n", __func__); fprintf(stderr, "%s: need Dead Beef\n", __func__);
return NOT_AN_IMAGE_DESC; return NOT_AN_IMAGE_DESC;
} }
foo = 0; foo = 0;
for (yy=0; yy<z->h; yy++) for (yy=0; yy<z->h; yy++) {
{
ys = yy + z->y; ys = yy + z->y;
if (ys<0 || ys>=s->height) if (ys<0 || ys>=s->height)
continue; continue;
@@ -129,8 +130,7 @@ for (yy=0; yy<z->h; yy++)
if (yd<0 || yd>=d->height) if (yd<0 || yd>=d->height)
continue; continue;
for (xx=0; xx<z->w; xx++) for (xx=0; xx<z->w; xx++) {
{
xs = xx + z->x; xs = xx + z->x;
if (xs<0 || xs>=s->width) if (xs<0 || xs>=s->width)
continue; continue;
@@ -154,22 +154,21 @@ return FUNC_IS_BETA;
* 23 dec 01 found a coredump if src image is too small * 23 dec 01 found a coredump if src image is too small
* *
*/ */
Image_Desc * Image_Desc *Image_create_subimg(Image_Desc *src, Image_Rect *r, int gray)
Image_create_subimg(Image_Desc *src, Image_Rect *r, int gray)
{ {
Image_Desc *clone; Image_Desc *clone;
int x,y,xs, ys; int x,y,xs, ys;
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, r, gray);
/* /*
* sanities controls... * sanities controls...
*/ */
if (src->type != IMAGE_RGB) if (src->type != IMAGE_RGB) {
{
fprintf(stderr, "'%s' work only on RGB images\n", __func__); fprintf(stderr, "'%s' work only on RGB images\n", __func__);
exit(5); exit(5);
} }
if ( (r->x<0) || (r->y<0) ) if ( (r->x<0) || (r->y<0) ) {
{
fprintf(stderr, "create_subimg, rect(%d,%d,%d,%d) iznotgoud\n", fprintf(stderr, "create_subimg, rect(%d,%d,%d,%d) iznotgoud\n",
r->x, r->y, r->w, r->h); r->x, r->y, r->w, r->h);
exit(5); exit(5);
@@ -180,34 +179,28 @@ if ( (r->x<0) || (r->y<0) )
* now, we allocate the new image... * now, we allocate the new image...
*/ */
clone = Image_alloc(r->w, r->h, src->type); clone = Image_alloc(r->w, r->h, src->type);
if (clone == NULL) if (clone == NULL) {
{
fprintf(stderr, "CreateSubImage: can't alloc memory...\n"); fprintf(stderr, "CreateSubImage: can't alloc memory...\n");
exit(5); exit(5);
} }
for (x=0; x<r->w; x++) for (x=0; x<r->w; x++) {
{
xs = x + r->x; xs = x + r->x;
for (y=0; y<r->h; y++) for (y=0; y<r->h; y++) {
{
ys = y + r->y; ys = y + r->y;
/*printf("dst %4d %4d ", x, y); */ /*printf("dst %4d %4d ", x, y); */
/*printf("src %4d %4d ", xs, ys); */ /*printf("src %4d %4d ", xs, ys); */
if (ys<0 || ys>src->width) if (ys<0 || ys>src->width) {
{
Image_plotRGB(clone, x, y, gray, gray, gray); Image_plotRGB(clone, x, y, gray, gray, gray);
} }
else else {
{
/* XXX calling this func is a nasty cpu sucker, /* XXX calling this func is a nasty cpu sucker,
* so we have to go to a nasty optimize trick */ * so we have to go to a nasty optimize trick */
/* XXX Image_pixel_copy(src, xs, ys, clone, x, y); */ /* XXX Image_pixel_copy(src, xs, ys, clone, x, y); */
(clone->Rpix[y])[x] = (src->Rpix[ys])[xs]; (clone->Rpix[y])[x] = (src->Rpix[ys])[xs];
(clone->Gpix[y])[x] = (src->Gpix[ys])[xs]; (clone->Gpix[y])[x] = (src->Gpix[ys])[xs];
(clone->Bpix[y])[x] = (src->Bpix[ys])[xs]; (clone->Bpix[y])[x] = (src->Bpix[ys])[xs];
} }
} }
} }

View File

@@ -19,15 +19,13 @@
#include "bmp.h" /* maybe I can hardcoded bmp.h here ? */ #include "bmp.h" /* maybe I can hardcoded bmp.h here ? */
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
static void static void fatal_error(char *txt)
fatal_error(char *txt)
{ {
fprintf(stderr, "BMP: Fatal error: %s\n", txt); fprintf(stderr, "BMP: Fatal error: %s\n", txt);
exit(10); exit(10);
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_BMP_infos(char *nom, int *pw, int *ph, int *pt, int verb)
Image_BMP_infos(char *nom, int *pw, int *ph, int *pt, int verb)
{ {
FILE *fp; FILE *fp;
BMPHEAD head; BMPHEAD head;
@@ -35,17 +33,20 @@ int foo;
if (verb) printf("BMP_Infos : '%s'\n", nom); 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); fprintf(stderr, "BMP_Infos: can't open %s\n", nom);
return FILE_NOT_FOUND; return FILE_NOT_FOUND;
} }
foo = fread(&head, 1, sizeof(head), fp); 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); fclose(fp);
if (verb) if (verb) {
{
printf("signature %c%c filesize %8ld\n", printf("signature %c%c filesize %8ld\n",
head.id[0], head.id[1], head.filesize); head.id[0], head.id[1], head.filesize);
printf("headerSize %8ld infoSize %8ld\n", printf("headerSize %8ld infoSize %8ld\n",
@@ -54,7 +55,7 @@ if (verb)
head.width, head.height, head.bits); head.width, head.height, head.bits);
printf("colors: used %ld important %ld\n", printf("colors: used %ld important %ld\n",
head.clrused, head.clrimportant); 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. * now, return some usefull informations.
@@ -70,28 +71,32 @@ return 0;
*/ */
#define PIX2BYTE(n) ((n+7)/8) #define PIX2BYTE(n) ((n+7)/8)
Image_Desc * Image_Desc * Image_BMP_alloc_load(char *nom, int reserved)
Image_BMP_alloc_load(char *nom, int reserved)
{ {
(void)reserved; /* WARNING KILLER */
FILE *fp; FILE *fp;
BMPHEAD head; BMPHEAD head;
int ligne, foo, larg, col, ligne2; int ligne, foo, larg, col, ligne2;
Image_Desc *image; Image_Desc *image;
uint8_t *buffer; uint8_t *buffer;
if ((fp=fopen(nom, "r")) == NULL) if ((fp=fopen(nom, "r")) == NULL) {
{
fprintf(stderr, "can't open %s\n", nom); fprintf(stderr, "can't open %s\n", nom);
return NULL; return NULL;
} }
foo = fread(&head, 1, sizeof(head), fp); 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 #if DEBUG_LEVEL
fprintf(stderr, "BMP: on a lu %d octets pour le header.\n", foo); fprintf(stderr, "BMP: on a lu %d octets pour le header.\n", foo);
#endif #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); fprintf(stderr, "BMP_Alloc_Load: BAD MAGIC %s\n", nom);
return NULL; return NULL;
} }
@@ -103,15 +108,13 @@ fprintf(stderr, "BMP_Alloc_Load: image depth = %d\n", head.bits);
/* /*
* first step: allocating the memory. * first step: allocating the memory.
*/ */
switch (head.bits) switch (head.bits) {
{
case 1: case 4: case 8: case 1: case 4: case 8:
fprintf(stderr, "bit depth %d not supported\n", head.bits); fprintf(stderr, "bit depth %d not supported\n", head.bits);
return NULL; return NULL;
break; break;
case 24: case 24:
if ( (image=Image_alloc(head.width, head.height, 3))==NULL) if ( (image=Image_alloc(head.width, head.height, 3))==NULL)
fatal_error("no memory for picture in 'alloc_load'\n"); 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"); fatal_error("no memory for buffer in 'alloc_load'\n");
larg = head.width * 3; larg = head.width * 3;
break; break;
default: default:
@@ -132,8 +134,7 @@ switch (head.bits)
/* /*
* round up to an even dword boundary (?) * round up to an even dword boundary (?)
*/ */
if (larg & 0x00000003) if (larg & 0x00000003) {
{
larg |= 0x00000003; larg |= 0x00000003;
larg++; larg++;
} }
@@ -143,17 +144,14 @@ if (larg & 0x00000003)
* *
* (no default case, filtered in first step) * (no default case, filtered in first step)
*/ */
switch (head.bits) switch (head.bits) {
{
case 24: case 24:
for (ligne=0; ligne<head.height; ligne++) for (ligne=0; ligne<head.height; ligne++) {
{
foo=fread(buffer, 1, larg, fp); foo=fread(buffer, 1, larg, fp);
/* printf("ligne %5d lu %d\n", ligne, foo); */ /* printf("ligne %5d lu %d\n", ligne, foo); */
ligne2 = head.height - ligne - 1; 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->Bpix[ligne2])[col] = buffer[ col*3 ];
(image->Gpix[ligne2])[col] = buffer[ (col*3) + 1 ]; (image->Gpix[ligne2])[col] = buffer[ (col*3) + 1 ];
(image->Rpix[ligne2])[col] = buffer[ (col*3) + 2 ]; (image->Rpix[ligne2])[col] = buffer[ (col*3) + 2 ];
@@ -172,9 +170,9 @@ return image;
* *
* et cette fois-ci, on va faire gaffe au boutisme :) * et cette fois-ci, on va faire gaffe au boutisme :)
*/ */
int int Image_BMP_save_24(char *filename, Image_Desc *img, int flag)
Image_BMP_save_24(char *filename, Image_Desc *img, int flag)
{ {
(void)flag; /* WARNING KILLER */
FILE *fp; FILE *fp;
long grand; long grand;
short court; short court;
@@ -187,8 +185,7 @@ fprintf(stderr, "%s : writing %p to %s, flag=%d\n", __func__,
img, filename, flag); img, filename, flag);
#endif #endif
if ((fp=fopen(filename, "w")) == NULL) if ((fp=fopen(filename, "w")) == NULL) {
{
fprintf(stderr, "can't open %s for writing\n", filename); fprintf(stderr, "can't open %s for writing\n", filename);
return FILE_CREATE_ERR; return FILE_CREATE_ERR;
} }
@@ -206,8 +203,7 @@ if (bytes & 0x3)
bytes++; bytes++;
} }
*/ */
switch (bytes & 0x3) switch (bytes & 0x3) {
{
case 0: /* OK */ break; case 0: /* OK */ break;
case 1: bytes+=3; break; case 1: bytes+=3; break;
case 2: bytes+=2; break; case 2: bytes+=2; break;
@@ -261,14 +257,12 @@ fflush(fp);
if ((buffer=(uint8_t *)malloc(sizeof(uint8_t)*4*img->width)) == NULL) if ((buffer=(uint8_t *)malloc(sizeof(uint8_t)*4*img->width)) == NULL)
fatal_error("no memory buffer for BMP24 save operation"); 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; ptr = buffer;
Rptr = img->Rpix[line]; Rptr = img->Rpix[line];
Gptr = img->Gpix[line]; Gptr = img->Gpix[line];
Bptr = img->Bpix[line]; Bptr = img->Bpix[line];
for (foo=0; foo<img->width; foo++) for (foo=0; foo<img->width; foo++) {
{
*ptr++ = Bptr[foo]; *ptr++ = Bptr[foo];
*ptr++ = Gptr[foo]; *ptr++ = Gptr[foo];
*ptr++ = Rptr[foo]; *ptr++ = Rptr[foo];

View File

@@ -11,26 +11,23 @@
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
* fonction en chantier -> coredump probable * 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: * 7 nov 2007:
* le flag a disparu, il contient maintenant la valeur de * le flag a disparu, il contient maintenant la valeur de
* la composante verte. lol. * la composante verte. lol.
*/ */
int int Image_cadre_burp_0(Image_Desc *img, int p1, int p2, int gval)
Image_cadre_burp_0(Image_Desc *img, int p1, int p2, int gval)
{ {
int x, y, zz, v; int x, y, zz, v;
#if DEBUG_LEVEL #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 #endif
for (x=0; x<img->width; x++) for (x=0; x<img->width; x++) {
{
v = (x * 256) / img->width; v = (x * 256) / img->width;
for (zz=0; zz<p1; zz++) for (zz=0; zz<p1; zz++) {
{
y = zz; y = zz;
(img->Rpix[y])[x] = 0; (img->Rpix[y])[x] = 0;
(img->Gpix[y])[x] = gval; (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; v = (y * 256) / img->height;
for (zz=0; zz<p2; zz++) for (zz=0; zz<p2; zz++) {
{
x = zz; x = zz;
(img->Rpix[y])[x] = 0; (img->Rpix[y])[x] = 0;
(img->Gpix[y])[x] = gval; (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 * 1er Juillet 2022: la colere est toujours la, mais ce n'est pas la
* meme qu'il y a vingt ans... * meme qu'il y a vingt ans...
*/ */
int int Image_cadre_burp_1(Image_Desc *img, int p1, int p2, int flags)
Image_cadre_burp_1(Image_Desc *img, int p1, int p2, int flags)
{ {
int x, xx, y, yy, v; 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); fprintf(stderr, ">>> %s ( %p %d %d $%x )\n", __func__, img, p1, p2, flags);
#endif #endif
for (x=0; x<img->width; x++) for (x=0; x<img->width; x++) {
{
v = (x * 256) / img->width; v = (x * 256) / img->width;
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL > 1
printf("%s : debug %d %d\n", __func__, x, v); printf("%s : debug %d %d\n", __func__, x, v);
#endif #endif
for (yy=0; yy<p1; yy++) for (yy=0; yy<p1; yy++) {
{
y = yy; y = yy;
(img->Rpix[y])[x] = TOPV-v; (img->Rpix[y])[x] = TOPV-v;
(img->Gpix[y])[x] = TOPV; (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; v = (y * 256) / img->height;
for (xx=0; xx<p2; xx++) for (xx=0; xx<p2; xx++) {
{
x = xx; x = xx;
(img->Rpix[y])[x] = 0; (img->Rpix[y])[x] = 0;
(img->Gpix[y])[x] = TOPV; (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__); fprintf(stderr, "plop from %s\n", __func__);
} }
@@ -133,8 +122,7 @@ return OLL_KORRECT;
* des exemples des objets POV de tTh * des exemples des objets POV de tTh
* *
*/ */
int int Image_cadre_burp_2(Image_Desc *img, int taille, int pr, int pg, int pb)
Image_cadre_burp_2(Image_Desc *img, int taille, int pr, int pg, int pb)
{ {
int x, y, zz; 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); fprintf(stderr, ">>> %s: sz %d, rgb %d %d %d\n", __func__, taille, pr, pg, pb);
#endif #endif
for (x=0; x<img->width; x++) for (x=0; x<img->width; x++) {
{ for (zz=0; zz<taille; zz++) {
for (zz=0; zz<taille; zz++)
{
y = zz; y = zz;
(img->Rpix[y])[x] |= pr; (img->Rpix[y])[x] |= pr;
(img->Gpix[y])[x] ^= pg; (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 (y=taille; y<img->height-taille; y++) {
{ for (zz=0; zz<taille; zz++) {
for (zz=0; zz<taille; zz++)
{
x = zz; x = zz;
(img->Rpix[y])[x] |= pr; (img->Rpix[y])[x] |= pr;
(img->Gpix[y])[x] ^= pg; (img->Gpix[y])[x] ^= pg;
@@ -177,13 +161,13 @@ for (y=taille; y<img->height-taille; y++)
return OLL_KORRECT; return OLL_KORRECT;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_cadre_burp_3(Image_Desc *img, int taille, int pr, int pg, int pb)
Image_cadre_burp_3(Image_Desc *img, int taille, int pr, int pg, int pb)
{ {
int foo; int foo;
#if DEBUG_LEVEL #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 #endif
foo = Image_cadre_burp_2(img, taille, pr, pg, pb); foo = Image_cadre_burp_2(img, taille, pr, pg, pb);
@@ -201,7 +185,7 @@ int foo;
int r, g, b; int r, g, b;
#if DEBUG_LEVEL #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 #endif
#define RASTA_RAND 4 #define RASTA_RAND 4
@@ -210,33 +194,30 @@ rect.x = rect.y = 0;
rect.w = img->width; rect.w = img->width;
rect.h = img->height; rect.h = img->height;
for (foo=0; foo<taille; foo++) for (foo=0; foo<taille; foo++) {
{
r = 220 + (rand() % RASTA_RAND); r = 220 + (rand() % RASTA_RAND);
b = 10 + (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.x++; rect.y++;
rect.h-=2; rect.w-=2; rect.h-=2; rect.w-=2;
} }
for (foo=0; foo<taille; foo++) for (foo=0; foo<taille; foo++) {
{
r = 220 + (rand() % RASTA_RAND); r = 220 + (rand() % RASTA_RAND);
g = 200 + (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.x++; rect.y++;
rect.h-=2; rect.w-=2; rect.h-=2; rect.w-=2;
} }
for (foo=0; foo<taille; foo++) for (foo=0; foo<taille; foo++) {
{
g = 220 + (rand() % RASTA_RAND); g = 220 + (rand() % RASTA_RAND);
b = 10 + (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.x++; rect.y++;
rect.h-=2; rect.w-=2; rect.h-=2; rect.w-=2;
} }
img->modified = 1; img->modified = 1;
return FUNC_IS_BETA; return OLL_KORRECT;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/

View File

@@ -2,7 +2,7 @@
calcluts.c calcluts.c
---------- ----------
voir aussi: luts15bits.c voir aussi: luts15bits.c & palettes.c
*/ */
@@ -17,29 +17,26 @@
#include "../tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_calclut_lin(int *lut, int v0, int v255)
Image_calclut_lin(int *lut, int v0, int v255)
{ {
int foo, quux, delta; int foo, quux, delta;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "calclut lin: v0 = %d v255 = %d\n", v0, v255); fprintf(stderr, ">>> %s ( %p %d %d )\n", __func__, lut, v0, v255);
#endif #endif
delta = v255 - v0; delta = v255 - v0;
if (delta == 0) if (delta == 0) {
{
return DIVISOR_IS_0; return DIVISOR_IS_0;
} }
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "calclut lin: delta = %d\n", delta); fprintf(stderr, " calclut lin: delta = %d\n", delta);
#endif #endif
for (foo=0; foo<256; foo++) for (foo=0; foo<256; foo++) {
{
quux = (foo * delta / 255) + v0; quux = (foo * delta / 255) + v0;
#if DEBUG_LEVEL #if DEBUG_LEVEL > 1
printf("lut(%d) = %d\n", foo, quux); printf("lut(%d) = %d\n", foo, quux);
#endif #endif
lut[foo] = quux; lut[foo] = quux;
@@ -48,66 +45,53 @@ for (foo=0; foo<256; foo++)
return FUNC_IS_ALPHA; return FUNC_IS_ALPHA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_calclut_foo(int *lut, int v0, int v255)
Image_calclut_foo(int *lut, int v0, int v255)
{ {
fprintf(stderr, "%s ( %p %d %d )\n", __func__, lut, v0, v255); fprintf(stderr, ">>> %s ( %p %d %d )\n", __func__, lut, v0, v255);
return FUNC_IS_ALPHA; return FUNC_IS_ALPHA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_print_lut(int *lut, char *fname, int flag)
Image_print_lut(int *lut, char *fname, int flag)
{ {
FILE *fp; FILE *fp;
int foo; int foo;
if (strcmp(fname, "-")) if (strcmp(fname, "-")) fp = fopen(fname, "w");
fp = fopen(fname, "w"); else fp = stdout;
else
fp = stdout;
for (foo=0; foo<256; foo++) for (foo=0; foo<256; foo++) {
{ if (flag) printf("%4d ", foo);
if (flag) printf(" %4d\n", lut[foo]);
printf("%d ", foo);
printf("%d\n", lut[foo]);
} }
if (fp!=stdout) if (fp!=stdout) fclose(fp);
fclose(fp);
return FUNC_IS_ALPHA; return FUNC_IS_ALPHA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_load_lut(int *lut, char *fname, int flag)
Image_load_lut(int *lut, char *fname, int flag)
{ {
FILE *fp; FILE *fp;
int value, foo, idx; int value, foo, idx;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p '%s' )\n", __func__, fname, lut);
#endif
if (flag) { if (flag) {
fprintf(stderr, "in %s, flag must be O, was %d\n", __func__, flag); fprintf(stderr, "in %s, flag must be O, was %d\n", __func__, flag);
return WRONG_FLAG; return WRONG_FLAG;
} }
#if DEBUG_LEVEL if (NULL==(fp=fopen(fname, "r"))) {
fprintf(stderr, "load_lut %s in %p\n", fname, lut);
#endif
if (NULL==(fp=fopen(fname, "r")))
{
fprintf(stderr, "%s can't fopen %s\n", __func__, fname); fprintf(stderr, "%s can't fopen %s\n", __func__, fname);
return 666; return 666;
} }
/* WARNING : very crude code here (4 nov 1999) */ /* WARNING : very crude code here (4 nov 1999) */
for (idx=0; idx<256; idx++) for (idx=0; idx<256; idx++) {
{
foo = fscanf(fp, "%d", &value); foo = fscanf(fp, "%d", &value);
#if DEBUG_LEVEL
fprintf(stderr, "load lut %3d %3d %d\n", idx, foo, value);
#endif
if (1==foo) lut[idx] = value; if (1==foo) lut[idx] = value;
else lut[idx] = -1; else lut[idx] = -1;
} }

View File

@@ -246,14 +246,13 @@ return OLL_KORRECT;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_LUT_mono(Image_Desc *src, Image_Desc *dst, int *lut)
Image_LUT_mono(Image_Desc *src, Image_Desc *dst, int *lut)
{ {
int x, y, foo; int x, y, foo;
if ( (foo=Image_compare_desc(src, dst)) ) 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; 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 /* et en parlant de LUTs, il n'y aurait pas un truc pour les LUTs

View File

@@ -11,8 +11,7 @@
#include "../tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_col4bits_and(Image_Desc *src, Image_Desc *dst)
Image_col4bits_and(Image_Desc *src, Image_Desc *dst)
{ {
int foo; int foo;
@@ -52,13 +51,13 @@ static int compare_teinte(struct elem *p1, struct elem *p2)
{ {
int r1, g1, b1, r2, b2, g2; int r1, g1, b1, r2, b2, g2;
r1 = (( (p1->rgb) >>8)&0xf)<<4; r1 = (( (p1->rgb) >>8)&0xf) <<4;
g1 = (( (p1->rgb) >>4)&0xf)<<4; g1 = (( (p1->rgb) >>4)&0xf) <<4;
b1 = ( (p1->rgb) &0xf)<<4; b1 = ( (p1->rgb) &0xf) <<4;
r2 = (( (p2->rgb) >>8)&0xf)<<4; r2 = (( (p2->rgb) >>8)&0xf) <<4;
g2 = (( (p2->rgb) >>4)&0xf)<<4; g2 = (( (p2->rgb) >>4)&0xf) <<4;
b2 = ( (p2->rgb) &0xf)<<4; b2 = ( (p2->rgb) &0xf) <<4;
/* printf("%8d %8d\n", p1->compte, p2->compte); /* printf("%8d %8d\n", p1->compte, p2->compte);
return (p1->rgb - p2->rgb); */ 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) #define TAILLE (1<<12)
int int Image_calc_Map_4bits(Image_Desc *img, RGB_map *map, int nbre)
Image_calc_Map_4bits(Image_Desc *img, RGB_map *map, int nbre)
{ {
long surface, maxi; long surface, maxi;
int x, y, r, g, b, idx; 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); fprintf(stderr, " Calc map 4 bits: nbre = %d\n", nbre);
#endif #endif
if ( (nbre<1) || (nbre>255) ) if ( (nbre<1) || (nbre>255) ) {
{ fprintf(stderr, "%s: nbre %d out of range\n", __func__, nbre);
fprintf(stderr, "Calc map 4 bits: nbre %d out of range\n", nbre);
return BAD_COLOR_NUMBER; return BAD_COLOR_NUMBER;
} }
surface = img->width * img->height; surface = img->width * img->height;
#if DEBUG_LEVEL #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 #endif
for (x=0; x<TAILLE; x++) for (x=0; x<TAILLE; x++) {
{
elems[x].compte = 0L; elems[x].compte = 0L;
elems[x].rgb = x; elems[x].rgb = x;
} }
maxi = 0L; maxi = 0L;
for (x=0; x<img->width; x++) for (x=0; x<img->width; x++) {
{ for (y=0; y<img->height; y++) {
for (y=0; y<img->height; y++)
{
r = (img->Rpix[y])[x] >> 4; r = (img->Rpix[y])[x] >> 4;
g = (img->Gpix[y])[x] >> 4; g = (img->Gpix[y])[x] >> 4;
b = (img->Bpix[y])[x] >> 4; b = (img->Bpix[y])[x] >> 4;
idx = (r<<8) | (g<<4) | b; idx = (r<<8) | (g<<4) | b;
if (idx >= TAILLE) if (idx >= TAILLE) {
{
fprintf(stderr, "FATAL ERROR in %s\n", __func__); fprintf(stderr, "FATAL ERROR in %s\n", __func__);
exit(5); exit(5);
} }
@@ -119,7 +114,7 @@ for (x=0; x<img->width; x++)
} }
} }
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, " Map4bits: compte maximum = %ld\n", maxi); fprintf(stderr, "%s: compte maximum = %ld\n", __func__, maxi);
#endif #endif
/* /*
@@ -130,16 +125,14 @@ qsort(elems, TAILLE, sizeof(struct elem), compare_compteur);
/* /*
* trier la palette, certe, mais dans quel ordre ? * trier la palette, certe, mais dans quel ordre ?
* * 28 Jan 2002: why ?
* 28 Jan 2002: why ?
*/ */
qsort(elems, nbre, sizeof(struct elem), compare_teinte); qsort(elems, nbre, sizeof(struct elem), compare_teinte);
/* /*
* recopier les 'nbre' entrees hautes dans la palette * recopier les 'nbre' entrees hautes dans la palette
*/ */
for(x=0; x<nbre; x++) for(x=0; x<nbre; x++) {
{
y = elems[x].rgb; y = elems[x].rgb;
r = ((y>>8)&0xf)<<4; r = ((y>>8)&0xf)<<4;

View File

@@ -8,6 +8,8 @@
#include "../tthimage.h" #include "../tthimage.h"
#define DEBUG_LEVEL 1
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
* ATTENTION: cette fonction sert à faire des essais, et ne doit * ATTENTION: cette fonction sert à faire des essais, et ne doit
@@ -16,8 +18,7 @@
* *
* n is the number of wanted colors * n is the number of wanted colors
*/ */
int int Image_essai_col_reduce(Image_Desc *src, Image_Desc *dst, int n, int t)
Image_essai_col_reduce(Image_Desc *src, Image_Desc *dst, int n, int t)
{ {
RGB_map map; RGB_map map;
int foo; int foo;

View File

@@ -4,13 +4,14 @@
made by Thierry Boudet, aka "Oulala", aka "Tonton Th". 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 de memes dimensions. on pourra, par exemple, les utiliser
pour comparer deux traitements. pour comparer deux traitements.
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <math.h>
#include "../tthimage.h" #include "../tthimage.h"
@@ -21,7 +22,7 @@
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
* 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 sy, int oy, int zak)
@@ -29,11 +30,11 @@ int Image_combine_lines(Image_Desc *s1, Image_Desc *s2, Image_Desc *d,
int foo, x, y, my, r, g, b; int foo, x, y, my, r, g, b;
if (sy == 0) { 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; return DIVISOR_IS_ZERO;
} }
if ( (foo=Image_compare_desc(s1, s2)) ) { 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; return foo;
} }
@@ -64,13 +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 sx, int ox, int zak)
{ {
int foo, x, y, mx, r, g, b; int foo, x, y, mx, r, g, b;
if (zak) {
fprintf(stderr, "in %s, zak is not 0\n", __func__);
}
if (sx == 0) { if (sx == 0) {
fprintf(stderr, "Combine Columns: sx is zer0\n"); fprintf(stderr, "Combine Columns: sx is zer0\n");
return DIVISOR_IS_ZERO; return DIVISOR_IS_ZERO;
@@ -236,8 +241,8 @@ return OLL_KORRECT;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
* le flag 'yo' decide quelle image sera en haut à droite. * le flag 'yo' decide quelle image sera en haut a droite.
* les paramètres p1 & p2 ne sont pas utilisés. * 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 yo, int p1, int p2)
@@ -246,8 +251,12 @@ int foo;
int x, y, r, g, b; int x, y, r, g, b;
int vertical, offset; int vertical, offset;
if ( p1 || p2 ) {
fprintf(stderr, "%s: bad p1 %d or bad p2 %d\n", __func__, p1, p2);
}
if ( (foo=Image_compare_desc(s1, s2)) ) { if ( (foo=Image_compare_desc(s1, s2)) ) {
fprintf(stderr, "Combine Diagonale: differents sources (%d)\n", foo); fprintf(stderr, "%s: differents sources (%d)\n", __func__, foo);
return foo; return foo;
} }
@@ -291,6 +300,7 @@ for (y=0; y<s1->height; y++) {
} }
/* /*
* 30 sept 2008 : est-ce que cette fonction a subi un bon fuzzing ? * 30 sept 2008 : est-ce que cette fonction a subi un bon fuzzing ?
* 9 aout 2024 : non, pas encore ;)
*/ */
return OLL_KORRECT; return OLL_KORRECT;
} }
@@ -343,7 +353,7 @@ return OLL_KORRECT;
/* /*
* fonction faite pour le finisseur de DBvsEE * 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. * 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)

View File

@@ -13,42 +13,35 @@
/* /*
* un kludge en chantier. programmation à la 'Gruiik' en vue. * un kludge en chantier. programmation à la 'Gruiik' en vue.
*/ */
int int Image_combine_waou(Image_Desc *s1, Image_Desc *s2, Image_Desc *dst,
Image_combine_waou(Image_Desc *s1, Image_Desc *s2, Image_Desc *dst,
int a, int b, int c, int d) int a, int b, int c, int d)
{ {
int x, y, foo; int x, y, foo;
#if DEBUG_LEVEL #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); __func__, s1, s2, dst, a, b, c, d);
#endif #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); fprintf(stderr, "%s : sources are differents %d\n", __func__, foo);
return 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); fprintf(stderr, "%s : destination bad dims %d\n", __func__, foo);
return foo; return foo;
} }
for (y=0; y<dst->height; y++) for (y=0; y<dst->height; y++) {
{ for (x=0; x<dst->width; x++) {
for (x=0; x<dst->width; x++) if (d) {
{
if (d)
{
/* canonical function */ /* canonical function */
(dst->Rpix[y])[x] = (x & (s1->Rpix[y])[x]) | a; (dst->Rpix[y])[x] = (x & (s1->Rpix[y])[x]) | a;
(dst->Gpix[y])[x] = x | b; (dst->Gpix[y])[x] = x | b;
(dst->Bpix[y])[x] = (y & (s2->Rpix[y])[x]) | c; (dst->Bpix[y])[x] = (y & (s2->Rpix[y])[x]) | c;
} }
else else {
{
/* new 9 mars 2010 - ave St Ex */ /* new 9 mars 2010 - ave St Ex */
(dst->Rpix[y])[x] = (x & (s1->Rpix[y])[x]) ^ a; (dst->Rpix[y])[x] = (x & (s1->Rpix[y])[x]) ^ a;
(dst->Gpix[y])[x] = x ^ b; (dst->Gpix[y])[x] = x ^ b;
@@ -63,8 +56,7 @@ return FUNC_IS_BETA;
/* /*
* un kludge en chantier. programmation à la 'Gruiik' en vue. * un kludge en chantier. programmation à la 'Gruiik' en vue.
*/ */
int int Image_combine_wauo(Image_Desc *s1, Image_Desc *s2, Image_Desc *dst,
Image_combine_wauo(Image_Desc *s1, Image_Desc *s2, Image_Desc *dst,
int flag) int flag)
{ {
int x, y, foo; int x, y, foo;
@@ -72,31 +64,25 @@ int x, y, foo;
if ( flag ) if ( flag )
fprintf(stderr, "Combine Wauo: flag = %d ?\n", 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); fprintf(stderr, "Combine Wauo: sources are differents %d\n", foo);
return 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); fprintf(stderr, "Combine Wauo: destination bad dims %d\n", foo);
return foo; return foo;
} }
for (y=1; y<dst->height-1; y++) for (y=1; y<dst->height-1; y++) {
{ for (x=1; x<dst->width-1; x++) {
for (x=1; x<dst->width-1; x++)
{
(dst->Rpix[y])[x] = (s1->Rpix[y][x] + s2->Rpix[y][x])/2; (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->Gpix[y])[x] = (s1->Gpix[y])[x];
(dst->Bpix[y])[x] = (s2->Bpix[y])[x]; (dst->Bpix[y])[x] = (s2->Bpix[y])[x];
} }
else else {
{
(dst->Gpix[y])[x] = (s2->Gpix[y])[x]; (dst->Gpix[y])[x] = (s2->Gpix[y])[x];
(dst->Bpix[y])[x] = (s1->Bpix[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] * threshold values (sr, sg, sb) are in the pix range [0..255]
*/ */
int int Image_combine_seuils(Image_Desc *s1, Image_Desc *s2, Image_Desc *dst,
Image_combine_seuils(Image_Desc *s1, Image_Desc *s2, Image_Desc *dst,
int sr, int sb, int sg) int sr, int sb, int sg)
{ {
int x, y, foo; int x, y, foo;
int r, g, b; 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); fprintf(stderr, "Combine Seuils: sources are differents %d\n", foo);
return 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); fprintf(stderr, "Combine Seuils: destination bad dims %d\n", foo);
return foo; return foo;
} }
sr*=2; sg*=2; sb*=2; sr*=2; sg*=2; sb*=2;
for (y=0; y<dst->height; y++) for (y=0; y<dst->height; y++) {
{ for (x=0; x<dst->width; x++) {
for (x=0; x<dst->width; x++)
{
if ( (s1->Rpix[y][x] + s2->Rpix[y][x]) > sr ) if ( (s1->Rpix[y][x] + s2->Rpix[y][x]) > sr )
r = s1->Rpix[y][x]; r = s1->Rpix[y][x];
else else

View File

@@ -88,7 +88,7 @@ int Image_XOR(Image_Desc *s1, Image_Desc *s2, Image_Desc *d, int k)
int foo, x, y; int foo, x, y;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "---> %s ( %p %p %p %d)\n", __func__, s1, s2, d, k); fprintf(stderr, ">>> %s ( %p %p %p %d)\n", __func__, s1, s2, d, k);
#endif #endif
if ( (foo=Image_compare_desc(s1, s2)) ) if ( (foo=Image_compare_desc(s1, s2)) )

View File

@@ -6,6 +6,67 @@
#include <math.h> #include <math.h>
#include "../tthimage.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 * 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); fprintf(stderr, "%s : %p -> %p\n", __func__, source, but);
#endif #endif
if (k) {
fprintf(stderr, "In %s, k must be 0, was %d\n", __func__, k);
}
if ( (foo=Image_compare_desc(source, but)) ) { if ( (foo=Image_compare_desc(source, but)) ) {
fprintf(stderr, "%s : images are differents %d\n", __func__, foo); fprintf(stderr, "%s : images are differents %d\n", __func__, foo);
return foo; return foo;
@@ -55,6 +120,10 @@ float fr, fg, fb;
fprintf(stderr, "%s : %p -> %p\n", __func__, source, but); fprintf(stderr, "%s : %p -> %p\n", __func__, source, but);
#endif #endif
if (k) {
fprintf(stderr, "In %s, k must be 0, was %d\n", __func__, k);
}
if ( (foo=Image_compare_desc(source, but)) ) { if ( (foo=Image_compare_desc(source, but)) ) {
fprintf(stderr, "%s : images are differents %d\n", __func__, foo); fprintf(stderr, "%s : images are differents %d\n", __func__, foo);
return foo; return foo;

View File

@@ -12,11 +12,14 @@
en entree, on doit avoir une image RGB, sinon, "segfault" en entree, on doit avoir une image RGB, sinon, "segfault"
le parametre 'uh' represente l'intensite de la couleur 'on' le parametre 'uh' represente l'intensite de la couleur 'on'
*/ */
int int Image_dither_Bayer_0(Image_Desc *s, Image_Desc *d, int uh)
Image_dither_Bayer_0(Image_Desc *s, Image_Desc *d, int uh)
{ {
int dx, dy, x, y, r, g, b; int dx, dy, x, y, r, g, b;
#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 /* directement copie de la page 389 de "Bitmapped graphics" de
Steve Rimmer. */ Steve Rimmer. */
@@ -57,18 +60,19 @@ return OLL_KORRECT;
* 19 Juin 2000: dithering on a 2x2 matrice. * 19 Juin 2000: dithering on a 2x2 matrice.
* 15 Nov 2001: 'uh' parameter is _now_ working ;-} * 15 Nov 2001: 'uh' parameter is _now_ working ;-}
*/ */
int int Image_dither_crude(Image_Desc *s, Image_Desc *d, int uh)
Image_dither_crude(Image_Desc *s, Image_Desc *d, int uh)
{ {
int x, y, r, g, b; int x, y, r, g, b;
int som; int som;
Image_clear(d, 0, 0, 0); #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, s, d, uh);
#endif
for (x=0; x<(s->width-1); x+=2) if (s != d) Image_clear(d, 0, 0, 0);
{
for (y=0; y<(s->height-1); y+=2) for (x=0; x<(s->width-1); x+=2) {
{ for (y=0; y<(s->height-1); y+=2) {
r = g = b = 0; r = g = b = 0;
r += Image_R_pixel(s, x, y); r += Image_R_pixel(s, x, y);
r += Image_R_pixel(s, x+1, y); r += Image_R_pixel(s, x+1, y);
@@ -96,14 +100,8 @@ for (x=0; x<(s->width-1); x+=2)
som = r + g + b; som = r + g + b;
if (som < 2048) if (som < 2048) Image_plotRGB(d, x+1, y+1, 0, 0, 0);
{ else Image_plotRGB(d, x+1, y+1, uh, uh, uh);
Image_plotRGB(d, x+1, y+1, 0, 0, 0);
}
else
{
Image_plotRGB(d, x+1, y+1, uh, uh, uh);
}
} }
} }
@@ -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 int Image_dither_2x2(Image_Desc *s, Image_Desc *d, int uh)
Image_dither_2x2(Image_Desc *s, Image_Desc *d, int uh)
{ {
int x, y, xm, ym; int x, y, xm, ym;
int r, g, b, v; int r, g, b, v;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, s, d, uh);
#endif
x = s->width; xm = (x&1) ? (x-1) : x; x = s->width; xm = (x&1) ? (x-1) : x;
y = s->height; ym = (y&1) ? (y-1) : y; y = s->height; ym = (y&1) ? (y-1) : y;
Image_clear(d, 0, 0, 0); if (s != d) Image_clear(d, 0, 0, 0);
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "dither 2x2: %d %d %d %d\n", x, xm, y, ym); fprintf(stderr, "dither 2x2: %d %d %d %d\n", x, xm, y, ym);
#endif #endif
for (x=0; x<xm; x+=2) for (x=0; x<xm; x+=2) {
{ for (y=0; y<ym; y+=2) {
for (y=0; y<ym; y+=2)
{
/* /*
* bon sang, mais que faire ici ? * bon sang, mais que faire ici ?
*/ */
@@ -155,24 +154,24 @@ for (x=0; x<xm; x+=2)
return FUNC_IS_ALPHA; return FUNC_IS_ALPHA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_dither_seuil_random(Image_Desc *s, Image_Desc *d, int uh)
Image_dither_seuil_random(Image_Desc *s, Image_Desc *d, int uh)
{ {
int x, y, r, g, b; int x, y, r, g, b;
int foo; int foo;
if ( (foo=Image_compare_desc(s, d)) ) #if DEBUG_LEVEL
{ fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, s, d, uh);
fprintf(stderr, "dither seuil random: images are differents %d\n", foo); #endif
if ( (foo=Image_compare_desc(s, d)) ) {
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
return foo; return foo;
} }
Image_clear(d, 0, 0, 0); if (s != d) Image_clear(d, 0, 0, 0);
for (y=0; y<s->height; y++) for (y=0; y<s->height; y++) {
{ for (x=0; x<s->width; x++) {
for (x=0; x<s->width; x++)
{
if (s->Rpix[y][x] < rand() % 256) r = 0; if (s->Rpix[y][x] < rand() % 256) r = 0;
else r = uh; else r = uh;
@@ -195,35 +194,33 @@ return OLL_KORRECT;
* *
* subtle bug: uh _must_ be 255 ? * subtle bug: uh _must_ be 255 ?
*/ */
int int Image_dither_simple_error(Image_Desc *s, Image_Desc *d, int uh)
Image_dither_simple_error(Image_Desc *s, Image_Desc *d, int uh)
{ {
int x, y, xa, xb, inc, errR, errG, errB; int x, y, xa, xb, inc, errR, errG, errB;
int r, g, b, dr, dg, db; int r, g, b, dr, dg, db;
int foo; int foo;
if ( (foo=Image_compare_desc(s, d)) ) #if DEBUG_LEVEL
{ fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, s, d, uh);
fprintf(stderr, "dither simple error: images are differents %d\n", foo); #endif
if ( (foo=Image_compare_desc(s, d)) ) {
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
return foo; return foo;
} }
Image_clear(d, 0, 0, 0); if (s != d) Image_clear(d, 0, 0, 0);
errR = errG = errB = 0; errR = errG = errB = 0;
for (y=0; y<s->height; y++) for (y=0; y<s->height; y++) {
{ if (y & 1) {
if (y & 1)
{
xa = 0; xb = s->width - 1; inc = 1; xa = 0; xb = s->width - 1; inc = 1;
} }
else else {
{
xa = s->width - 1; xb = 0; inc = -1; xa = s->width - 1; xb = 0; inc = -1;
} }
for (x=xa; x!=xb; x+=inc) for (x=xa; x!=xb; x+=inc) {
{
r = (s->Rpix[y])[x]; r = (s->Rpix[y])[x];
if ( (r + errR) > 127 ) dr = uh; if ( (r + errR) > 127 ) dr = uh;
else dr = 0; else dr = 0;
@@ -253,26 +250,21 @@ return OLL_KORRECT;
* 29 Jan 2002: may be I can buid a func for automagically * 29 Jan 2002: may be I can buid a func for automagically
* computing of right values ? * computing of right values ?
*/ */
int int Image_dither_double_seuil(Image_Desc *s, Image_Desc *d, int sa, int sb, int uh)
Image_dither_double_seuil(Image_Desc *s, Image_Desc *d, int sa, int sb, int uh)
{ {
int x, y, r, g, b, foo; int x, y, r, g, b, foo;
if ( (foo=Image_compare_desc(s, d)) ) if ( (foo=Image_compare_desc(s, d)) ) {
{
fprintf(stderr, "dither double seuil: images are differents %d\n", foo); fprintf(stderr, "dither double seuil: images are differents %d\n", foo);
return foo; return foo;
} }
if ( sa >= sb ) if ( sa >= sb ) {
{
fprintf(stderr, "dither double seuil: lo %d > hi %d !\n", sa, sb); fprintf(stderr, "dither double seuil: lo %d > hi %d !\n", sa, sb);
} }
for (y=0; y<s->height; y++) for (y=0; y<s->height; y++) {
{ for (x=0; x<s->width; x++) {
for (x=0; x<s->width; x++)
{
r = (s->Rpix[y])[x]; r = (s->Rpix[y])[x];
if (r < sa) r = 0; if (r < sa) r = 0;
else if (r > sb) r = uh; else if (r > sb) r = uh;

View File

@@ -42,7 +42,7 @@ if ( (foo=Image_compare_desc(s, d)) )
Image_TGA_save("/tmp/aaaa_debug_a.tga", s, 0); Image_TGA_save("/tmp/aaaa_debug_a.tga", s, 0);
#endif #endif
Image_clear(d, 0, 0, 0); /* XXX Image_clear(d, 0, 0, 0); */
for (y=0; y<s->height-3; y+=3) 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__); fprintf(stderr, "* Image_dither_3x3_1 (%s) is experimental\n", __FILE__);
#endif #endif
Image_clear(d, 0, 0, 0); /* XXX Image_clear(d, 0, 0, 0); */
for (y=0; y<s->height-3; y+=3) for (y=0; y<s->height-3; y+=3)
{ {
@@ -167,7 +167,7 @@ if ( (foo=Image_compare_desc(s, d)) )
return foo; return foo;
} }
Image_clear(d, 0, 0, 0); /* XXX Image_clear(d, 0, 0, 0); */
return FUNC_NOT_FINISH; return FUNC_NOT_FINISH;
} }
@@ -183,7 +183,7 @@ if ( (foo=Image_compare_desc(s, d)) )
return foo; return foo;
} }
Image_clear(d, 0, 0, 0); /* XXX Image_clear(d, 0, 0, 0); */
return FUNC_NOT_FINISH; return FUNC_NOT_FINISH;
} }

View File

@@ -8,8 +8,7 @@
#include "../tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_dither_atkinson(Image_Desc *s, Image_Desc *d, int uh)
Image_dither_atkinson(Image_Desc *s, Image_Desc *d, int uh)
{ {
int x, y, r, g, b; int x, y, r, g, b;
int foo, sr, sg, sb; int foo, sr, sg, sb;
@@ -24,10 +23,8 @@ if ( (foo=Image_compare_desc(s, d)) )
Image_clear(d, 0, 0, 0); Image_clear(d, 0, 0, 0);
r = g = b = sr = sg = sb = 0; r = g = b = sr = sg = sb = 0;
for (y=0; y<s->height; y++) for (y=0; y<s->height; y++) {
{ for (x=0; x<s->width; x++) {
for (x=0; x<s->width; x++)
{
} }
} }
@@ -35,3 +32,77 @@ for (y=0; y<s->height; y++)
return FUNC_NOT_FINISH; 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;
}
/*::------------------------------------------------------------------::*/

View File

@@ -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;
}
/*::------------------------------------------------------------------::*/

View File

@@ -19,8 +19,7 @@
/* /*
* the easy one. * the easy one.
*/ */
int int Image_paint_A_rect(Image_Desc *img, Image_Rect *rect, RGBA *rgba)
Image_paint_A_rect(Image_Desc *img, Image_Rect *rect, RGBA *rgba)
{ {
int xd, yd, xf, yf, x, y; int xd, yd, xf, yf, x, y;
int r, g, b, a0, a1, nbre; int r, g, b, a0, a1, nbre;
@@ -42,10 +41,8 @@ a1 = rgba->a;
nbre = 0; nbre = 0;
for (x=xd; x<xf; x++) for (x=xd; x<xf; x++) {
{ for (y=yd; y<yf; y++) {
for (y=yd; y<yf; y++)
{
Image_getRGB(img, x, y, &r, &g, &b); Image_getRGB(img, x, y, &r, &g, &b);
/* /*
* ok, compute now... * 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; return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
* new 15 Janvier 2003. * new 15 Janvier 2003.
* première utilisation: l'écriture des titres des * premiere utilisation: l'ecriture des titres des
* image de l'expovsition. * image de l'expovsition.
*/ */
int int Image_fade_A_rect(Image_Desc *img, Image_Rect *rect, int alpha)
Image_fade_A_rect(Image_Desc *img, Image_Rect *rect, int alpha)
{ {
int xd, yd, xf, yf, x, y; int xd, yd, xf, yf, x, y;
int r, g, b ; 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); fprintf(stderr, " coefficient alpha = %d\n", alpha);
#endif #endif
for (x=xd; x<xf; x++) for (x=xd; x<xf; x++) {
{ for (y=yd; y<yf; y++) {
for (y=yd; y<yf; y++)
{
Image_getRGB(img, x, y, &r, &g, &b); Image_getRGB(img, x, y, &r, &g, &b);
/* /*
* ok, compute now... * ok, compute now...
@@ -108,34 +100,29 @@ return FUNC_IS_BETA; /* need unit testing */
* bon, une fonction pour tamponner une image quelconque avec une * bon, une fonction pour tamponner une image quelconque avec une
* image alpha, il serait temps de la mettre en place, nom ? * image alpha, il serait temps de la mettre en place, nom ?
*/ */
int int Image_tampon_alpha_0(Image_Desc *src, Image_Desc *tampon, Image_Desc *dst)
Image_tampon_alpha_0(Image_Desc *src, Image_Desc *tampon, Image_Desc *dst)
{ {
int x, y, rs, gs, bs, rt, gt, bt; int x, y, rs, gs, bs, rt, gt, bt;
int rd, gd, bd, clean_tampon; int rd, gd, bd, clean_tampon;
clean_tampon = 0; clean_tampon = 0;
/* if the 'tampon' is not defined, we have to imagine one */ /* if the 'tampon' is not defined, we have to imagine one */
if (NULL==tampon) if (NULL==tampon) {
{
tampon = Image_clone(src, 0); tampon = Image_clone(src, 0);
fprintf(stderr, "fake tampon @ %p\n", tampon); fprintf(stderr, "fake tampon @ %p\n", tampon);
Image_mirror(src, tampon, 0); Image_mirror(src, tampon, 0);
clean_tampon = 1; clean_tampon = 1;
} }
for (y=0; y<src->height; y++) for (y=0; y<src->height; y++) {
{ for (x=0; x<src->width; x++) {
for (x=0; x<src->width; x++)
{
Image_getRGB(src, x, y, &rs, &gs, &bs); Image_getRGB(src, x, y, &rs, &gs, &bs);
Image_getRGB(tampon, x, y, &rt, &gt, &bt); Image_getRGB(tampon, x, y, &rt, &gt, &bt);
rd = (rs * rt) / 256; rd = (rs * rt) / 256;
} }
} }
if (clean_tampon) if (clean_tampon) {
{
fprintf(stderr, "clean %p in %s\n", tampon, __func__); fprintf(stderr, "clean %p in %s\n", tampon, __func__);
Image_DeAllocate(tampon); free(tampon); Image_DeAllocate(tampon); free(tampon);
} }

View File

@@ -34,7 +34,7 @@ Image_plotRGB(i, x+xc, y+yc, 100, 100, 100);
fprintf(stderr, "sym %d %d\n", x, y); fprintf(stderr, "sym %d %d\n", x, y);
} }
/* le paramètre 'wrap' ne sert à rien */ /* 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 Image_draw_circle(Image_Desc *i, int xc, int yc, int rayon, RGBA *q, int wrap)
{ {
int x, y, d; int x, y, d;
@@ -62,6 +62,23 @@ for ( x=0; x<y; ) {
return FUNC_NOT_FINISH; 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 * l'appel a la fonction isign devrait disparaitre pour optimiser
* la vitesse du bouzin. * la vitesse du bouzin.
@@ -72,8 +89,8 @@ int dx, dy, ix, iy, inc;
int foo, plotx, ploty, x, y; int foo, plotx, ploty, x, y;
int plot; int plot;
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL
printf("%s %4d %4d -----> %4d %4d\n", __func__, x1, y1, x2, y2); printf(">>> %s ( %p %4d %4d %4d %4d\n", __func__, i, x1, y1, x2, y2);
#endif #endif
dx = x2 - x1; dy = y2 - y1; dx = x2 - x1; dy = y2 - y1;
@@ -111,7 +128,7 @@ 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 * 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)
@@ -128,10 +145,10 @@ yd = max(0, rect->y);
xf = min((img->width), (rect->x+rect->w)); xf = min((img->width), (rect->x+rect->w));
yf = min((img->height), (rect->y+rect->h)); 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 ! * 24 Avril 2008: NON !
* 26 janvier 2014 : toujours non... * 26 janvier 2014 : toujours non...
* 19 septembre 2022 : je n'ai pas de certitude à ce sujet * 19 septembre 2022 : je n'ai pas de certitude a ce sujet
*/ */
#if DEBUG_LEVEL > 2 #if DEBUG_LEVEL > 2
@@ -158,7 +175,6 @@ return 0;
### ###
### THERE IS A OFF-BY-ONE IN THIS FUNCTION ! ### 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)
{ {
@@ -223,4 +239,3 @@ return FUNC_IS_BETA;
/* /*
* kikoo lol a tous les goret-codeurs, et en particulier Mr Spleyt. * kikoo lol a tous les goret-codeurs, et en particulier Mr Spleyt.
*/ */

View File

@@ -1,7 +1,7 @@
/* /*
+---------------------------------------+ +---------------------------------------+
| Effets speciaux sur les images | | Effets speciaux sur les images |
| troisième module | | troisieme module |
+---------------------------------------+ +---------------------------------------+
Thierry Boudet <oulala@chez.com> Thierry Boudet <oulala@chez.com>
*/ */
@@ -70,8 +70,7 @@ return FUNC_IS_BETA;
/* /*
* 3 avril 2007: je me rend compte que les parametres ne servent a rien. * 3 avril 2007: je me rend compte que les parametres ne servent a rien.
*/ */
int int Image_effect_x_1(Image_Desc *src, Image_Desc *dst)
Image_effect_x_1(Image_Desc *src, Image_Desc *dst)
{ {
int foo, x, y, r, g, b; int foo, x, y, r, g, b;
@@ -86,7 +85,7 @@ for (y=0; y<dst->height; y++) {
g = src->Gpix[y][x]; g = src->Gpix[y][x];
b = src->Bpix[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->Rpix[y][x] = g^b;
dst->Gpix[y][x] = r^b; dst->Gpix[y][x] = r^b;
dst->Bpix[y][x] = r^g; dst->Bpix[y][x] = r^g;
@@ -97,11 +96,10 @@ return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
* 1er Février 2003: encore une autre expérimentation, qui va être * 1er Fevrier 2003: encore une autre experimentation, qui va etre
* basée sur la trigonométrie. * basee sur la trigonometrie.
*/ */
int int Image_effect_x_2(Image_Desc *src, Image_Desc *dst, int kx, int ky, int kv)
Image_effect_x_2(Image_Desc *src, Image_Desc *dst, int kx, int ky, int kv)
{ {
int foo, x, y, r, g, b; int foo, x, y, r, g, b;
double dr, dg, db, ar, ag, ab; double dr, dg, db, ar, ag, ab;
@@ -135,7 +133,7 @@ for (y=0; y<dst->height; y++) {
ab = atan2(dr, dg); 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) * 15 mars 2005: pourquoi 156 ? (XXX)
*/ */
r = (int)(ar * 156.0); r = (int)(ar * 156.0);
@@ -154,14 +152,13 @@ return FUNC_IS_BETA;
/* /*
* 30 Jan 2003: hop, j'improvise pendant que les patates cuisent :) * 30 Jan 2003: hop, j'improvise pendant que les patates cuisent :)
* 4 Fev 2003: et je peaufine pendant que le poulet mijote :) * 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. * 16 Mai 2005: je commence a ecrire la documentation.
* 29 sept 2015: je devrais finir la doc d'ici 2 ans. * 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 int Image_effect_x_3(Image_Desc *src, Image_Desc *dst, int kx, int ky, char *comp)
Image_effect_x_3(Image_Desc *src, Image_Desc *dst, int kx, int ky, char *comp)
{ {
int foo, sx, sy; int foo, sx, sy;
int x, y, r, g, b; 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); fprintf(stderr, "%s : kx %d ky %d comp '%s'\n", __func__, kx, ky, comp);
#endif #endif
if ( (foo=Image_compare_desc(src, dst)) ) if ( (foo=Image_compare_desc(src, dst)) ) {
{
fprintf(stderr, "%s: images are differents %d\n", __func__, foo); fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
return foo; return foo;
} }
if (strlen(comp) != 2) if (strlen(comp) != 2) {
{ fprintf(stderr, "%s: bad comp parameter '%s'\n", __func__, comp);
fprintf(stderr, "eff x3: bad comp parameter '%s'\n", comp);
fprintf(stderr, " must be a 2 chars string, from 'rgb'\n"); fprintf(stderr, " must be a 2 chars string, from 'rgb'\n");
return INVALID_PARAM; return INVALID_PARAM;
} }
@@ -193,25 +188,22 @@ sx = sy = 0;
/* /*
* ici il faudrait une validation des deux lettres, mais j'ai la * 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 (y=0; y<dst->height; y++) {
{ for (x=0; x<dst->width; x++) {
for (x=0; x<dst->width; x++)
{
r = src->Rpix[y][x]; r = src->Rpix[y][x];
g = src->Gpix[y][x]; g = src->Gpix[y][x];
b = src->Bpix[y][x]; b = src->Bpix[y][x];
switch(cx) switch(cx) {
{
case 'r': dx = r; break; case 'r': dx = r; break;
case 'g': dx = g; break; case 'g': dx = g; break;
case 'b': dx = b; break; case 'b': dx = b; break;
} }
switch(cy) switch(cy) {
{
case 'r': dy = r; break; case 'r': dy = r; break;
case 'g': dy = g; break; case 'g': dy = g; break;
case 'b': dy = b; break; case 'b': dy = b; break;
@@ -221,15 +213,13 @@ for (y=0; y<dst->height; y++)
sy = y + ((ky * (dy-128)) / 100); sy = y + ((ky * (dy-128)) / 100);
if ( sx >= 0 && sx < dst->width && if ( sx >= 0 && sx < dst->width &&
sy >= 0 && sy < dst->height ) sy >= 0 && sy < dst->height ) {
{
r = src->Rpix[sy][sx]; r = src->Rpix[sy][sx];
g = src->Gpix[sy][sx]; g = src->Gpix[sy][sx];
b = src->Bpix[sy][sx]; b = src->Bpix[sy][sx];
Image_plotRGB(dst, x, y, r, g, b); Image_plotRGB(dst, x, y, r, g, b);
} }
else else {
{
Image_plotRGB(dst, x, y, r, r, r); Image_plotRGB(dst, x, y, r, r, r);
} }
/* /*
@@ -285,8 +275,7 @@ return FUNC_IS_BETA;
* faudrait que les gosses arretent de ma casser les oreilles avec leur * faudrait que les gosses arretent de ma casser les oreilles avec leur
* machine a batailles. putain de gamecube... */ * machine a batailles. putain de gamecube... */
/* 23 aout 2022 : j'ai bien envie d'une SNES et d'un Trinitron */ /* 23 aout 2022 : j'ai bien envie d'une SNES et d'un Trinitron */
int int Image_effect_x_5(Image_Desc *src, Image_Desc *dst, int kx, int ky, int kz)
Image_effect_x_5(Image_Desc *src, Image_Desc *dst, int kx, int ky, int kz)
{ {
int foo, sx, sy; int foo, sx, sy;
int x, y, r, g, b; int x, y, r, g, b;

15
Lib/equalhist.c Normal file
View 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"
/*::------------------------------------------------------------------::*/

View File

@@ -17,6 +17,50 @@
#include "../tthimage.h" #include "../tthimage.h"
#include "essais.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 */ /* nouveau vacances de fevrier 2010 */
int Essayer_les_alphas(char *fname, int k) 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); 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); 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); foo = Image_luminance(src, dst, 200);
Image_TGA_save("Pictures/aaaa-luminance-200.tga", dst, 0); Image_TGA_save("Pictures/aaaa-luminance-200.tga", dst, 0);
foo = Image_luminance(src, dst, 500); 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); 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 */ /* on va creer le receptacle des horreurs */
if (NULL==(dst=Image_clone(src, 0))) { if (NULL==(dst=Image_clone(src, 0))) {
fprintf(stderr, "%s: err clone\n", __func__);
exit(5); exit(5);
} }
/* ah bravo ! enfin un test unitaire appelable /* ah bravo ! enfin un test unitaire appelable
* depuis le test unitaire */ * 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); foo = Image_essai_col_reduce(src, dst, 133, idx);
printf("le retour de l'essai_col_reduce %d est %d\n", idx, foo); printf("le retour de l'essai_col_reduce %d est %d\n", idx, foo);
if (OLL_KORRECT==foo) if (OLL_KORRECT==foo) {
{ sprintf(fname, "aaaa-colredux-%02d.tga", idx);
sprintf(fname, "Pictures/aaaa-colredux-%02d.tga", idx);
Image_TGA_save(fname, dst, 0); 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); 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_TGA_save("Pictures/aaaa-zoom.tga", nucked, 0);
Image_DeAllocate(nucked); free(nucked); Image_DeAllocate(nucked); free(nucked);
@@ -425,7 +470,6 @@ int rotule, foo;
Image_Desc *origine, *imgtmp; Image_Desc *origine, *imgtmp;
char chaine[100]; char chaine[100];
int filtre[11]; int filtre[11];
int w3, h3;
Image_Rect rect; Image_Rect rect;
static int datas_sobel[] = static int datas_sobel[] =
@@ -442,6 +486,8 @@ static int datas_prewitt[] =
-1, -1, -1, -1, -1, -1,
1, 128 1, 128
}; };
#if 0
/* WHAT THE HELL is this data thing ? */
static struct offxy static struct offxy
{ int x, y; } offsets[] = { { int x, y; } offsets[] = {
{ 1, 0 }, { 1, 0 },
@@ -453,6 +499,7 @@ static struct offxy
{ 0, 1 }, { 0, 1 },
{ 0, 0 } { 0, 0 }
}; };
#endif
printf("========= Filtrage directionnel sur %s =======\n", srcname); printf("========= Filtrage directionnel sur %s =======\n", srcname);
@@ -464,9 +511,6 @@ printf("image originale @ %p\n", origine);
imgtmp = Image_clone(origine, 1); imgtmp = Image_clone(origine, 1);
w3 = origine->width * 3;
h3 = origine->height * 3;
if (flags) memcpy(filtre, datas_prewitt, sizeof(filtre)); if (flags) memcpy(filtre, datas_prewitt, sizeof(filtre));
else memcpy(filtre, datas_sobel, 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); 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); fprintf(stderr, "Err loading '%s'\n", srcname);
exit(5); exit(5);
} }
dst = Image_clone(src, 0); dst = Image_clone(src, 0);
foo = Image_warp_essai_0(src, dst, 33.5, 100, 100); 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); 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; ax = (src->width * 2) / 3;
ay = (src->height * 2) / 3; ay = (src->height * 2) / 3;
foo = Image_shift_xy(src, dst, ax, ay); 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); 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); 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(src); free(src);
Image_DeAllocate(dst); free(dst); Image_DeAllocate(dst); free(dst);
return 42; return 42;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
@@ -750,7 +792,7 @@ Image_DeAllocate(dst); free(dst);
return 42; return 42;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int Test_classif(char *srcname, int k) int Test_Classif(char *srcname, int k)
{ {
Image_Desc *src, *dst; Image_Desc *src, *dst;
int foo; int foo;
@@ -767,8 +809,7 @@ static Une_Classe_Sph classs[] =
{ 0, 255, 0, DC, 0, 255, 0 } { 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); fprintf(stderr, "Err loading '%s'\n", srcname);
exit(5); exit(5);
} }
@@ -776,11 +817,11 @@ dst = Image_clone(src, 0);
foo = Image_classif_0(src, dst); foo = Image_classif_0(src, dst);
Image_print_error("essai classif 0", foo); 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); foo = Image_classif_1(src, dst, classs, 5, 0);
Image_print_error("essai classif 1", foo); 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(src); free(src);
Image_DeAllocate(dst); free(dst); Image_DeAllocate(dst); free(dst);
@@ -789,23 +830,29 @@ return 42;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* new 24 avril 2007, essais sur le module rgbmask.c */ /* new 24 avril 2007, essais sur le module rgbmask.c */
int int Test_RGBmask(char *srcname)
Test_rgbmask(char *srcname)
{ {
Image_Desc *source, *image ; Image_Desc *source, *image ;
int foo; int foo;
fprintf(stderr, "=============== %s on %s ==============\n", __func__, srcname);
source = Image_TGA_alloc_load(srcname); source = Image_TGA_alloc_load(srcname);
image = Image_clone(source, 0); image = Image_clone(source, 0);
foo = Image_rgbmask_H(source, image, 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); 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); 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); 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; return 42;
} }
@@ -941,9 +988,9 @@ return 0;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
* 2023-09-30 this function need more work
*/ */
int int Test_copie_de_rectangles(char *nomsource)
Test_copie_de_rectangles(char *nomsource)
{ {
Image_Desc *source, *image, *finale; Image_Desc *source, *image, *finale;
int foo, w, h, x, y; int foo, w, h, x, y;
@@ -1006,15 +1053,47 @@ Image_DeAllocate(finale); free(finale);
return 0; return 0;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int /* new: Sat Aug 10 15:32:01 UTC 2024 */
Test_Egalisations(char *nomsource, int k) 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; Image_Desc *image, *deuxieme, *troisieme;
int x, y; 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); printf("image loaded %p\n", image);
deuxieme = Image_clone(image, 0); deuxieme = Image_clone(image, 0);
@@ -1025,18 +1104,17 @@ troisieme = Image_clone(image, 0);
printf("image 3 cloned %p\n", troisieme); printf("image 3 cloned %p\n", troisieme);
Image_egalise_RGB(image, troisieme, 0); Image_egalise_RGB(image, troisieme, 0);
for (x=0; x<image->width; x++) for (x=0; x<image->width; x++) {
{ if (x < image->width/3) {
if (x < image->width/3) for (y=0; y<image->height; y++) {
{
for (y=0; y<image->height; y++)
Image_pixel_copy(image, x, y, troisieme, x, y); Image_pixel_copy(image, x, y, troisieme, x, y);
}
} }
else else
if (x > image->width/3*2) if (x > image->width/3*2) {
{ for (y=0; y<image->height; y++) {
for (y=0; y<image->height; y++)
Image_pixel_copy(deuxieme, x, y, troisieme, x, y); Image_pixel_copy(deuxieme, x, y, troisieme, x, y);
}
} }
#if DEBUG_LEVEL > 2 #if DEBUG_LEVEL > 2
@@ -1046,7 +1124,7 @@ for (x=0; x<image->width; x++)
printf("saving resultat...\n"); printf("saving resultat...\n");
Image_marque_1(troisieme, "Egalisations", 0); 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(image); free(image);
Image_DeAllocate(deuxieme); free(deuxieme); Image_DeAllocate(deuxieme); free(deuxieme);
Image_DeAllocate(troisieme); free(troisieme); Image_DeAllocate(troisieme); free(troisieme);
@@ -1054,30 +1132,30 @@ Image_DeAllocate(troisieme); free(troisieme);
return 42; return 42;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Test_Dithering(char *nomsource, int k)
Test_Dithering(char *nomsource, int k)
{ {
Image_Desc *source, *image, *deuxieme, *finale; Image_Desc *source, *image, *deuxieme, *finale;
Image_Rect rect; Image_Rect rect;
int foo; int foo, wf, hf;
int x2, y2; int x2, y2;
RGBA ink, pap; 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); source = Image_TGA_alloc_load(nomsource);
if (NULL == source) if (NULL == source) {
{
fprintf(stderr, "%s:%s err load %s\n", __FILE__, __func__, nomsource); fprintf(stderr, "%s:%s err load %s\n", __FILE__, __func__, nomsource);
exit(5); exit(5);
} }
#if DEBUG_LEVEL
Image_dump_descriptor(source, "just after load"); Image_dump_descriptor(source, "just after load");
#endif
/* /*
* est-ce bien necessaire ? * est-ce bien necessaire ?
*/ */
/* Image_egalise_RGB(source, source, 0); */ /* Image_egalise_RGB(source, source, 0); */
wf = source->width; hf = (source->height) * 3;
x2 = source->width / 2; y2 = source->height / 2; x2 = source->width / 2; y2 = source->height / 2;
rect.w = x2; rect.h = y2; rect.w = x2; rect.h = y2;
rect.x = 0; rect.y = 0; 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; ink.r = 255, ink.g = 255, ink.b = 100; ink.a = 255;
pap.r = 30, pap.g = 30, pap.b = 155; pap.a = 255; pap.r = 30, pap.g = 30, pap.b = 155; pap.a = 255;
finale = Image_alloc(source->width, (source->height)*3, 3); finale = Image_alloc(wf, hf, 3);
if (NULL == finale) if (NULL == finale) {
{
fprintf(stderr, "%s:%s:%d err alloc image\n", fprintf(stderr, "%s:%s:%d err alloc image\n",
__FILE__, __func__, __LINE__); __FILE__, __func__, __LINE__);
exit(5); 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); image = Image_MakeHalfSize(source, 0);
if (NULL == image) if (NULL == image) {
{
fprintf(stderr, "%s:%s:%d err halfsize image\n", fprintf(stderr, "%s:%s:%d err halfsize image\n",
__FILE__, __func__, __LINE__); __FILE__, __func__, __LINE__);
exit(5); exit(5);
} }
printf("%s: image Half at %p\n", __func__, image);
printf("image Half -> %p\n", image);
Image_DeAllocate(source); free(source); Image_DeAllocate(source); free(source);
Image_copy_rect(image, &rect, finale, 0, 0); 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); foo = Image_dither_bayer8x8rnd(image, deuxieme, 5000, 0);
printf("retour Dither bayer8x8rnd = %d\n", foo); printf("retour Dither bayer8x8rnd = %d\n", foo);
Image_copy_rect(deuxieme, &rect, finale, x2, y2*4); 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); foo = Image_dither_bayer8x8rnd(image, deuxieme, 5000, 1);
printf("retour Dither bayer8x8rnd = %d\n", foo); printf("retour Dither bayer8x8rnd = %d\n", foo);
Image_copy_rect(deuxieme, &rect, finale, 0, y2*4); 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(image); free(image);
Image_DeAllocate(deuxieme); free(deuxieme); Image_DeAllocate(deuxieme); free(deuxieme);
Image_DeAllocate(finale); free(finale); Image_DeAllocate(finale); free(finale);
printf("++++++ fin essais dither\n");
return 0; return 0;
} }
@@ -1177,8 +1256,7 @@ return -1;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* new 21 juillet 2007 - ave St Exupery */ /* new 21 juillet 2007 - ave St Exupery */
int int Test_Effects_A(char *nomsource, int flag)
Test_Effects_A(char *nomsource, int flag)
{ {
Image_Desc *source, *image, *deuxieme, *finale; Image_Desc *source, *image, *deuxieme, *finale;
int foo; int foo;
@@ -1187,8 +1265,7 @@ RGBA ink, pap;
printf("=== %s %s === %s === %d ===\n", __FILE__, __func__, nomsource, flag); printf("=== %s %s === %s === %d ===\n", __FILE__, __func__, nomsource, flag);
if (flag) if (flag) {
{
fprintf(stderr, "%s: flag is %d ?\n", __func__, 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; pap.r = 30, pap.g = 30, pap.b = 155; pap.a = 255;
source = Image_TGA_alloc_load(nomsource); source = Image_TGA_alloc_load(nomsource);
if (NULL==source) if (NULL==source) {
{
fprintf(stderr, "%s : il manque '%s'\n", __func__, nomsource); fprintf(stderr, "%s : il manque '%s'\n", __func__, nomsource);
exit(1); exit(1);
} }
@@ -1273,8 +1349,7 @@ Image_DeAllocate(finale); free(finale);
return 42; return 42;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Test_des_tamppools(char *imgname, int param)
Test_des_tamppools(char *imgname, int param)
{ {
void *ptr; void *ptr;
int foo; int foo;
@@ -1297,30 +1372,31 @@ int Test_des_filtres(char *srcname, int k)
Image_Desc *src, *dst; Image_Desc *src, *dst;
int foo; int foo;
printf("======= LES FILTRES ===[ %s ]==[ %d ]====\n", srcname, k); printf("=============== Filtres =====[ %s ]====[ %d ]====\n", srcname, k);
src = Image_TGA_alloc_load(srcname); src = Image_TGA_alloc_load(srcname);
if (NULL == src) if (NULL == src) {
{
fprintf(stderr, "%s can't load %s\n", __func__, srcname); fprintf(stderr, "%s can't load %s\n", __func__, srcname);
return 666; return 666;
} }
dst = Image_clone(src, 1); dst = Image_clone(src, 1);
if (NULL == dst) if (NULL == dst) {
{
fprintf(stderr, "mem failure in %s\n", __func__); fprintf(stderr, "mem failure in %s\n", __func__);
abort(); abort();
} }
foo = Image_lissage_3x3(src, dst); 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); } if (foo) { fprintf(stderr, "%s: liss3x3 -> %d\n", __func__, foo); }
foo = Image_filtre_Prewitt(src, dst, 5); 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); 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); 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(src); free(src);
Image_DeAllocate(dst); free(dst); Image_DeAllocate(dst); free(dst);
@@ -1416,3 +1492,17 @@ Image_DeAllocate(dst); free(dst);
return -1; 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);
}
/* ============================== */
/*::------------------------------------------------------------------::*/

View File

@@ -27,6 +27,8 @@ int Essai_des_lut15bits(char *srcname, int k);
int Essai_des_mires(char *, int, int); int Essai_des_mires(char *, int, int);
int Essai_des_zooms(char *srcname, int k); 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_7_segments(char *srcname, int flag);
int Essai_des_distances(char *srcname, int nbre, int flag); int Essai_des_distances(char *srcname, int nbre, int flag);
int Essai_des_cadres(char *srcname, int flags); 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_vignettes(char *srcname, int k);
int Test_classif(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); void Test_rgb2xyz(void);
int Essai_des_marquages(char *srcname, int nombre, char *texte); 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_bitblt(char *srcname, int k);
int Essai_des_gadgrect(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 */ /* dans essais2;c */
int Essai_des_big_chars(char *fname, int k); int Essai_des_big_chars(char *fname, int k);

39
Lib/falsecolors.c Normal file
View 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;
}
/*::------------------------------------------------------------------::*/
/*::------------------------------------------------------------------::*/

117
Lib/foo.c
View File

@@ -2,72 +2,103 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <stdint.h> #include <stdint.h>
#include <math.h>
#include "../tthimage.h" #include "../tthimage.h"
/* ============================== */ /* ============================== */
int essai_show_t16x24( char *text)
/* 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)
{ {
if (NULL != text) Image_Desc *alice, *bob;
Image_t16x24_essai("16x24thin", text, "16x24.tga"); int x, y, foo;
else double T0, T1, perpix;
Image_t16x24_essai("16x24thin", "0123456789abcdef", "16x24.tga"); long count;
return 0; char *fname;
}
/* ============================== */
int essai_draw_paint_rect(char *outga)
{
Image_Desc *img;
Image_Rect rect;
int foo, x, y;
fprintf(stderr, ">>> %s ( '%s' )\n", __func__, outga); alice = Image_alloc(SZPIC, SZPIC, IMAGE_RGB);
bob = Image_alloc(SZPIC, SZPIC, IMAGE_RGB);
rect.x = 8; rect.y = 8; Image_pattern_000(alice, 0);
rect.w = 6; rect.h = 6; Image_TGA_save("alice.tga", alice, 0);
if (NULL==(img=Image_alloc(64, 32, 3))) { T0 = tthi_dtime();
abort(); count = 0L;
}
for (x=0; x<img->width; x+=2) { if (usemacro) {
for (y=0; y<img->height; y+=2) { for (y=0; y<SZPIC; y++) {
Image_plotRGB(img, x, y, 200, 200, 200); 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";
} }
foo = Image_draw_rect(img, &rect, 192, 128, 64); T1 = tthi_dtime();
foo = Image_TGA_save(fname, bob, 0);
if (foo) { if (foo) {
fprintf(stderr, "%s: err %d draw rect\n", __func__, foo); fprintf(stderr, "%s: save -> %d\n", __func__, foo);
return foo;
} }
rect.x = 24; perpix = ((T1-T0) / (double)count) * 1e6;
foo = Image_paint_rect(img, &rect, 64, 128, 192); fprintf(stderr, "%s : %10ld pixels, elapsed %9.6f seconds ==> %9.6f µs/pix\n",
if (foo) { usemacro ? "macro" : "func ",
fprintf(stderr, "%s: err %d paint rect\n", __func__, foo); count, T1-T0, perpix);
return foo;
}
foo = Image_TGA_save(outga, img, 0); /* end */
if (foo) {
fprintf(stderr, "%s: err %d save '%s'\n", __func__, foo, outga);
return foo;
}
return OLL_KORRECT;
} }
/* ============================== */ /* ============================== */
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int foo; int i;
Image_print_version(2); fprintf(stderr, "*********** %s ************\n", argv[0]);
Image_print_sizeof_structs("foo");
foo = essai_draw_paint_rect("foo.tga"); if (argc > 1) {
fprintf(stderr, "essai draw rect --> %d\n", foo); 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; return 0;
} }

27
Lib/functions.c Normal file
View 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;
}
/* ------------------------------------------------------------------- */
/* ------------------------------------------------------------------- */

View File

@@ -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, int Image_gadrct_poke_from_tga(char *namesrc, Image_Rect *fromrect,
Image_Desc *dst, int xdst, int ydst, int flags) Image_Desc *dst, int xdst, int ydst, int flags)

View File

@@ -5,7 +5,7 @@
#include <stdio.h> #include <stdio.h>
#include <math.h> #include <math.h>
#include "tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
@@ -32,5 +32,3 @@ for (foo=0; foo<256; foo++)
return FULL_NUCKED; return FULL_NUCKED;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/*::------------------------------------------------------------------::*/

View File

@@ -29,9 +29,9 @@ switch (code)
abort(); abort();
break; break;
} }
#if DEBUG_LEVEL if (foo) {
fprintf(stderr, "%s -> %d\n", __func__, foo); fprintf(stderr, "%s got a %d\n", __func__, foo);
#endif }
return FULL_NUCKED; return FULL_NUCKED;
} }
@@ -53,9 +53,9 @@ for (nbre=0; nbre<k; nbre++)
{ {
x = rand() % src->width; x = rand() % src->width;
y = rand() % src->height; y = rand() % src->height;
d = rand() & 3;
Image_getRGB(src, x, y, &r, &g, &b); Image_getRGB(src, x, y, &r, &g, &b);
d = rand() & 3;
switch (d) switch (d)
{ {
case 0: case 0:

60
Lib/gradient.c Normal file
View 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;
}
/*::------------------------------------------------------------------::*/

View File

@@ -13,25 +13,24 @@
#include "../tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
void void Image_print_version(int flag)
Image_print_version(int flag)
{ {
char *ptr; char *ptr;
fflush(stdout); 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); IMAGE_VERSION_STRING);
if (flag) if (flag)
{ {
/* this information is only correct IF you touch image.c before /* this information is only correct IF you touch image.c before
* running 'make' utility */ * running 'make' utility */
printf(" + compiled : %s, %s\n", __DATE__, __TIME__); fprintf(stderr, " + compiled : %s, %s\n", __DATE__, __TIME__);
} }
if (flag > 1) if (flag > 1)
{ {
printf(" + DESTDIR = %s\n", DESTDIR); fprintf(stderr, " + DESTDIR = %s\n", DESTDIR);
printf(" + SHAREDIR = %s\n", SHAREDIR); fprintf(stderr, " + SHAREDIR = %s\n", SHAREDIR);
printf(" + CC OPTS = %s\n", CC_OPTS); fprintf(stderr, " + CC OPTS = %s\n", CC_OPTS);
} }
fflush(stdout); fflush(stdout);
@@ -94,8 +93,7 @@ return 0;
* on the structure who describe the image. * on the structure who describe the image.
* - - - > don't "free" this pointer, please. * - - - > don't "free" this pointer, please.
*/ */
Image_Desc * Image_Desc * Image_alloc(int width, int height, int type)
Image_alloc(int width, int height, int type)
{ {
Image_Desc *header; Image_Desc *header;
int foo; int foo;
@@ -193,19 +191,18 @@ return header;
/* /*
This fonction build another image from a model. This fonction build another image from a model.
*/ */
Image_Desc * Image_Desc * Image_clone (Image_Desc *src, int copy)
Image_clone (Image_Desc *src, int copy)
{ {
Image_Desc *image; Image_Desc *image;
if ( src==NULL ) if ( NULL == src )
{ {
fprintf(stderr, "Image_clone: source descriptor is NULL\n"); fprintf(stderr, "Image_clone: source descriptor is NULL\n");
exit(5); exit(5);
} }
image = Image_alloc(src->width, src->height, src->type); image = Image_alloc(src->width, src->height, src->type);
if ( image==NULL ) if ( NULL == image )
{ {
fprintf(stderr, "Image_clone: cloned descriptor is NULL\n"); fprintf(stderr, "Image_clone: cloned descriptor is NULL\n");
exit(5); exit(5);
@@ -247,20 +244,16 @@ return FUNC_IS_ALPHA;
* Helas, cette fonction ne marche que sur les images RGB * Helas, cette fonction ne marche que sur les images RGB
* et comment la rendre compatible tout-types sans tout casser ? * et comment la rendre compatible tout-types sans tout casser ?
*/ */
int int Image_clear( Image_Desc *image, int r, int g, int b )
Image_clear( Image_Desc *image, int r, int g, int b )
{ {
int x, y; int x, y;
if (image->type == IMAGE_RGB) if (image->type == IMAGE_RGB) {
{ for (y=0; y<image->height; y++) {
for (y=0; y<image->height; y++)
{
/* /*
* XXX here we can go faster with a few memset * 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->Rpix[y])[x] = r;
(image->Gpix[y])[x] = g; (image->Gpix[y])[x] = g;
(image->Bpix[y])[x] = b; (image->Bpix[y])[x] = b;
@@ -270,12 +263,9 @@ if (image->type == IMAGE_RGB)
return 0; /* ok, this 'return' here is a "spleyterie" :) */ return 0; /* ok, this 'return' here is a "spleyterie" :) */
} }
if (image->type == IMAGE_RGBA) if (image->type == IMAGE_RGBA) {
{ for (y=0; y<image->height; y++) {
for (y=0; y<image->height; y++) for (x=0; x<image->width; x++) {
{
for (x=0; x<image->width; x++)
{
(image->Rpix[y])[x] = r; (image->Rpix[y])[x] = r;
(image->Gpix[y])[x] = g; (image->Gpix[y])[x] = g;
(image->Bpix[y])[x] = b; (image->Bpix[y])[x] = b;
@@ -290,12 +280,40 @@ fprintf(stderr, "%s : invalid image type %d : %s\n", __func__,
return IMAGE_BAD_TYPE; 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 * every image in memory have a comment field, who is writen
* in TGA and PNM file when image is saved. * in TGA and PNM file when image is saved.
*/ */
int int Image_set_comment(Image_Desc *image, char *text)
Image_set_comment(Image_Desc *image, char *text)
{ {
if (strlen(text) > IMG_OBJCOMMENT_LEN) if (strlen(text) > IMG_OBJCOMMENT_LEN)
return STRING_TOO_LONG; return STRING_TOO_LONG;
@@ -304,8 +322,7 @@ return OLL_KORRECT;
} }
/* 10 nov 2001: no #define for this not-so-magic 254 value ? */ /* 10 nov 2001: no #define for this not-so-magic 254 value ? */
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_plot_gray(Image_Desc *img, int x, int y, int v)
Image_plot_gray(Image_Desc *img, int x, int y, int v)
{ {
if ( x<0 || y<0 || x>=img->width || y>=img->height ) 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); fprintf(stderr, "PLOTRGB %d %d\n", x, y);
#endif #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); fprintf(stderr, "Errplot RGB X=%d, Y=%d %d, %d, %d\n", x, y, r, g, b);
#if FORCE_ABORT #if FORCE_ABORT
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) 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 ? */ /* may be an #if DEBUG_LEVEL here ? */
fprintf(stderr, "Errplot RGBA X %4d Y %4d %d, %d, %d, %d\n", fprintf(stderr, "Errplot RGBA X %4d Y %4d %d, %d, %d, %d\n",
x, y, r, g, b, a); x, y, r, g, b, a);
@@ -360,11 +375,9 @@ if ( x<0 || y<0 || x>=img->width || y>=img->height )
return OLL_KORRECT; return OLL_KORRECT;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_getRGB(Image_Desc *img, int x, int y, int *pr, int *pg, int *pb)
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 ? */ /* may be an #if DEBUG_LEVEL here ? */
fprintf(stderr, "ERR GETRGB X %4d Y %4d\n", x, y); fprintf(stderr, "ERR GETRGB X %4d Y %4d\n", x, y);
#if FORCE_ABORT #if FORCE_ABORT
@@ -380,11 +393,9 @@ if ( x<0 || y<0 || x>=img->width || y>=img->height )
return OLL_KORRECT; return OLL_KORRECT;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_getRGBA(Image_Desc *img, int x, int y, int *pr, int *pg, int *pb, int *pa)
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); fprintf(stderr, "ERR GETRGBA X %4d Y %4d\n", x, y);
#if FORCE_ABORT #if FORCE_ABORT
abort(); abort();
@@ -392,10 +403,9 @@ if ( x<0 || y<0 || x>=img->width || y>=img->height )
return OUT_OF_IMAGE; return OUT_OF_IMAGE;
} }
if (img->type != IMAGE_RGBA) if (img->type != IMAGE_RGBA) {
{ fprintf(stderr, "%s: bad image type: %d, %s\n",
fprintf(stderr, "Image get RGBA: bad image type: %d, %s\n", __func__, img->type, Image_type2str(img->type));
img->type, Image_type2str(img->type));
#if FORCE_ABORT #if FORCE_ABORT
abort(); abort();
#endif #endif
@@ -416,16 +426,14 @@ return OLL_KORRECT;
*/ */
int Image_plot_channel(Image_Desc *img, char channel, int x, int y, int value) 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 #if DEBUG_LEVEL
fprintf(stderr, "ERR PLOTCHANNEL X %4d Y %4d\n", x, y); fprintf(stderr, "ERR PLOTCHANNEL X %4d Y %4d\n", x, y);
#endif #endif
return OUT_OF_IMAGE; return OUT_OF_IMAGE;
} }
switch (channel) switch (channel) {
{
case 'r': case 'R': (img->Rpix[y])[x] = (uint8_t)(value&0xff); break; 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 '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; 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. lecture d'une des composantes de l'image.
*/ */
int int Image_R_pixel(Image_Desc *img, int x, int y)
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); fprintf(stderr, "ERR READ R PIX X%d Y%d\n", x, y);
return OUT_OF_IMAGE; return OUT_OF_IMAGE;
} }
return (int)((img->Rpix[y])[x]); return (int)((img->Rpix[y])[x]);
} }
int int Image_G_pixel(Image_Desc *img, int x, int y)
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); fprintf(stderr, "ERR READ G PIX X%d Y%d\n", x, y);
return OUT_OF_IMAGE; return OUT_OF_IMAGE;
} }
return (int)((img->Gpix[y])[x]); return (int)((img->Gpix[y])[x]);
} }
int int Image_B_pixel(Image_Desc *img, int x, int y)
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); fprintf(stderr, "ERR READ B PIX X%d Y%d\n", x, y);
return OUT_OF_IMAGE; return OUT_OF_IMAGE;
} }
return (int)((img->Bpix[y])[x]); return (int)((img->Bpix[y])[x]);
} }
int int Image_A_pixel(Image_Desc *img, int x, int y)
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); fprintf(stderr, "ERR A PIX X%d Y%d\n", x, y);
return OUT_OF_IMAGE; return OUT_OF_IMAGE;
} }
@@ -518,7 +518,7 @@ 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)
{ {
@@ -536,18 +536,16 @@ return OLL_KORRECT;
*/ */
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==NULL) || (b==NULL) ) return NULL_DESCRIPTOR;
if ( a->magic != MAGIC_OF_IMAGE ) if ( a->magic != MAGIC_OF_IMAGE ) {
{ fprintf(stderr, fmt, __func__, a);
fprintf(stderr, fmt, a);
return NOT_AN_IMAGE_DESC; return NOT_AN_IMAGE_DESC;
} }
if ( b->magic != MAGIC_OF_IMAGE ) if ( b->magic != MAGIC_OF_IMAGE ) {
{ fprintf(stderr, fmt, __func__, a);
fprintf(stderr, fmt, a);
return NOT_AN_IMAGE_DESC; return NOT_AN_IMAGE_DESC;
} }
@@ -565,8 +563,7 @@ return OLL_KORRECT;
c'est qu'il reste un pointeur fou chez c'est qu'il reste un pointeur fou chez
l'appelant ... l'appelant ...
*/ */
int int Image_DeAllocate(Image_Desc *im)
Image_DeAllocate(Image_Desc *im)
{ {
int line; int line;

View File

@@ -38,12 +38,10 @@ Image_marque_1(Image_Desc *img, char *texte, int flags)
RGBA papier, encre; RGBA papier, encre;
int len; int len;
#if DEBUG_LEVEL
if (flags) if (flags)
{ {
fprintf(stderr, "*** %s 'flags' must be ZERO ***\n", __func__); fprintf(stderr, "*** %s 'flags' must be ZERO ***\n", __func__);
} }
#endif
len = strlen(texte); len = strlen(texte);
if (len < 1) return FULL_NUCKED; if (len < 1) return FULL_NUCKED;
@@ -110,22 +108,19 @@ fprintf(stderr, "%s: '%s' %s\n", __func__, texte, ptr);
#endif #endif
papier.r = papier.g = papier.b = papier.a = 0; 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; encre.r = encre.g = encre.b = 90, encre.a = 255;
rgba = &encre; rgba = &encre;
} }
if (flags & 1) if (flags & 1) {
{
rect.x = rect.y = 3; rect.x = rect.y = 3;
rect.h = 11; rect.w = l1*8+2; rect.h = 11; rect.w = l1*8+2;
Image_paint_rect(img, &rect, 255, 255, 255); Image_paint_rect(img, &rect, 255, 255, 255);
} }
Image_trace_chaine_1(img, texte, 5, 6, "libimage.fonte", &papier, rgba); 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.x = 3; rect.y = 16;
rect.h = 11; rect.w = l2*8+2; rect.h = 11; rect.w = l2*8+2;
Image_paint_rect(img, &rect, 255, 255, 255); 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); Image_trace_chaine_1(img, ptr, 5, 18, NULL, &papier, rgba);
#if DEBUG_LEVEL
fprintf(stderr, "done %s\n", __func__);
#endif
img->modified = 1; img->modified = 1;
return FUNC_IS_BETA; return FUNC_IS_BETA;

View File

@@ -12,14 +12,14 @@ static struct
int x, y; int x, y;
} deltas[] = } deltas[] =
{ { -1, -1, }, { { -1, -1, },
{ 0, -1, }, { 0, -1, },
{ 1, -1, }, { 1, -1, },
{ -1, 0, }, { -1, 0, },
{ 0, 0, }, { 0, 0, },
{ 1, 0, }, { 1, 0, },
{ -1, 1, }, { -1, 1, },
{ 0, 1, }, { 0, 1, },
{ 1, 1 } { 1, 1 }
}; };
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
@@ -27,33 +27,24 @@ static struct
* ============================= * =============================
* 23 avril 2007: switched to direct pixel access. * 23 avril 2007: switched to direct pixel access.
*/ */
int int Image_expand_max(Image_Desc *src, Image_Desc *dst, int factor)
Image_expand_max(Image_Desc *src, Image_Desc *dst, int factor)
{ {
int foo, x, y, maxr, maxg, maxb; int foo, x, y, maxr, maxg, maxb;
int r, g, b; 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; return foo;
} }
if ( 0 != factor ) if ( 0 != factor ) {
{
fprintf(stderr, "%s: factor (%d) must be 0\n", __func__, factor); fprintf(stderr, "%s: factor (%d) must be 0\n", __func__, factor);
} }
#if DEBUG_LEVEL for (y=1; y<src->height-1; y++) {
fprintf(stderr, "expanding MAX %p to %p\n", src, dst); for (x=1; x<src->width-1; x++) {
#endif
for (y=1; y<src->height-1; y++)
{
for (x=1; x<src->width-1; x++)
{
maxr = maxg = maxb = 0; maxr = maxg = maxb = 0;
for (foo=0; foo<9; foo++) for (foo=0; foo<9; foo++) {
{
/* XXX Faster pussy cat ! /* XXX Faster pussy cat !
Image_getRGB(src, x+deltas[foo].x, y+deltas[foo].y, Image_getRGB(src, x+deltas[foo].x, y+deltas[foo].y,
&r, &g, &b); &r, &g, &b);
@@ -78,19 +69,16 @@ dst->modified = 1;
return 0; return 0;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_expand_min(Image_Desc *src, Image_Desc *dst, int factor)
Image_expand_min(Image_Desc *src, Image_Desc *dst, int factor)
{ {
int foo, x, y, minr, ming, minb; int foo, x, y, minr, ming, minb;
int r, g, b; int r, g, b;
if ( (foo=Image_compare_desc(src, dst)) ) if ( (foo=Image_compare_desc(src, dst)) ) {
{
return foo; return foo;
} }
if ( 0 != factor ) if ( 0 != factor ) {
{
fprintf(stderr, "%s: factor (%d) must be 0\n", __func__, 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); fprintf(stderr, "expanding MIN %p to %p\n", src, dst);
#endif #endif
for (y=1; y<src->height-1; y++) for (y=1; y<src->height-1; y++) {
{ for (x=1; x<src->width-1; x++) {
for (x=1; x<src->width-1; x++)
{
minr = ming = minb = 1664; 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, Image_getRGB(src, x+deltas[foo].x, y+deltas[foo].y,
&r, &g, &b); &r, &g, &b);
@@ -133,8 +118,7 @@ Image_sortmat_display(FILE *ou, struct sort_pixel *table)
fprintf(ou, "%s ( %p )\n", __func__, table); fprintf(ou, "%s ( %p )\n", __func__, table);
} }
int int Image_Gray_Sorted_Points(Image_Desc *src, Image_Desc *dst, int *filtre)
Image_Gray_Sorted_Points(Image_Desc *src, Image_Desc *dst, int *filtre)
{ {
int x, y, r, g, b; int x, y, r, g, b;
int foo, gris; int foo, gris;
@@ -145,13 +129,10 @@ struct sort_pixel pixels[9];
fprintf(stderr, "Image Gray Sorted Points: %p -> %p\n", src, dst); fprintf(stderr, "Image Gray Sorted Points: %p -> %p\n", src, dst);
#endif #endif
for (y=1; y<src->height-1; y++) for (y=1; y<src->height-1; y++) {
{ for (x=1; x<src->width-1; x++) {
for (x=1; x<src->width-1; x++)
{
/* collecte des infos sur les voisins. */ /* 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, Image_getRGB(src, x+deltas[foo].x, y+deltas[foo].y,
&r, &g, &b); &r, &g, &b);

View File

@@ -184,7 +184,7 @@ int dy[4] = { 0, 0, 1, 1 };
for (y=0; y<src->height-1; y+=2) { for (y=0; y<src->height-1; y+=2) {
for (x=0; x<src->width-1; x+=2) { for (x=0; x<src->width-1; x+=2) {
for (foo=0; foo<4; foo++) { for (foo=0; foo<4; foo++) {
bar = (foo+rot)%4; bar = (foo+rot)%4; /* XXX ? */
r = (src->Rpix[y+dy[foo]])[x+dx[foo]]; r = (src->Rpix[y+dy[foo]])[x+dx[foo]];
g = (src->Gpix[y+dy[foo]])[x+dx[foo]]; g = (src->Gpix[y+dy[foo]])[x+dx[foo]];
b = (src->Bpix[y+dy[foo]])[x+dx[foo]]; b = (src->Bpix[y+dy[foo]])[x+dx[foo]];
@@ -198,25 +198,4 @@ for (y=0; y<src->height-1; y+=2) {
return FUNC_IS_BETA; 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)) ) {
fprintf(stderr, "%s: err compare %d\n", __func__, foo);
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;
}
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/

View File

@@ -5,8 +5,8 @@
25 Aout 1999: certaines fonctions utilisent 'alloca'. 25 Aout 1999: certaines fonctions utilisent 'alloca'.
4 Fevrier 2001: je me rend compte que certaines interfaces sont trop 4 Fevrier 2001: je me rend compte que certaines interfaces sont trop
simplistes, et que définir des structures contenant de multiples simplistes, et que definir des structures contenant de multiples
paramètres ne serait peut-être pas une mauvaise idée... parametres ne serait peut-etre pas une mauvaise idee...
16 Oct 2001: je deplace quelques fonctions dans d'autres modules. 16 Oct 2001: je deplace quelques fonctions dans d'autres modules.
@@ -132,7 +132,7 @@ return FUNC_IS_BETA;
} }
/* /*
* p'taing, c'est tellement crade qu'il faut: * 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 !... * 2) la virer illico !...
*/ */
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
@@ -167,9 +167,9 @@ if ( (foo=Image_compare_desc(src, dst)) ) {
if((histr=(long *)alloca(256*sizeof(long))) == NULL) return BUFFER_NO_MEM; if((histr=(long *)alloca(256*sizeof(long))) == NULL) return BUFFER_NO_MEM;
if((histg=(long *)alloca(256*sizeof(long))) == NULL) return BUFFER_NO_MEM; if((histg=(long *)alloca(256*sizeof(long))) == NULL) return BUFFER_NO_MEM;
if((histb=(long *)alloca(256*sizeof(long))) == NULL) return BUFFER_NO_MEM; if((histb=(long *)alloca(256*sizeof(long))) == NULL) return BUFFER_NO_MEM;
if((cumlr=(int *)alloca(256*sizeof(int))) == NULL) return BUFFER_NO_MEM; if((cumlr=(int *)alloca(256*sizeof(int))) == NULL) return BUFFER_NO_MEM;
if((cumlg=(int *)alloca(256*sizeof(int))) == NULL) return BUFFER_NO_MEM; if((cumlg=(int *)alloca(256*sizeof(int))) == NULL) return BUFFER_NO_MEM;
if((cumlb=(int *)alloca(256*sizeof(int))) == NULL) return BUFFER_NO_MEM; if((cumlb=(int *)alloca(256*sizeof(int))) == NULL) return BUFFER_NO_MEM;
Image_histo_RGB(src, histr, histg, histb); Image_histo_RGB(src, histr, histg, histb);

View File

@@ -18,12 +18,14 @@
* Les colors maps sont censees etre compatible avec celles * Les colors maps sont censees etre compatible avec celles
* de FRACTINT, mais il faudrait verifier. * de FRACTINT, mais il faudrait verifier.
*/ */
int int Image_save_color_Map(char *file, char *name, RGB_map *map)
Image_save_color_Map(char *file, char *name, RGB_map *map)
{ {
int foo; int foo;
FILE *fp; FILE *fp;
fprintf(stderr, ">>> %s ( '%s' '%s' %p )\n", __func__,
file, name, map);
if ( (fp=fopen(file, "w")) == NULL ) { if ( (fp=fopen(file, "w")) == NULL ) {
fprintf(stderr, "Save Color Map: err fopen\n"); fprintf(stderr, "Save Color Map: err fopen\n");
return FILE_CREATE_ERR; return FILE_CREATE_ERR;
@@ -74,22 +76,26 @@ return OLL_KORRECT;
* What is the 'right thing' to do when we get more than * What is the 'right thing' to do when we get more than
* 256 lines of data ? return an error ? * 256 lines of data ? return an error ?
*/ */
int int Image_load_color_Map(char *file, char *name, RGB_map *where)
Image_load_color_Map(char *file, char *name, RGB_map *where)
{ {
FILE *fp; FILE *fp;
int nbre, r, g, b, foo, errcode; int nbre, r, g, b, foo, errcode;
char buffer[256]; char buffer[256];
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' '%s' %p )\n", __func__,
file, name, where);
#endif
if ( name != NULL ) { if ( name != NULL ) {
if (strlen(name)>IMG_OBJNAME_LEN) return STRING_TOO_LONG; if (strlen(name)>IMG_OBJNAME_LEN) return STRING_TOO_LONG;
strcpy(where->name, name); 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 * patch du 11 Decembre 2001: on utilise une fonction qui recherche le
* fichier dans differents endroits. Cf 'mustopen.c' pour + de détails. * fichier dans differents endroits. Cf 'mustopen.c' pour + de details.
*/ */
if ((fp=Image_must_fopen(file, "r", 0)) == NULL) { if ((fp=Image_must_fopen(file, "r", 0)) == NULL) {
/* safety poke */ /* safety poke */
@@ -128,13 +134,12 @@ return errcode;
* *
* XXX voir aussi indexcol.x XXX * XXX voir aussi indexcol.x XXX
*/ */
int int Image_attach_Map(Image_Desc *im, char *nom_map, int flags)
Image_attach_Map(Image_Desc *im, char *nom_map, int flags)
{ {
RGB_map map; RGB_map map;
int foo; 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); foo = Image_load_color_Map(nom_map, "", &map);
if (foo == 0) { if (foo == 0) {
fprintf(stderr, "Attach Map: foo is zero ?\n"); fprintf(stderr, "Attach Map: foo is zero ?\n");
@@ -145,8 +150,7 @@ return FUNC_NOT_FINISH;
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* new 31 Juillet 2000 */ /* new 31 Juillet 2000 */
int int Image_make_random_Map(char *nom, RGB_map *map, int nbre)
Image_make_random_Map(char *nom, RGB_map *map, int nbre)
{ {
int foo; int foo;
@@ -170,8 +174,7 @@ return OLL_KORRECT;
/* 21 Sept 2000 /* 21 Sept 2000
Make a 2x2x2 color palette. Make a 2x2x2 color palette.
*/ */
int int Image_make_222_Map(char *nom, RGB_map *map, int noise)
Image_make_222_Map(char *nom, RGB_map *map, int noise)
{ {
int foo, r, g, b; int foo, r, g, b;
@@ -200,13 +203,12 @@ return OLL_KORRECT;
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* 15 Mai 2001 /* 15 Mai 2001
* A big classic: the three-sinus color map. * A big classic: the three-sinus color map.
* paramètres: * parametres:
* 0,1,2 R,G,B period * 0,1,2 R,G,B period
* 3,4,5 R,G,B phase * 3,4,5 R,G,B phase
* 6,7 reserved * 6,7 reserved
*/ */
int int Image_palette_3sinus(char *nom, RGB_map *ou, double pars[8])
Image_palette_3sinus(char *nom, RGB_map *ou, double pars[8])
{ {
int foo; int foo;
double dfoo, dra, dga, dba; double dfoo, dra, dga, dba;
@@ -235,8 +237,7 @@ return FUNC_IS_BETA;
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* new 18 Dec 2001 /* new 18 Dec 2001
*/ */
int int Image_mix_palettes(RGB_map *p1, RGB_map *p2, RGB_map *d, char *txt, int k)
Image_mix_palettes(RGB_map *p1, RGB_map *p2, RGB_map *d, char *txt, int k)
{ {
int idx, k2; int idx, k2;
int r1, g1, b1, r2, g2, b2; int r1, g1, b1, r2, g2, b2;
@@ -248,8 +249,7 @@ fprintf(stderr, "Image mix palette: work in progress...\n");
k2 = 10000 - k; k2 = 10000 - k;
for (idx=0; idx<256; idx++) { for (idx=0; idx<256; idx++) {
if (idx < p1->nbre) if (idx < p1->nbre) {
{
r1 = p1->red[idx]; r1 = p1->red[idx];
g1 = p1->green[idx]; g1 = p1->green[idx];
b1 = p1->blue[idx]; b1 = p1->blue[idx];
@@ -284,7 +284,7 @@ return FUNC_IS_BETA;
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* new 01 aout 2008 */ /* new 01 aout 2008 */
/* XXX HACK XXX */ /* XXX HACK XXX */ /* please explain ! */
double round(double); double round(double);
/* XXX HACK XXX */ /* XXX HACK XXX */
@@ -302,9 +302,9 @@ if (p->nbre < 1 || p->nbre > 256) {
} }
for (foo=0; foo<p->nbre; foo++) { for (foo=0; foo<p->nbre; foo++) {
p->red[foo] = round((double)p->red[foo] * v); p->red[foo] = round((double)p->red[foo] * v);
p->green[foo] = round((double)p->green[foo] * v); p->green[foo] = round((double)p->green[foo] * v);
p->blue[foo] = round((double)p->blue[foo] * v); p->blue[foo] = round((double)p->blue[foo] * v);
if (clip_it) { if (clip_it) {
if (p->red[foo] < 0) p->red[foo] = 0; if (p->red[foo] < 0) p->red[foo] = 0;
if (p->red[foo] > 255) p->red[foo] = 255; if (p->red[foo] > 255) p->red[foo] = 255;
@@ -394,6 +394,6 @@ for (foo=0; foo<p->nbre; foo++) {
fclose(fp); fclose(fp);
return FULL_NUCKED; return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/

View File

@@ -9,8 +9,7 @@
#include "../tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_pattern_000(Image_Desc *img, int foo)
Image_pattern_000(Image_Desc *img, int foo)
{ {
int x, y, xx, yy, r, g, b; 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); fprintf(stderr, "%s : foo = %d\n", __func__, foo);
#endif #endif
for (x=0; x<img->width; x++) for (x=0; x<img->width; x++) {
{
xx = (x * 256) / img->width; xx = (x * 256) / img->width;
for (y=0; y<img->height; y++) for (y=0; y<img->height; y++) {
{
yy = (y * 256) / img->height; yy = (y * 256) / img->height;
r = xx & yy & foo; r = xx & yy & foo;
g = ((xx * yy) & 0xf8 ); g = ((xx * yy) & 0xf8 );
@@ -37,8 +34,7 @@ for (x=0; x<img->width; x++)
return FUNC_IS_BETA; return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_pattern_001(Image_Desc *img, int foo)
Image_pattern_001(Image_Desc *img, int foo)
{ {
int x, y; int x, y;
@@ -50,11 +46,10 @@ for (x=0; x<img->width; x++)
for (y=0; y<img->height; y++) for (y=0; y<img->height; y++)
Image_plotRGB(img, x, y, x^y^foo, (x*y)>>4, x&y); Image_plotRGB(img, x, y, x^y^foo, (x*y)>>4, x&y);
return FUNC_NOT_FINISH; return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_pattern_002(Image_Desc *img, int foo)
Image_pattern_002(Image_Desc *img, int foo)
{ {
int x, y, x2, y2; int x, y, x2, y2;
@@ -62,11 +57,9 @@ int x, y, x2, y2;
fprintf(stderr, "Pattern 002: %d\n", foo); fprintf(stderr, "Pattern 002: %d\n", foo);
#endif #endif
for (x=0; x<img->width; x++) for (x=0; x<img->width; x++) {
{
x2 = (x * 256) / img->width; x2 = (x * 256) / img->width;
for (y=0; y<img->height; y++) for (y=0; y<img->height; y++) {
{
y2 = (y * 256) / img->height; y2 = (y * 256) / img->height;
Image_plotRGB(img, x, y, (x2/2)&(y2/2)&foo, (x2*y2)>>3, x2^y2); 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; return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_pattern_003(Image_Desc *img, int foo)
Image_pattern_003(Image_Desc *img, int foo)
{ {
int x, x2, y, y2; int x, x2, y, y2;
@@ -85,11 +77,9 @@ fprintf(stderr, "Pattern 003: foo is %d\n", foo);
#endif #endif
/* added some ugly code the 28 february 2008 */ /* 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; x2 = (x * 256) / img->width;
for (y=0; y<img->height; y++) for (y=0; y<img->height; y++) {
{
y2 = (y * 256) / img->height; y2 = (y * 256) / img->height;
Image_plotRGB(img, x, y, (x2/4)&(y2/4)&foo, (x2*y2)>>5, x2^y2); 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; return FUNC_NOT_FINISH;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_pattern_004(Image_Desc *img, int a, int b, int c, int d)
Image_pattern_004(Image_Desc *img, int a, int b, int c, int d)
{ {
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "Pattern 004: %d, %d, %d, %d\n", a, b, c, d); fprintf(stderr, "Pattern 004: %d, %d, %d, %d\n", a, b, c, d);
@@ -122,11 +111,9 @@ if (NULL == map) {
return NULL_POINTER; return NULL_POINTER;
} }
for (y=0; y<img->height; y++) for (y=0; y<img->height; y++) {
{
fy = (double)y; fy = (double)y;
for (x=0; x<img->width; x++) for (x=0; x<img->width; x++) {
{
fx = (double)x; fx = (double)x;
idx = (int)(127.0+(sin(fx)*cos(fy)*254.99)); 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; return FUNC_NOT_FINISH;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_pattern_042(Image_Desc *img, int foo)
Image_pattern_042(Image_Desc *img, int foo)
{ {
int x, y, r, g, b; int x, y, r, g, b;
@@ -150,10 +136,8 @@ fprintf(stderr, "Pattern 042: threshold level is %d\n", foo);
#endif #endif
r = g = b = 42; r = g = b = 42;
for (x=0; x<img->width; x++) for (x=0; x<img->width; x++) {
{ for (y=0; y<img->height; y++) {
for (y=0; y<img->height; y++)
{
r += rand() % 4; r += rand() % 4;
if (r > foo) r = 0; if (r > foo) r = 0;

View File

@@ -16,15 +16,15 @@
/* /*
* c'est quasiment impossible de documenter cette fonction. * c'est quasiment impossible de documenter cette fonction.
*/ */
int int Image_pattern_100(Image_Desc *dst, int kr, int kg, int kb)
Image_pattern_100(Image_Desc *dst, int kr, int kg, int kb)
{ {
int x, y, r,g, b; int x, y, r,g, b;
for (x=0; x<dst->width; x++) fprintf(stderr, ">>> %s ( %p %d %d %d )\n", __func__,
{ dst, kr, kg, kb);
for (y=0; y<dst->height; y++)
{ for (x=0; x<dst->width; x++) {
for (y=0; y<dst->height; y++) {
r = abs(x+y-(dst->width/3)) * kr; r = abs(x+y-(dst->width/3)) * kr;
g = abs(x-y-(dst->height/3)) * kg; g = abs(x-y-(dst->height/3)) * kg;
b = (rand() % 42) + kb; b = (rand() % 42) + kb;
@@ -36,19 +36,19 @@ for (x=0; x<dst->width; x++)
return FUNC_IS_BETA; return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_pattern_101(Image_Desc *dst, int kr, int kg, int kb)
Image_pattern_101(Image_Desc *dst, int kr, int kg, int kb)
{ {
int x, y, r,g, b; 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 (kr == 0) kr = 1;
if (kg == 0) kg = 1; if (kg == 0) kg = 1;
if (kb == 0) kb = 1; if (kb == 0) kb = 1;
for (x=0; x<dst->width; x++) for (x=0; x<dst->width; x++) {
{ for (y=0; y<dst->height; y++) {
for (y=0; y<dst->height; y++)
{
if (x < dst->width/2) if (x < dst->width/2)
{ r=x/kr; g=y/kg; b=x/kb; } { r=x/kr; g=y/kg; b=x/kb; }
else else
@@ -59,18 +59,15 @@ for (x=0; x<dst->width; x++)
return FUNC_IS_BETA; return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_pattern_102(Image_Desc *dst, int param, int kr, int kg, int kb)
Image_pattern_102(Image_Desc *dst, int param, int kr, int kg, int kb)
{ {
int x, y, r,g, b; int x, y, r,g, b;
for (x=0; x<dst->width; x++) for (x=0; x<dst->width; x++) {
{ for (y=0; y<dst->height; y++) {
for (y=0; y<dst->height; y++)
{
r = x ^ kr; r = x ^ kr;
g = y ^ kg; g = y ^ kg;
b = (x+y) ^ kb; b = (x+y+param) ^ kb;
Image_plotRGB(dst, x, y, r, g, b); 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... /* hop, 31 mars 2008, une petite evolution stochastique de base...
* */ * */
int int Image_pattern_103(Image_Desc *dst, int param, int kr, int kg, int kb)
Image_pattern_103(Image_Desc *dst, int param, int kr, int kg, int kb)
{ {
int x, y, r, g, b; int x, y, r, g, b;
long surface;
double dx, dy; double dx, dy;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s: acting on image %p\n", __func__, dst); fprintf(stderr, "%s: acting on image %p\n", __func__, dst);
#endif #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; 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; 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; g = b = rand() & 0xf0;
Image_plotRGB(dst, x, y, r, g, b); Image_plotRGB(dst, x, y, r, g, b);
} }

View File

@@ -23,6 +23,12 @@ int x, y, v, delta;
delta = high - low; 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 (x=0; x<dst->width; x++)
{ {
for (y=0; y<dst->height; y++) for (y=0; y<dst->height; y++)
@@ -44,6 +50,12 @@ int x, y, r, g, b, delta;
delta = high - low; 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 (x=0; x<dst->width; x++)
{ {
for (y=0; y<dst->height; y++) for (y=0; y<dst->height; y++)

View File

@@ -22,7 +22,7 @@
#define DEBUG_LEVEL 1 #define DEBUG_LEVEL 1
#endif #endif
#include "tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
#define LIBPCX_VERSION "0.0.12" #define LIBPCX_VERSION "0.0.12"

View File

@@ -27,6 +27,8 @@ return FULL_NUCKED;
int Image_rot_pixel(Image_Desc *img, int x, int y, int r, int g, int b) 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) ) if ( (x<0) || (y<0) || (x>=img->width) || (y>=img->height) )
{ {
fprintf(stderr, "%s : out of pic (%d, %d)\n", __func__, x, y); fprintf(stderr, "%s : out of pic (%d, %d)\n", __func__, x, y);

View File

@@ -13,7 +13,7 @@
#include "../tthimage.h" #include "../tthimage.h"
#define SOMBRE 26 /* pourquoi ces valeurs sont codées en */ #define SOMBRE 26 /* pourquoi ces valeurs sont codees en */
#define CLAIR 242 /* dur ? et ~/.tth/libimagerc alors ? */ #define CLAIR 242 /* dur ? et ~/.tth/libimagerc alors ? */
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
@@ -30,18 +30,16 @@ for (foo=bas; foo<=haut; foo++)
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* new 20 mars 2002 /* new 20 mars 2002
*/ */
int int Image_plot_luts(char *nomtga, int *lr, int *lg, int *lb, char *texte)
Image_plot_luts(char *nomtga, int *lr, int *lg, int *lb, char *texte)
{ {
Image_Desc *img; Image_Desc *img;
int foo; int foo;
RGBA paper, ink; RGBA paper, ink;
int vr, vg, vb, ovr, ovg, ovb; int vr, vg, vb, ovr, ovg, ovb;
if ( (img = Image_alloc(400, 300, 3)) == NULL ) if ( (img = Image_alloc(400, 300, 3)) == NULL ) {
{
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "Plot Luts: alloc of img failed, file=%s\n", nomtga); fprintf(stderr, "%s: alloc of img failed, file=%s\n", __func__, nomtga);
#endif #endif
return IMAGE_NO_MEM; return IMAGE_NO_MEM;
} }
@@ -138,13 +136,13 @@ fprintf(stderr, "taille txt %d\n", strlen(txt));
Image_trace_chaine_1(img, txt, 5, 5, "libimage.fonte", &paper, &ink); Image_trace_chaine_1(img, txt, 5, 5, "libimage.fonte", &paper, &ink);
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL > 1
fprintf(stderr, "[%s] tracée...\n", txt); fprintf(stderr, "[%s] drawed...\n", txt);
#endif #endif
sprintf(chaine, "max rgb = %ld", maxhisto); sprintf(chaine, "max rgb = %ld", maxhisto);
Image_trace_chaine_1(img, chaine, 5, 15, NULL, &paper, &ink); Image_trace_chaine_1(img, chaine, 5, 15, NULL, &paper, &ink);
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL > 1
fprintf(stderr, "[%s] tracée...\n", chaine); fprintf(stderr, "[%s] drawed...\n", chaine);
#endif #endif
Image_cadre_A(img); Image_cadre_A(img);
@@ -177,8 +175,7 @@ return FUNC_IS_BETA;
* fabrique dans une image une petite bande a partir d'une palette * fabrique dans une image une petite bande a partir d'une palette
* cette bande est horizontale. * cette bande est horizontale.
*/ */
int int Image_plot_h_Map(Image_Desc *img, RGB_map *map, int xpos, int ypos, int h)
Image_plot_h_Map(Image_Desc *img, RGB_map *map, int xpos, int ypos, int h)
{ {
int x, y, v; int x, y, v;
@@ -212,15 +209,12 @@ return FUNC_IS_BETA;
* fabrique dans une image une petite bande a partir d'une palette * fabrique dans une image une petite bande a partir d'une palette
* cette bande est verticale. * cette bande est verticale.
*/ */
int int Image_plot_v_Map(Image_Desc *img, RGB_map *map, int xpos, int ypos, int l)
Image_plot_v_Map(Image_Desc *img, RGB_map *map, int xpos, int ypos, int l)
{ {
int x, y, v; int x, y, v;
for (y=0; y<256; y++) for (y=0; y<256; y++) {
{ for (x=0; x<l; x++) {
for (x=0; x<l; x++)
{
if ( ((y>>2)+(x>>2)) & 1) v = SOMBRE; if ( ((y>>2)+(x>>2)) & 1) v = SOMBRE;
else v = CLAIR; else v = CLAIR;
Image_plotRGB(img, x+xpos, y+ypos, v, v, v); Image_plotRGB(img, x+xpos, y+ypos, v, v, v);
@@ -247,8 +241,7 @@ return FUNC_IS_BETA;
* fabrique une petite TGA horizontale avec une palette dedans * fabrique une petite TGA horizontale avec une palette dedans
*/ */
#define LITTLE_DIM 42 #define LITTLE_DIM 42
int int Image_plot_little_h_Map(char *nom, RGB_map *map, char *texte)
Image_plot_little_h_Map(char *nom, RGB_map *map, char *texte)
{ {
Image_Desc *img; Image_Desc *img;
int foo; int foo;
@@ -276,11 +269,10 @@ return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
* 20 Février 2002. * 20 Fevrier 2002.
* fabrique une petite TGA verticale avec une palette dedans * fabrique une petite TGA verticale avec une palette dedans
*/ */
int int Image_plot_little_v_Map(char *nom, RGB_map *map, char *texte)
Image_plot_little_v_Map(char *nom, RGB_map *map, char *texte)
{ {
Image_Desc *img; Image_Desc *img;
int foo; int foo;
@@ -306,8 +298,7 @@ return FUNC_IS_BETA;
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* new 2 decembre 2009 - ave St Exupery /* new 2 decembre 2009 - ave St Exupery
*/ */
int int Image_plot_square_Map(char *fname, RGB_map *map, char *texte, int k)
Image_plot_square_Map(char *fname, RGB_map *map, char *texte, int k)
{ {
int x, y, foo; int x, y, foo;
int r, g, b; int r, g, b;
@@ -320,10 +311,9 @@ fprintf(stderr, "%s ( '%s' %p '%s' %d )\n", __func__,
fname, map, texte, k); fname, map, texte, k);
#endif #endif
if ( (img = Image_alloc(512, 512, 3)) == NULL ) if ( (img = Image_alloc(512, 512, 3)) == NULL ) {
{
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "Plot MAP: alloc of img failed, file=%s\n", fname); fprintf(stderr, "%s: alloc of img failed, file=%s\n", __func__, fname);
#endif #endif
return IMAGE_NO_MEM; return IMAGE_NO_MEM;
} }
@@ -332,8 +322,7 @@ Image_clear(img, 0, 0, 0);
rect.h = rect.w = 31; rect.h = rect.w = 31;
for (foo=0; foo<256; foo++) for (foo=0; foo<256; foo++) {
{
x = ( foo & 0x0f ) * 32; x = ( foo & 0x0f ) * 32;
y = ( foo & 0xf0 ) * 2; y = ( foo & 0xf0 ) * 2;
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL > 1
@@ -343,8 +332,7 @@ for (foo=0; foo<256; foo++)
rect.x = x; rect.x = x;
rect.y = y; rect.y = y;
if (foo < map->nbre) if (foo < map->nbre) {
{
r = map->red[foo]; r = map->red[foo];
g = map->green[foo]; g = map->green[foo];
b = map->blue[foo]; b = map->blue[foo];
@@ -353,11 +341,7 @@ for (foo=0; foo<256; foo++)
#endif #endif
Image_paint_rect(img, &rect, r, g, b); Image_paint_rect(img, &rect, r, g, b);
} }
else /* on est au dela de la fin de la palette */ else { /* on est au dela de la fin de la palette */
{
#if DEBUG_LEVEL > 1
printf(" xxx\n");
#endif
/* Image_gadrct_Hsweep_0(img, &rect, 0); */ /* Image_gadrct_Hsweep_0(img, &rect, 0); */
Image_gadrct_cross(img, &rect, 0); Image_gadrct_cross(img, &rect, 0);
} }
@@ -386,17 +370,14 @@ Image_Rect rect;
if ( (img = Image_alloc(400, 300, 3)) == NULL ) if ( (img = Image_alloc(400, 300, 3)) == NULL )
{ {
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "Plot MAP: alloc of img failed, file=%s\n", nomtga); fprintf(stderr, "%s: alloc of img failed, file=%s\n", __func__, nomtga);
#endif #endif
return IMAGE_NO_MEM; return IMAGE_NO_MEM;
} }
Image_clear(img, SOMBRE, SOMBRE, SOMBRE); Image_clear(img, SOMBRE, SOMBRE, SOMBRE);
for (foo=0; foo<map->nbre; foo++) {
for (foo=0; foo<map->nbre; foo++)
{
Image_plotRGB(img, foo+90, 120, 255, 255, 255); Image_plotRGB(img, foo+90, 120, 255, 255, 255);
Image_plotRGB(img, foo+90, 200, 255, 255, 255); Image_plotRGB(img, foo+90, 200, 255, 255, 255);
Image_plotRGB(img, foo+90, 280, 255, 255, 255); Image_plotRGB(img, foo+90, 280, 255, 255, 255);
@@ -414,10 +395,8 @@ Image_draw_rect(img, &rect, CLAIR/2, CLAIR/2, CLAIR/2);
fprintf(stderr, "Plot MAP: the text is '%s'\n", txt); fprintf(stderr, "Plot MAP: the text is '%s'\n", txt);
#endif #endif
for (foo=0; foo<map->nbre; foo++) for (foo=0; foo<map->nbre; foo++) {
{ for (x=21; x<50; x++) {
for (x=21; x<50; x++)
{
Image_plotRGB(img, x, foo+31, Image_plotRGB(img, x, foo+31,
map->red[foo], map->green[foo], map->blue[foo]); map->red[foo], map->green[foo], map->blue[foo]);
} }
@@ -427,7 +406,7 @@ paper.r = paper.b = paper.g = SOMBRE; paper.a = 0;
ink.r = ink.b = ink.g = CLAIR; ink.a = 255; ink.r = ink.b = ink.g = CLAIR; ink.a = 255;
foo = Image_trace_chaine_1(img, txt, 15, 7, "8x8thin", &paper, &ink); foo = Image_trace_chaine_1(img, txt, 15, 7, "8x8thin", &paper, &ink);
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL > 1
fprintf(stderr, "Plot MAP: retour trace chaine = %d\n", foo); fprintf(stderr, "%s: retour trace chaine = %d\n", __func__, foo);
#endif #endif
Image_cadre_A(img); Image_cadre_A(img);
@@ -446,8 +425,7 @@ return OLL_KORRECT;
* new 23 oct 2001 * new 23 oct 2001
* parameters 'p1' and 'p2' are not used, and must be 0 ! * parameters 'p1' and 'p2' are not used, and must be 0 !
*/ */
int int Image_plot_histo_hf15(Image_Desc *img, char *nom, char *txt, int p1, int p2)
Image_plot_histo_hf15(Image_Desc *img, char *nom, char *txt, int p1, int p2)
{ {
Image_Desc *plot; Image_Desc *plot;
long *histo, maximum; long *histo, maximum;
@@ -460,49 +438,41 @@ char chaine[200];
fprintf(stderr, "%s: img %p ! work in progress !\n", __func__, img); fprintf(stderr, "%s: img %p ! work in progress !\n", __func__, img);
#endif #endif
if ( (histo=alloca(sizeof(long)*32768)) == NULL) if ( (histo=alloca(sizeof(long)*32768)) == NULL) {
{ fprintf(stderr, "%s: no mem for buffer\n", __func__);
fprintf(stderr, "Plot histo hf15: no mem for buffer\n");
#if FORCE_ABORT #if FORCE_ABORT
abort(); abort();
#endif #endif
return BUFFER_NO_MEM; return BUFFER_NO_MEM;
} }
if ( (plot = Image_alloc(800, 600, 3)) == NULL ) if ( (plot = Image_alloc(800, 600, 3)) == NULL ) {
{
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "Plot histo hf15: alloc img failed\n"); fprintf(stderr, "Plot histo hf15: alloc img failed\n");
#endif #endif
free(histo);
return IMAGE_NO_MEM; return IMAGE_NO_MEM;
} }
Image_clear(plot, SOMBRE, SOMBRE, SOMBRE); Image_clear(plot, SOMBRE, SOMBRE, SOMBRE);
for (foo=0; foo<32768; foo++) histo[foo] = 0L; for (foo=0; foo<32768; foo++) histo[foo] = 0L;
#if DEBUG_LEVEL > 1
fprintf(stderr, "Plot histo hf15: buffers allocated, computing now...\n");
#endif
epic_fail = 0; epic_fail = 0;
for (y=0; y<img->height; y++) for (y=0; y<img->height; y++) {
{ for (x=0; x<img->width; x++) {
for (x=0; x<img->width; x++)
{
h = Image_hf15_height(img, x, y); h = Image_hf15_height(img, x, y);
if (h<0 || h>32767) if (h<0 || h>32767) epic_fail++;
epic_fail++; else histo[h]++;
else
histo[h]++;
} }
} }
if (epic_fail) if (epic_fail) {
{ fprintf(stderr, "%s: %d epic fail(s) is epic\n", __func__, epic_fail);
fprintf(stderr, "%s : %d epic fail is epic\n", __func__, epic_fail);
#if FORCE_ABORT #if FORCE_ABORT
abort(); abort();
#endif #endif
free(histo);
} }
/* recherche du maximum de l'histogramme, pour faire la mise a l'echelle */ /* recherche du maximum de l'histogramme, pour faire la mise a l'echelle */
@@ -518,12 +488,10 @@ fprintf(stderr, "%s: maximum = %ld, diviseur = %g\n", __func__,
maximum, diviseur); maximum, diviseur);
h2 = 0; h2 = 0;
for (foo=0; foo<32768; foo+=4) for (foo=0; foo<32768; foo+=4) {
{
h = (int)((double)histo[foo] / diviseur); h = (int)((double)histo[foo] / diviseur);
x = (foo/64)+60; x = (foo/64)+60;
if (foo) /* pourquoi ? */ if (foo) { /* pourquoi ? */
{
vline(plot, x, 590-h, 290-h2, 'g', CLAIR); vline(plot, x, 590-h, 290-h2, 'g', CLAIR);
h2 = h; h2 = h;
} }

View File

@@ -2,7 +2,7 @@
pov_hf15e.c pov_hf15e.c
=========== ===========
opérations de morphologie mathématique appliquées operations de morphologie mathematique appliquees
aux height-fields. aux height-fields.
*/ */
@@ -18,40 +18,30 @@ static struct
int x, y; int x, y;
} off[] = } off[] =
{ {
{ -1, -1 }, { -1, -1 }, { 0, -1 }, { 1, -1 },
{ 0, -1 }, { -1, 0 }, { 0, 0 }, { 1, 0 },
{ 1, -1 }, { -1, 1 }, { 0, 1 }, { 1, 1 }
{ -1, 0 },
{ 0, 0 },
{ 1, 0 },
{ -1, 1 },
{ 0, 1 },
{ 1, 1 }
}; };
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
* le paramètre 'coef' n'est pas utilisé. D'ailleurs, je ne vois * le parametre 'coef' n'est pas utilise. D'ailleurs, je ne vois
* pas trop quoi y mettre ? * pas trop quoi y mettre ?
*/ */
int int Image_hf15_dilate(Image_Desc *src, Image_Desc *dst, int coef)
Image_hf15_dilate(Image_Desc *src, Image_Desc *dst, int coef)
{ {
(void)coef; /* KILL WARNING */
int foo; int foo;
int x, y, h, hmax; int x, y, h, hmax;
if ( (foo=Image_compare_desc(src, dst)) ) if ( (foo=Image_compare_desc(src, dst)) ) {
{
fprintf(stderr, "Image hf15 dilate: images differents %d\n", foo); fprintf(stderr, "Image hf15 dilate: images differents %d\n", foo);
return foo; return foo;
} }
for (y=1; y<dst->height-1; y++) for (y=1; y<dst->height-1; y++) {
{ for (x=1; x<dst->width-1; x++) {
for (x=1; x<dst->width-1; x++)
{
hmax = -1664; hmax = -1664;
for (foo=0; foo<9; foo++) for (foo=0; foo<9; foo++) {
{
h = Image_hf15_height(src, x+off[foo].x, y+off[foo].y); h = Image_hf15_height(src, x+off[foo].x, y+off[foo].y);
if (h > hmax) hmax = h; if (h > hmax) hmax = h;
} }
@@ -63,27 +53,23 @@ return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
* le paramètre 'coef' n'est pas utilisé. * le parametre 'coef' n'est pas utilise.
*/ */
int int Image_hf15_erode(Image_Desc *src, Image_Desc *dst, int coef)
Image_hf15_erode(Image_Desc *src, Image_Desc *dst, int coef)
{ {
(void)coef; /* KILL WARNING */
int foo; int foo;
int x, y, h, hmin; int x, y, h, hmin;
if ( (foo=Image_compare_desc(src, dst)) ) if ( (foo=Image_compare_desc(src, dst)) ) {
{
fprintf(stderr, "Image hf15 erode: images differents %d\n", foo); fprintf(stderr, "Image hf15 erode: images differents %d\n", foo);
return foo; return foo;
} }
for (y=1; y<dst->height-1; y++) for (y=1; y<dst->height-1; y++) {
{ for (x=1; x<dst->width-1; x++) {
for (x=1; x<dst->width-1; x++)
{
hmin = 42042; hmin = 42042;
for (foo=0; foo<9; foo++) for (foo=0; foo<9; foo++) {
{
h = Image_hf15_height(src, x+off[foo].x, y+off[foo].y); h = Image_hf15_height(src, x+off[foo].x, y+off[foo].y);
if (h < hmin) hmin = h; if (h < hmin) hmin = h;
} }
@@ -95,7 +81,7 @@ return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
* Et maintenant, il reste à coder le chapeau haut-de-forme * Et maintenant, il reste a coder le chapeau haut-de-forme
*/ */
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/

View File

@@ -35,11 +35,10 @@ Image_PtList * Image_ptl_alloc(int nbre, char *name)
Image_PtList *ptr; Image_PtList *ptr;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "Image PtList: alloc: %d '%s'\n", nbre, name); fprintf(stderr, ">>> %s ( %d '%s' )\n", __func__, nbre, name);
#endif #endif
if ( (ptr=malloc(sizeof(Image_PtList)))==NULL) if ( (ptr=malloc(sizeof(Image_PtList)))==NULL) {
{
fprintf(stderr, "Image PtList: struct malloc failed\n"); fprintf(stderr, "Image PtList: struct malloc failed\n");
#if FORCE_ABORT #if FORCE_ABORT
abort(); abort();
@@ -56,8 +55,7 @@ if (strlen(name) < IMG_OBJNAME_LEN)
else else
strcpy(ptr->name, "name too long"); strcpy(ptr->name, "name too long");
if ( (ptr->points=malloc(sizeof(Image_Point)*nbre))==NULL) if ( (ptr->points=malloc(sizeof(Image_Point)*nbre))==NULL) {
{
fprintf(stderr, "Image PtList: array malloc failed\n"); fprintf(stderr, "Image PtList: array malloc failed\n");
#if FORCE_ABORT #if FORCE_ABORT
abort(); abort();
@@ -80,8 +78,7 @@ fprintf(stderr, "Image PtList: addpt to %p: %5d %5d %5d %5d\n",
/* in first, we check if this is a valid point list */ /* in first, we check if this is a valid point list */
if (ptl->control != 0xfde9601a) if (ptl->control != 0xfde9601a) {
{
fprintf(stderr, "ptl addpt: invalid point list %p\n", ptl); fprintf(stderr, "ptl addpt: invalid point list %p\n", ptl);
#if FORCE_ABORT #if FORCE_ABORT
abort(); abort();
@@ -91,12 +88,10 @@ if (ptl->control != 0xfde9601a)
/* /*
* in second, we check if we have room for the new point. * in second, we check if we have room for the new point.
*/ */
if (ptl->nbre==ptl->alloc) if (ptl->nbre==ptl->alloc) {
{
newsize = ptl->alloc + 200; newsize = ptl->alloc + 200;
fprintf(stderr, "ptl: realloc array %d\n", newsize); fprintf(stderr, "ptl: realloc array %d\n", newsize);
if ((ptrpt=realloc(ptl->points, sizeof(Image_Point)*newsize))==NULL) if ((ptrpt=realloc(ptl->points, sizeof(Image_Point)*newsize))==NULL) {
{
fprintf(stderr, "%s: REALLOC FAIL\n", __func__); fprintf(stderr, "%s: REALLOC FAIL\n", __func__);
exit(5); exit(5);
} }
@@ -117,7 +112,7 @@ return FUNC_IS_BETA;
/* /*
* attention, il est _important_ de respecter le format d'écriture * attention, il est _important_ de respecter le format d'écriture
* parce que les fichiers de liste de points sont parfois relus par * parce que les fichiers de liste de points sont parfois relus par
* des programmes FORTRAN, beaucoup plus pointilleux sur le * des programmes FORTRAN 77, beaucoup plus pointilleux sur le
* formatage des données. * formatage des données.
*/ */
int Image_ptl_write(char *filename, Image_PtList *ptl) int Image_ptl_write(char *filename, Image_PtList *ptl)
@@ -125,17 +120,15 @@ int Image_ptl_write(char *filename, Image_PtList *ptl)
FILE *fp; FILE *fp;
int foo; int foo;
if ( (fp=fopen(filename, "w"))==NULL ) if ( (fp=fopen(filename, "w"))==NULL ) {
{ fprintf(stderr, "%s: write %s fopen fail.\n", __func__, filename);
fprintf(stderr, "Image PtList: write: fopen fail.\n");
return FILE_CREATE_ERR; return FILE_CREATE_ERR;
} }
fprintf(fp, "%8d\n", ptl->nbre); fprintf(fp, "%8d\n", ptl->nbre);
fprintf(fp, "%08d%08d\n", ptl->width, ptl->height); fprintf(fp, "%08d%08d\n", ptl->width, ptl->height);
fprintf(fp, "%08d%08d\n", 42, 42); /* reserved */ fprintf(fp, "%08d%08d\n", 42, 42); /* reserved */
for (foo=0; foo<ptl->nbre; foo++) for (foo=0; foo<ptl->nbre; foo++) {
{
fprintf(fp, "%8d%8d%8d%8d\n", fprintf(fp, "%8d%8d%8d%8d\n",
ptl->points[foo].x, ptl->points[foo].y, ptl->points[foo].x, ptl->points[foo].y,
ptl->points[foo].h, ptl->points[foo].c); ptl->points[foo].h, ptl->points[foo].c);
@@ -155,8 +148,7 @@ int foo;
fprintf(stderr, ">>> %s ( '%s' %p )\n", __func__, filename, ptl); fprintf(stderr, ">>> %s ( '%s' %p )\n", __func__, filename, ptl);
#endif #endif
if (ptl->control != 0xfde9601a) if (ptl->control != 0xfde9601a) {
{
fprintf(stderr, "%s: no deadbeef in %p\n", __func__, ptl); fprintf(stderr, "%s: no deadbeef in %p\n", __func__, ptl);
fprintf(stderr, " can't read '%s'\n", filename); fprintf(stderr, " can't read '%s'\n", filename);
return 666; return 666;
@@ -175,8 +167,7 @@ int Image_ptl_kill(Image_PtList *ptl, char *msg)
fprintf(stderr, "Killing point list %p for '%s'\n", ptl, msg); fprintf(stderr, "Killing point list %p for '%s'\n", ptl, msg);
#endif #endif
if (ptl->control != 0xfde9601a) if (ptl->control != 0xfde9601a) {
{
fprintf(stderr, "%s: no deadbeef in %p\n", __func__, ptl); fprintf(stderr, "%s: no deadbeef in %p\n", __func__, ptl);
return 666; return 666;
} }
@@ -198,8 +189,7 @@ return FULL_NUCKED;
int int
Image_ptl_get_size(Image_PtList *ptl, int *nbre, int *alloc) Image_ptl_get_size(Image_PtList *ptl, int *nbre, int *alloc)
{ {
if (ptl->control != 0xfde9601a) if (ptl->control != 0xfde9601a) {
{
fprintf(stderr, "%s: no deadbeef in %p\n", __func__, ptl); fprintf(stderr, "%s: no deadbeef in %p\n", __func__, ptl);
return 666; return 666;
} }
@@ -211,19 +201,16 @@ return OLL_KORRECT;
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int Image_ptl_get_point(Image_PtList *ptl, Image_Point *pt, int idx) int Image_ptl_get_point(Image_PtList *ptl, Image_Point *pt, int idx)
{ {
if (ptl->control != 0xfde9601a) if (ptl->control != 0xfde9601a) {
{
fprintf(stderr, "%s: no deadbeef in %p\n", __func__, ptl); fprintf(stderr, "%s: no deadbeef in %p\n", __func__, ptl);
return 666; return 666;
} }
if (idx < 0) if (idx < 0) {
{
fprintf(stderr, "%s:%s point idx %d is negative, so bad !\n", fprintf(stderr, "%s:%s point idx %d is negative, so bad !\n",
__FILE__, __func__, idx); __FILE__, __func__, idx);
return FULL_NUCKED; return FULL_NUCKED;
} }
if (idx>ptl->nbre) if (idx>ptl->nbre) {
{
fprintf(stderr, "%s:%s point idx %d is too big, so bad !\n", fprintf(stderr, "%s:%s point idx %d is too big, so bad !\n",
__FILE__, __func__, idx); __FILE__, __func__, idx);
return FULL_NUCKED; return FULL_NUCKED;
@@ -243,8 +230,7 @@ int Image_ptl_boundingbox(Image_PtList *ptl, Image_Rect *box)
int xmin, ymin, xmax, ymax; int xmin, ymin, xmax, ymax;
int foo; int foo;
if (ptl->control != 0xfde9601a) if (ptl->control != 0xfde9601a) {
{
fprintf(stderr, "%s: no deadbeef in %p\n", __func__, ptl); fprintf(stderr, "%s: no deadbeef in %p\n", __func__, ptl);
return 666; return 666;
} }
@@ -252,8 +238,7 @@ if (ptl->control != 0xfde9601a)
xmin = ymin = 999999999; xmin = ymin = 999999999;
xmax = ymax = -999999999; xmax = ymax = -999999999;
for (foo=0; foo<ptl->nbre; foo++) for (foo=0; foo<ptl->nbre; foo++) {
{
if (ptl->points[foo].x < xmin) xmin = ptl->points[foo].x; if (ptl->points[foo].x < xmin) xmin = ptl->points[foo].x;
if (ptl->points[foo].x > xmax) xmax = ptl->points[foo].x; if (ptl->points[foo].x > xmax) xmax = ptl->points[foo].x;
if (ptl->points[foo].y < ymin) ymin = ptl->points[foo].y; if (ptl->points[foo].y < ymin) ymin = ptl->points[foo].y;

26
Lib/readjpeg.c Normal file
View File

@@ -0,0 +1,26 @@
/*
--------- libtthimage -----------
trying to code a JPEG file reader
new Mon 26 Dec 2022 05:43:47 AM CET
*/
#include <stdio.h>
#include <jpeglib.h> /* XXX to be checked ? */
#include "../tthimage.h"
/*::------------------------------------------------------------------::*/
int try_to_read_a_jpeg_file(char *fname, Image_Desc *img)
{
fprintf(stderr, ">>> %s ( '%s' %p )\n", __func__, fname, img);
fprintf(stderr, " %s compiled %s at %s\n", __FILE__, __DATE__, __TIME__);
fprintf(stderr, " JPEG_LIB_VERSION = %d\n", JPEG_LIB_VERSION);
return FULL_NUCKED;
}
/*::------------------------------------------------------------------::*/

View File

@@ -4,6 +4,7 @@
*/ */
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#include <math.h> #include <math.h>
#include "../tthimage.h" #include "../tthimage.h"
@@ -15,6 +16,8 @@
* fait le meme genre de truc, mais en bien mieux... * fait le meme genre de truc, mais en bien mieux...
* *
*/ */
/* Private variables */
static Image_Desc *S, *D; static Image_Desc *S, *D;
static int seuil; static int seuil;
static int level, maxlevel; static int level, maxlevel;
@@ -25,7 +28,8 @@ Image_Rect rect;
int h1, h2, w1, w2, xx, yy, foo; int h1, h2, w1, w2, xx, yy, foo;
int mr, mg, mb, dr, dg, db, s; int mr, mg, mb, dr, dg, db, s;
level++; level++; /* pourquoi ? */
if (level > maxlevel) if (level > maxlevel)
maxlevel = level; maxlevel = level;
@@ -35,10 +39,16 @@ fprintf(stderr, "%5d -> %3d %3d %3d %3d\n",
#endif #endif
foo = Image_stats_zone_0(S, pRect, &mr, &mg, &mb, &dr, &dg, &db); foo = Image_stats_zone_0(S, pRect, &mr, &mg, &mb, &dr, &dg, &db);
if (foo) {
fprintf(stderr, "%s: err stat zone %d\n", __func__, foo);
exit(1);
}
s = (dr + dg + db) / 3; s = (dr + dg + db) / 3;
#if DEBUG_LEVEL > 1
printf(" %7d V %3d %3d %3d D %3d %3d %3d S %3d (%d)\n", #if 1
pRect->w*pRect->h, mr, mg, mb, dr, dg, db, s, foo); printf(" %7d V %3d %3d %3d D %3d %3d %3d S %3d\n",
pRect->w*pRect->h, mr, mg, mb, dr, dg, db, s);
#endif #endif
if ( (s < seuil) || (pRect->w < 6) || (pRect->h < 6) ) { if ( (s < seuil) || (pRect->w < 6) || (pRect->h < 6) ) {
@@ -116,6 +126,10 @@ int Image_call_recursion_0(Image_Desc *image, Image_Desc *dest, int param)
Image_Rect rect; Image_Rect rect;
int foo; int foo;
#if 1
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, image, dest, param);
#endif
rect.x = rect.y = 0; rect.x = rect.y = 0;
rect.h = image->height; rect.h = image->height;
rect.w = image->width; rect.w = image->width;
@@ -135,17 +149,7 @@ fprintf(stderr, "-> fin recursion: %d, maxlevel=%d\n", foo, maxlevel);
dest->modified = 1; dest->modified = 1;
return FUNC_IS_ALPHA; return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int
Image_call_recursion(Image_Desc *image, Image_Desc *dest, int param)
{
int foo;
fprintf(stderr, "XXX %s is obsolete XXX\n", __func__);
foo = Image_call_recursion_0(image, dest, param);
return foo;
}
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/

View File

@@ -16,25 +16,20 @@
/* /*
* horizontal lines * horizontal lines
*/ */
int int Image_rgbmask_H(Image_Desc *src, Image_Desc *dst, int gris)
Image_rgbmask_H(Image_Desc *src, Image_Desc *dst, int gris)
{ {
int foo, x, y; int foo, 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); fprintf(stderr, "%s : images are differents %d\n", __func__, foo);
return foo; return foo;
} }
Image_copy(src, dst); /* XXX pourquoi cette copie ? */ Image_copy(src, dst); /* XXX pourquoi cette copie ? */
for (y=0; y<src->height; y++) for (y=0; y<src->height; y++) {
{ for (x=0; x<src->width; x++) {
for (x=0; x<src->width; x++) switch (y%3) {
{
switch (y%3)
{
case 0: case 0:
Image_plot_channel(dst, 'r', x, y, gris); Image_plot_channel(dst, 'r', x, y, gris);
Image_plot_channel(dst, 'g', x, y, gris); Image_plot_channel(dst, 'g', x, y, gris);
@@ -57,25 +52,19 @@ return FUNC_IS_BETA;
/* /*
* vertical lines * vertical lines
*/ */
int int Image_rgbmask_V(Image_Desc *src, Image_Desc *dst, int gris)
Image_rgbmask_V(Image_Desc *src, Image_Desc *dst, int gris)
{ {
int foo, x, y; int foo, x, y;
if ( (foo=Image_compare_desc(src, dst)) ) if ( (foo=Image_compare_desc(src, dst)) ) {
{
fprintf(stderr, "Image rgbmask V: images are differents %d\n", foo); fprintf(stderr, "Image rgbmask V: images are differents %d\n", foo);
return foo; return foo;
} }
Image_copy(src, dst); Image_copy(src, dst);
for (y=0; y<src->height; y++) for (y=0; y<src->height; y++) {
{ for (x=0; x<src->width; x++) {
for (x=0; x<src->width; x++) switch (x%3) {
{
switch (x%3)
{
case 0: case 0:
Image_plot_channel(dst, 'r', x, y, gris); Image_plot_channel(dst, 'r', x, y, gris);
Image_plot_channel(dst, 'g', x, y, gris); Image_plot_channel(dst, 'g', x, y, gris);
@@ -98,26 +87,21 @@ return FUNC_IS_BETA;
/* /*
* sequential dots - _very_ dependant on image dimensions. * sequential dots - _very_ dependant on image dimensions.
*/ */
int int Image_rgbmask_2(Image_Desc *src, Image_Desc *dst, int gris)
Image_rgbmask_2(Image_Desc *src, Image_Desc *dst, int gris)
{ {
int foo, x, y; int foo, x, y;
if ( (foo=Image_compare_desc(src, dst)) ) if ( (foo=Image_compare_desc(src, dst)) ) {
{
fprintf(stderr, "Image rgbmask 2: images are differents %d\n", foo); fprintf(stderr, "Image rgbmask 2: images are differents %d\n", foo);
return foo; return foo;
} }
Image_copy(src, dst); Image_copy(src, dst);
foo = 0; foo = 0;
for (y=0; y<src->height; y++) for (y=0; y<src->height; y++) {
{ for (x=0; x<src->width; x++) {
for (x=0; x<src->width; x++)
{
foo++; foo++;
switch (foo%3) switch (foo%3) {
{
case 0: case 0:
Image_plot_channel(dst, 'r', x, y, gris); Image_plot_channel(dst, 'r', x, y, gris);
Image_plot_channel(dst, 'g', x, y, gris); Image_plot_channel(dst, 'g', x, y, gris);
@@ -140,8 +124,7 @@ return FUNC_IS_BETA;
/* /*
* random dots - VERY BAD RESULTS :( * random dots - VERY BAD RESULTS :(
*/ */
int int Image_rgbmask_R(Image_Desc *src, Image_Desc *dst, int gris)
Image_rgbmask_R(Image_Desc *src, Image_Desc *dst, int gris)
{ {
int foo, x, y; int foo, x, y;
@@ -149,20 +132,16 @@ int foo, x, y;
fprintf(stderr, "this function, %s(%d), is very buggy...\n", __func__, gris); fprintf(stderr, "this function, %s(%d), is very buggy...\n", __func__, gris);
#endif #endif
if ( (foo=Image_compare_desc(src, dst)) ) if ( (foo=Image_compare_desc(src, dst)) ) {
{
fprintf(stderr, "Image rgbmask R: images are differents %d\n", foo); fprintf(stderr, "Image rgbmask R: images are differents %d\n", foo);
return foo; return foo;
} }
Image_copy(src, dst); Image_copy(src, dst);
for (y=0; y<src->height; y++) for (y=0; y<src->height; y++) {
{ for (x=0; x<src->width; x++) {
for (x=0; x<src->width; x++)
{
foo = rand() % 3; /* mmmm pas tres bon :( */ foo = rand() % 3; /* mmmm pas tres bon :( */
switch (foo) switch (foo) {
{
case 0: case 0:
Image_plot_channel(dst, 'r', x, y, gris); Image_plot_channel(dst, 'r', x, y, gris);
Image_plot_channel(dst, 'g', x, y, gris); Image_plot_channel(dst, 'g', x, y, gris);

View File

@@ -72,6 +72,9 @@ return FUNC_IS_ALPHA;
some approximations\dots some approximations\dots
this function is PRIVATE, see 'Image_getpix_bilin' for public interface this function is PRIVATE, see 'Image_getpix_bilin' for public interface
2022 September : update in progress.
*/ */
static int getpix_bilin(Image_Desc *src, double fx, double fy, static int getpix_bilin(Image_Desc *src, double fx, double fy,
int *pr, int *pg, int *pb) int *pr, int *pg, int *pb)
@@ -125,6 +128,7 @@ if (rbb < 0.0) abort();
if (gbb < 0.0) abort(); if (gbb < 0.0) abort();
if (bbb < 0.0) abort(); if (bbb < 0.0) abort();
/* hu ho ? */
rcc = (raa * (1.0-drh)) + (rbb * drh); rcc = (raa * (1.0-drh)) + (rbb * drh);
gcc = (gaa * (1.0-drh)) + (gbb * drh); gcc = (gaa * (1.0-drh)) + (gbb * drh);
bcc = (baa * (1.0-drh)) + (bbb * drh); bcc = (baa * (1.0-drh)) + (bbb * drh);

View File

@@ -9,8 +9,7 @@
#include "../tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_filtre_Sobel_4(Image_Desc *src, Image_Desc *dst, int rotation)
Image_filtre_Sobel_4(Image_Desc *src, Image_Desc *dst, int rotation)
{ {
static int Sobel[] = static int Sobel[] =
{ {
@@ -23,6 +22,8 @@ int filtre[11], foo;
Image_Desc *tmp[4]; Image_Desc *tmp[4];
int x, y, r, g, b; int x, y, r, g, b;
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, dst,rotation);
memcpy(filtre, Sobel, 11*sizeof(int)); memcpy(filtre, Sobel, 11*sizeof(int));
for (foo=0; foo<4; foo++) { for (foo=0; foo<4; foo++) {
@@ -50,7 +51,6 @@ for (x=0; x<src->width; x++) {
dst->Bpix[y][x] = b; dst->Bpix[y][x] = b;
} }
} }
dst->modified = 1; dst->modified = 1;
for (foo=0; foo<4; foo++) { for (foo=0; foo<4; foo++) {

View File

@@ -11,11 +11,10 @@
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
* première fonction, assez primitive, mais qui marche. * premiere fonction, assez primitive, mais qui marche.
*/ */
int int Image_combine_stereo_0(Image_Desc *gauche, Image_Desc *droite,
Image_combine_stereo_0(Image_Desc *gauche, Image_Desc *droite, Image_Desc *stereo)
Image_Desc *stereo)
{ {
int x, y, foo; int x, y, foo;
int rouge, vert; int rouge, vert;
@@ -57,8 +56,7 @@ return OLL_KORRECT;
* En fait (30 janv 2008, ave StEx) au lieu de faire du Rouge/Vert * En fait (30 janv 2008, ave StEx) au lieu de faire du Rouge/Vert
* il va faire du Rouge/Bleu. A la demande de Ker2x. * il va faire du Rouge/Bleu. A la demande de Ker2x.
*/ */
int int Image_combine_stereo_1(Image_Desc *s1, Image_Desc *s2, Image_Desc *d,
Image_combine_stereo_1(Image_Desc *s1, Image_Desc *s2, Image_Desc *d,
int kr, int kg, int kb) int kr, int kg, int kb)
{ {
int x, y, foo, cumul; int x, y, foo, cumul;
@@ -99,7 +97,7 @@ return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
* Et pour celui-ci, il faudrait trouver une façon de définir * Et pour celui-ci, il faudrait trouver une maniere de definir
* les composantes pour l'image destination, afin de tenir * les composantes pour l'image destination, afin de tenir
* compte des filtres qui seront dans les lunettes... * compte des filtres qui seront dans les lunettes...
*/ */
@@ -112,6 +110,9 @@ int x, y, foo;
int rouge, vert, bleu; int rouge, vert, bleu;
XXX */ XXX */
fprintf(stderr, ">>> %s ( %p %p %p '%c' '%c' )\n", __func__,
s1, s2, d, cr, cl);
fprintf(stderr, "%s: %s missing, sorry.\n", __FILE__, __func__); fprintf(stderr, "%s: %s missing, sorry.\n", __FILE__, __func__);
return FULL_NUCKED; return FULL_NUCKED;

View File

@@ -123,13 +123,13 @@ xmax = src->width - w; ymax = src->height - h;
ox = (src->width % w) / 2; ox = (src->width % w) / 2;
oy = (src->height % h) / 2; oy = (src->height % h) / 2;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s : offsets = %d %d\n", __func__, ox, oy); fprintf(stderr, "%s : offsets = %d & %d\n", __func__, ox, oy);
#endif #endif
Image_clear(dst, grey, grey, grey); Image_clear(dst, grey, grey, grey);
for (x=ox; x<xmax; x+=w) { for (x=ox; x<(xmax-ox); x+=w) {
zone.x = x + (w/2); zone.x = x + (w/2);
for (y=oy; y<ymax; y+=h) { for (y=oy; y<(ymax-oy); y+=h) {
zone.y = y + (h/2); zone.y = y + (h/2);
r = src->Rpix[y][x] & 0xfe; r = src->Rpix[y][x] & 0xfe;
g = src->Gpix[y][x] & 0xfe; g = src->Gpix[y][x] & 0xfe;
@@ -192,7 +192,7 @@ return FULL_NUCKED;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
* new 3 jan 203 - at Mixart-Myrys * new 3 jan 2013 - at Mixart-Myrys
*/ */
int Image_TV_cplus_v1(Image_Desc *src, Image_Desc *dst, int p) int Image_TV_cplus_v1(Image_Desc *src, Image_Desc *dst, int p)
{ {
@@ -200,7 +200,7 @@ int foo;
int y, taille; int y, taille;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s ( %p %p %d )\n", __func__, src, dst, p); fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, src, dst, p);
#endif #endif
if (p <= 1) { if (p <= 1) {
@@ -218,7 +218,8 @@ taille = src->width - (abs(p*2));
fprintf(stderr, "%s: largeur %d, taille %d\n", __func__, src->width, taille); fprintf(stderr, "%s: largeur %d, taille %d\n", __func__, src->width, taille);
#endif #endif
Image_gray_noise_0(dst, 20, 60); /* make a background for left and right border's pixels */
Image_gray_noise_0(dst, 20, 90);
for (y=0; y<src->height; y++) { for (y=0; y<src->height; y++) {
switch (rand()%3) { switch (rand()%3) {

View File

@@ -77,7 +77,7 @@ return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* new 8 jan 2002 /* new 8 jan 2002
* le paramètre 'yo' ne sert à rien et doit être mis à 0 * le parametre 'yo' ne sert a rien et doit etre mis a 0
*/ */
int Image_TV_gruud(Image_Desc *src, Image_Desc *dst, int yo) int Image_TV_gruud(Image_Desc *src, Image_Desc *dst, int yo)
{ {
@@ -123,7 +123,7 @@ return FUNC_IS_BETA;
#define GRIIIZ_SIZE 20 #define GRIIIZ_SIZE 20
/* /*
* le paramètre 'yo' ne sert à rien et doit être mis à 0 * le parametre 'yo' ne sert e rien et doit etre mis a 0
*/ */
int Image_TV_griiiz(Image_Desc *src, Image_Desc *dst, int yo) int Image_TV_griiiz(Image_Desc *src, Image_Desc *dst, int yo)
{ {

View File

@@ -19,6 +19,8 @@ int w;
Image_Desc *img; Image_Desc *img;
char filename[100], chaine[110]; char filename[100], chaine[110];
fprintf(stderr, "k is %d in %s\n", k, __func__);
Image_load_fnt8x8("libimage.fonte", NULL, 0); Image_load_fnt8x8("libimage.fonte", NULL, 0);
for (w=160; w<180; w++) for (w=160; w<180; w++)

View File

@@ -15,18 +15,33 @@
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int test_du_jpeg_reader(char *filename)
{
Image_Desc destimg;
int foo;
fprintf(stderr, ">>> %s ( '%s' ) \n", __func__, filename);
#if 0
foo = try_to_read_a_jpeg_file(filename, &destimg);
#endif
return FULL_NUCKED;
}
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
char *fichier; char *fichier;
int foo; int foo, idx;
printf("\n========== TestTga %s %s ==========\n", __DATE__, __TIME__); printf("\n========== TestTga %s %s ==========\n", __DATE__, __TIME__);
Image_print_version(2); Image_print_version(2);
/* Image_print_sizeof_structs("tth was here"); */
if (argc != 2) #if DEBUG_LEVEL
{ Image_print_sizeof_structs("tth was here");
#endif
if (argc != 2) {
printf("no args, using the testfile\n"); printf("no args, using the testfile\n");
fichier = "wou.tga"; fichier = "wou.tga";
} }
@@ -38,15 +53,37 @@ else
Image_start_chrono("Essai", 0); Image_start_chrono("Essai", 0);
for (idx=0; idx<10; idx++) {
foo = Test_Egalisations(fichier, 0);
fprintf(stderr, " essai egalisation -> %d\n", foo);
foo = Essai_Televisions(fichier, 10);
fprintf(stderr, " essai televisions -> %d\n", foo);
foo = Test_Dithering(fichier, 0);
fprintf(stderr, " essai dithering -> %d\n", foo);
foo = Test_des_filtres(fichier, 0);
fprintf(stderr, " essai filtres -> %d\n", foo);
foo = Test_RGBmask(fichier);
fprintf(stderr, " essai rgb mask -> %d\n", foo);
foo = Test_Classif(fichier, 0);
fprintf(stderr, " essai classif -> %d\n", foo);
foo = Test_des_warpings(fichier, 0);
fprintf(stderr, " essai warping -> %d\n", foo);
foo = Essai_color_2_map(fichier, idx);
fprintf(stderr, " essai col2map -> %d\n", foo);
foo = Test_Dithering(fichier, 17);
fprintf(stderr, "essai dithering -> %d\n", foo); fprintf(stderr, "\n*************** %s: fin passe %d ******\n\n",
argv[0], idx);
}
#if 0 #if 0
/*
foo = test_du_jpeg_reader("in.jpeg");
fprintf(stderr, " essai lecture jpeg -> %d\n", foo);
Test_des_patterns("/tmp/pattt", 0, 0); Test_des_patterns("/tmp/pattt", 0, 0);
foo = Essai_des_jauges(fichier, 17); foo = Essai_des_jauges(fichier, 17);
*/
foo = Essai_Extractbits(fichier, 17); foo = Essai_Extractbits(fichier, 17);
@@ -59,6 +96,7 @@ Test_des_warpings(fichier, 17);
foo = Essai_des_Combines(fichier, 17); foo = Essai_des_Combines(fichier, 17);
fprintf(stderr, "essai combine -> %d\n", foo); fprintf(stderr, "essai combine -> %d\n", foo);
foo = Test_Dithering(fichier, 17); foo = Test_Dithering(fichier, 17);
Essai_des_Contrastes(fichier, 0); Essai_des_Contrastes(fichier, 0);

View File

@@ -35,7 +35,7 @@ int Image_load_fnt8x8(char *nomfnt, uint8_t *ou, int flags)
{ {
int fd, foo; int fd, foo;
#if DEBUG_LEVEL > -1 #if DEBUG_LEVEL > 1
fprintf(stderr, ">>> %s ( '%s' %p %d )\n", __func__, nomfnt, ou, flags); fprintf(stderr, ">>> %s ( '%s' %p %d )\n", __func__, nomfnt, ou, flags);
#endif #endif
@@ -47,7 +47,9 @@ if (0 != flags)
/* patch du 24 septembre 2015 */ /* patch du 24 septembre 2015 */
if (NULL == nomfnt) { if (NULL == nomfnt) {
nomfnt = "libimage.fonte"; nomfnt = "libimage.fonte";
fprintf(stderr, "%s : using default font '%s'\n", __func__, nomfnt); #if DEBUG_LEVEL
fprintf(stderr, " using default font '%s'\n", nomfnt);
#endif
} }
/* on pourrait aussi mettre la fonte par ddefaut dans l'environ */ /* on pourrait aussi mettre la fonte par ddefaut dans l'environ */
@@ -56,6 +58,10 @@ if ( (fd=Image_must_open(nomfnt, O_RDONLY, 0)) < 0 ) {
exit(5); exit(5);
} }
/*
* Maybe add a check on the size of the file ?
*/
foo = read(fd, priv_fonte, T_FONTE); foo = read(fd, priv_fonte, T_FONTE);
if ( foo != T_FONTE ) { if ( foo != T_FONTE ) {
fprintf(stderr, "%s: read only %d bytes from font file\n", __func__, foo); fprintf(stderr, "%s: read only %d bytes from font file\n", __func__, foo);
@@ -67,6 +73,8 @@ close(fd);
fprintf(stderr, "%s : font '%s' loaded\n", __func__, nomfnt); fprintf(stderr, "%s : font '%s' loaded\n", __func__, nomfnt);
#endif #endif
font_is_loaded = 1;
return OLL_KORRECT; return OLL_KORRECT;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
@@ -154,6 +162,7 @@ int foo;
fprintf(stderr, "THE FUNCTION '%s' IS OBSOLETE\n", __func__); fprintf(stderr, "THE FUNCTION '%s' IS OBSOLETE\n", __func__);
if (0 != flags) if (0 != flags)
fprintf(stderr, "in %s, 'flags' (%d) must be 0\n", __func__, flags); fprintf(stderr, "in %s, 'flags' (%d) must be 0\n", __func__, flags);
foo = Image_trace_chaine_1(im, txt, x, y, "libimage.fonte", paper, ink); foo = Image_trace_chaine_1(im, txt, x, y, "libimage.fonte", paper, ink);
return foo; return foo;
@@ -171,9 +180,14 @@ int posx, posy, t_texte, foo;
int octet; int octet;
uint8_t *ptrtxt; uint8_t *ptrtxt;
RGBA blanc = { 255, 255, 255, 255, 0, 0 }; RGBA blanc = { 255, 255, 255, 255, 0, 0 };
RGBA noir = { 0, 0, 0, 64, 0, 0 }; RGBA noir = { 0, 0, 0, 64, 0, 0 };
if (nomfonte==NULL) { #if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p '%s' %d %d '%s' %p %p\n", __func__,
im, txt, x, y, nomfonte, paper, ink);
#endif
if (NULL == nomfonte) {
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL > 1
fprintf(stderr, "trace chaine 1: using loaded font\n"); fprintf(stderr, "trace chaine 1: using loaded font\n");
#endif #endif
@@ -188,7 +202,7 @@ else {
if (NULL==paper) paper = &blanc; if (NULL==paper) paper = &blanc;
if (NULL==ink) ink = &noir; if (NULL==ink) ink = &noir;
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL
Image_print_rgba("encre", ink, 0); Image_print_rgba("encre", ink, 0);
Image_print_rgba("papier", paper, 0); Image_print_rgba("papier", paper, 0);
#endif #endif
@@ -206,7 +220,8 @@ posx = x; posy = y;
for (foo=0; foo<t_texte; foo++) { for (foo=0; foo<t_texte; foo++) {
octet = ptrtxt[foo]; octet = ptrtxt[foo];
if (posx > (im->width-8)) { if (posx > (im->width-8)) {
fprintf(stderr, "can't plot char '%c' at x=%d\n", octet, posx); fprintf(stderr, "%s: can't plot char '%c' at x=%d\n",
__func__, octet, posx);
break; break;
} }
Image_trace_caractere_2(im, priv_fonte, posx, posy, octet, paper, ink); Image_trace_caractere_2(im, priv_fonte, posx, posy, octet, paper, ink);
@@ -245,23 +260,19 @@ if ( (code < 0) || (code > 255)) {
paper.r = paper.g = paper.b = 0; paper.r = paper.g = paper.b = 0;
ink.r = ink.g = ink.b = 255; ink.r = ink.g = ink.b = 255;
rect.w = kx, rect.h = ky; rect.w = kx, rect.h = ky;
/* /*
* NEED BOUNDARY CHECK ! * NEED BOUNDARY CHECK !
*/ */
for (foo=0; foo<8; foo++) /* 8 scan lines */ for (foo=0; foo<8; foo++) { /* 8 scan lines */
{
octet = priv_fonte[(code*8)+foo]; octet = priv_fonte[(code*8)+foo];
rect.y = (foo * ky) + y; rect.y = (foo * ky) + y;
for (bar=0; bar<8; bar++) for (bar=0; bar<8; bar++) {
{
rect.x = (bar * kx) + x; rect.x = (bar * kx) + x;
rect.x = ((8-bar)*kx) + x; rect.x = ((8-bar)*kx) + x;
if (octet & 1) if (octet & 1) {
{
Image_paint_rect(im, &rect, 255, 198, 0); Image_paint_rect(im, &rect, 255, 198, 0);
Image_draw_rect(im, &rect, 0, 0, 80); Image_draw_rect(im, &rect, 0, 0, 80);
} }

View File

@@ -87,9 +87,9 @@ for (idx=0; idx<len; idx++)
idx, txt[idx], xpos); idx, txt[idx], xpos);
#endif #endif
foo = Image_trace_big_char_0(im, xpos, y, txt[idx], xf, yf); foo = Image_trace_big_char_0(im, xpos, y, txt[idx], xf, yf);
#if DEBUG_LEVEL if (foo) {
fprintf(stderr, "Image_trace_big_char_0 -> %d\n", foo); fprintf(stderr, "Image_trace_big_char_0 -> %d\n", foo);
#endif }
xpos += (xf * 8); xpos += (xf * 8);
} }

View File

@@ -165,6 +165,9 @@ int rp, gp, bp;
int x2, y2; int x2, y2;
uint16_t mask; uint16_t mask;
RGBA blanc = { 255, 255, 255, 255, 0, 0 },
noir = { 0, 0, 0, 64, 0, 0 };
if (flags) { if (flags) {
fprintf(stderr, "in %s, useless flags 0x%x is useless\n", fprintf(stderr, "in %s, useless flags 0x%x is useless\n",
__func__, flags); __func__, flags);
@@ -175,11 +178,15 @@ fprintf(stderr, "%s: ltr %3d '%c' %4d %4d\n", __func__, lettre,
isprint(lettre) ? lettre : ' ', xpos, ypos); isprint(lettre) ? lettre : ' ', xpos, ypos);
#endif #endif
/*
* use default if not provided by caller
*/
if (NULL==pap) pap = &blanc;
if (NULL==ink) ink = &noir;
/* +-------------------------------+ /* +-------------------------------+
| WTF ? no boundary check ? | | WTF ? no boundary check ? |
+-------------------------------+ */ +-------------------------------+ */
for (y=0; y<24; y++) { for (y=0; y<24; y++) {
mask = 0x8000; mask = 0x8000;
y2 = y + ypos; y2 = y + ypos;

View File

@@ -12,7 +12,7 @@
#include "../tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
#define LIBTGA_VERSION "0.2.42" #define LIBTGA_VERSION "0.2.43"
typedef struct { typedef struct {
uint8_t text_size; uint8_t text_size;
@@ -27,6 +27,9 @@ typedef struct {
} Tga_file_header; } Tga_file_header;
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/*
*
*/
int Image_TGA_write_header(FILE *fp, Tga_file_header *head) int Image_TGA_write_header(FILE *fp, Tga_file_header *head)
{ {
fwrite (&head->text_size, 1, 1, fp); fwrite (&head->text_size, 1, 1, fp);
@@ -87,7 +90,7 @@ if (img->magic != MAGIC_OF_IMAGE) {
return NOT_AN_IMAGE_DESC; return NOT_AN_IMAGE_DESC;
} }
/* /*
* mais ça marche pas a tous les coups. il faudrait pouvoir tester si * mais c,a marche pas a tous les coups. il faudrait pouvoir tester si
* le pointeur 'img' est coherent, mais je sais pas comment faire... * le pointeur 'img' est coherent, mais je sais pas comment faire...
*/ */
if (compress != 0) { if (compress != 0) {
@@ -423,6 +426,8 @@ return OLL_KORRECT;
/* new 1er mai 2007 (la france qui bosse tout le temps) */ /* new 1er mai 2007 (la france qui bosse tout le temps) */
int Image_TGA_show_header(char *filename, int flag) int Image_TGA_show_header(char *filename, int flag)
{ {
(void)flag; /* WARNING KILLER */
FILE *fp; FILE *fp;
Tga_file_header header; Tga_file_header header;
int foo; int foo;
@@ -443,7 +448,7 @@ if (foo) {
foo = Image_TGA_print_header(&header); foo = Image_TGA_print_header(&header);
if (foo) if (foo)
{ {
; fprintf(stderr, "%s: something is wrong\n", __func__);
} }
return FUNC_NOT_FINISH; return FUNC_NOT_FINISH;
@@ -497,8 +502,7 @@ return OLL_KORRECT;
* que les images RGB. il manque le GRIS !!! * que les images RGB. il manque le GRIS !!!
* ! il manque aussi la decompression ! * ! il manque aussi la decompression !
*/ */
Image_Desc * Image_Desc * Image_TGA_alloc_load(char *nom)
Image_TGA_alloc_load(char *nom)
{ {
Tga_file_header head; Tga_file_header head;
FILE *fp; FILE *fp;
@@ -516,6 +520,11 @@ if ( (fp=fopen(nom, "rb")) == NULL )
memset(&head, 0, sizeof(Tga_file_header)); memset(&head, 0, sizeof(Tga_file_header));
foo = Image_TGA_read_header(fp, &head); foo = Image_TGA_read_header(fp, &head);
if (foo) {
fprintf(stderr, "%s: read error %d on header\n", __func__, foo);
fclose(fp);
return NULL;
}
#if DEBUG_LEVEL > 1 #if DEBUG_LEVEL > 1
printf("TGA ALLOC LOAD: read header -> %d\n", foo); printf("TGA ALLOC LOAD: read header -> %d\n", foo);

11
Lib/tiff.c Normal file
View File

@@ -0,0 +1,11 @@
/*
* TIFF
*
* new Sun Jul 28 10:57:00 UTC 2024
*/
#include <stdio.h>
/*::------------------------------------------------------------------::*/
/*::------------------------------------------------------------------::*/

View File

@@ -26,7 +26,12 @@ foo = (compteur++) / div;
printf("%c\r", batons[foo&0x03]); fflush(stdout); printf("%c\r", batons[foo&0x03]); fflush(stdout);
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/*
* I think that the 'chrono' system is full broken
*
* You have to look at 'functions.c' for more timing functions.
*
*/
#define NB_CHRONOS 42 #define NB_CHRONOS 42
static struct { static struct {
@@ -98,7 +103,7 @@ printf("/-------- Descriptor Dump (lib v=%s) -----------\n",
printf("| why text: %s\n", text); printf("| why text: %s\n", text);
printf("| main pointer: %p\n", im); printf("| main pointer: %p\n", im);
if ( im==NULL ) { if ( NULL == im ) {
printf("!\t\tthis is a null descriptor, good luck, Sir...\n"); printf("!\t\tthis is a null descriptor, good luck, Sir...\n");
return NULL_DESCRIPTOR; return NULL_DESCRIPTOR;
} }
@@ -124,11 +129,11 @@ return 0;
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int Image_dump_rect(Image_Rect *rect, char *texte, int flag) int Image_dump_rect(Image_Rect *rect, char *texte, int flag)
{ {
printf("Rect: '%s'\n\t%5d %5d %5d %5d $%08lx\n", texte, printf("Rect: '%s'\n\t%5d %5d %5d %5d $%04lx\n", texte,
rect->x, rect->y, rect->w, rect->h, rect->reserved); rect->x, rect->y, rect->w, rect->h, rect->reserved);
if (flag) { if (flag) {
printf(" coin bas/droite %5d %5d\n", rect->x+rect->w, rect->y+rect->h); printf(" lower right %5d %5d\n", rect->x+rect->w, rect->y+rect->h);
printf(" surface %8ld\n", (long)rect->w * (long)rect->h); printf(" surface %8ld\n", (long)rect->w * (long)rect->h);
} }
fflush(stdout); fflush(stdout);
@@ -155,7 +160,7 @@ putc('\n', stderr);
void Image_warning(char caractere, char *lig1, char *lig2, int k) void Image_warning(char caractere, char *lig1, char *lig2, int k)
{ {
int len1, len2, len, foo; int len1, len2, len;
len1 = len2 = 0; len1 = len2 = 0;
if (NULL != lig1) len1 = strlen(lig1); if (NULL != lig1) len1 = strlen(lig1);
@@ -169,9 +174,9 @@ fprintf(stderr, "%s : ligne 1 = %s\n", __func__, lig1);
fprintf(stderr, "%s : ligne 2 = %s\n", __func__, lig2); fprintf(stderr, "%s : ligne 2 = %s\n", __func__, lig2);
#endif #endif
ligne_char(caractere, len+10); ligne_char(caractere, len+10+k);
ligne_space(caractere, len+10); ligne_space(caractere, len+10+k);
ligne_char(caractere, len+10); ligne_char(caractere, len+10+k);
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
@@ -185,7 +190,7 @@ if (*txt == '-') {
fp = stdout; fp = stdout;
txt++; /* skip the '-' */ txt++; /* skip the '-' */
} }
else { else {
fp = stderr; fp = stderr;
} }
fprintf(fp, hexa ? fmth : fmtd, txt, rgba->r, rgba->g, rgba->b, rgba->a); fprintf(fp, hexa ? fmth : fmtd, txt, rgba->r, rgba->g, rgba->b, rgba->a);
@@ -209,7 +214,7 @@ if (h->control != MAGIC_OF_DF3) {
return 666; return 666;
} }
printf("+--- DF3head @ %p -- %s --\n", h, txt); printf("+--- DF3head @ %p -- %s -- %c\n", h, txt, flag ? 'X' : 'O');
printf("| magic: %08lx\n", h->control); printf("| magic: %08lx\n", h->control);
printf("| name: %s\n", h->name); printf("| name: %s\n", h->name);
printf("| dims: %d %d %d\n", h->xdim, h->ydim, h->zdim); printf("| dims: %d %d %d\n", h->xdim, h->ydim, h->zdim);

View File

@@ -1,30 +0,0 @@
/*
* trigo.c
*
* nouveau Thu 15 Sep 2022 09:33:53 PM CEST
*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#ifdef NEED_ALLOCA_H
#include <alloca.h>
#endif
#include "../tthimage.h"
/*::------------------------------------------------------------------::*/
Image_cos010(Image_Desc *src, Image_Desc *dst)
{
int foo;
if ( (foo=Image_compare_desc(src, dst)) ) {
fprintf(stderr, "%s: images not compatible, %d\n", __func__, foo);
return foo;
}
return FULL_NUCKED;
}
/*::------------------------------------------------------------------::*/
/*::------------------------------------------------------------------::*/

View File

@@ -9,17 +9,16 @@
#include "../tthimage.h" #include "../tthimage.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_turtle_infos(Image_Desc *img, int flags)
Image_turtle_infos(Image_Desc *img, int flags)
{ {
int foo;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "Image turtle infos: flags = %04x\n", flags); fprintf(stderr, "Image turtle infos: flags = %04x\n", flags);
#endif #endif
if ( flags & 1 ) if ( flags & 1 ) {
foo = Image_dump_descriptor(img, "turtle infos"); Image_dump_descriptor(img, "turtle infos");
}
return FUNC_IS_ALPHA; return FUNC_IS_ALPHA;
} }
@@ -30,8 +29,7 @@ return FUNC_IS_ALPHA;
* Q: pourquoi le canal alpha n'est pas pris en compte ? * Q: pourquoi le canal alpha n'est pas pris en compte ?
* A: parce que :) * A: parce que :)
*/ */
int int Image_turtle_setcolors(Image_Desc *img, int r, int g, int b)
Image_turtle_setcolors(Image_Desc *img, int r, int g, int b)
{ {
img->rt = r; img->gt = g; img->bt = b; img->rt = r; img->gt = g; img->bt = b;
@@ -40,21 +38,28 @@ img->at = 0; /* ? bonne valeur ? */
return FUNC_IS_ALPHA; return FUNC_IS_ALPHA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_turtle_move(Image_Desc *img, double xt, double yt)
Image_turtle_move(Image_Desc *img, double xt, double yt)
{ {
fprintf(stderr, ">>> %s ( %p %f %f )\n", __func__, img, xt, yt);
img->xt = xt; img->xt = xt;
img->yt = yt; img->yt = yt;
return FUNC_NOT_FINISH; return FUNC_NOT_FINISH;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_turtle_draw(Image_Desc *img, double xt, double yt)
Image_turtle_draw(Image_Desc *img, double xt, double yt)
{ {
int x1, y1, x2, y2;
RGBA color = { 200, 200, 200, 0, 0, 0 };
(void)img; fprintf(stderr, ">>> %s ( %p %f %f )\n", __func__, img, xt, yt);
x1 = (int)img->xt, y1 = (int)img->yt;
x2 = (int)xt , y2 = (int)yt;
Image_draw_line(img, x1, y1, x2, y2, &color);
return FUNC_NOT_FINISH; return FUNC_NOT_FINISH;
} }

13
Lib/utility.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/bash
set -e
SRC="testtga.c essais.c operat.c image.c effects.c tele_2.c calculs.c"
SRC="$SRC dither.c television.c rgbmask.c sobel4.c tga.c patterns*.c"
echo $SRC ; echo
FLOW="cflow.txt"
cflow --depth=5 -o $FLOW -m main --number $SRC
less $FLOW

View File

@@ -65,13 +65,13 @@ for (y=0; y<dst->height; y++) {
return FUNC_IS_BETA; return FUNC_IS_BETA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int Image_warp_essai_1(Image_Desc *src, Image_Desc *dst, double angle, double shift)
Image_warp_essai_1(Image_Desc *src, Image_Desc *dst, double angle)
{ {
#if DEBUG_LEVEL fprintf(stderr, ">>> %s ( %p %p %f %f )\n", __func__, src, dst, angle, shift);
fprintf(stderr, "Warp 1: what I can do here ?\n");
#endif
return FUNC_NOT_FINISH; return FUNC_NOT_FINISH;
} }

View File

@@ -1,62 +0,0 @@
/*
warp3.c
---------------
*/
#include <stdio.h>
#include <math.h>
#include "../tthimage.h"
/*::------------------------------------------------------------------::*/
/*
* travail basé sur un PDF dont l'URL a été postée dans la
* tribune de la buvette.
*
* L'auteur est Gernot Hoffmann.
*/
int
Image_interpolate_0(Image_Desc *src, Image_Desc *dst, int ox, int oy)
{
int x, y;
int x2, y2, foo;
fprintf(stderr, "*** Image_interpolate_0: work in progress...\n");
if ( src == dst )
{
fprintf(stderr, "Image interpolate_0: can't overwrite, sorry\n");
return IMG_OVERWRITE;
}
/*
@@@@@@@@@@@@@@
PUTAIN SA RACE
La police du PDF est pas sortie à l'impression :(
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Et comme le code est incomplet et en Pascal, je ne
sais pas trop quoi en faire. Beueueueh.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
*/
return FUNC_NOT_FINISH;
}
/*::------------------------------------------------------------------::*/
/* new 11 janvier 2009 - avenue St Exupery */
int
Image_interpolate_2(Image_Desc *src, Image_Desc *dst, RGBA *rgba)
{
int x, y;
if (NULL==rgba)
{
fprintf(stderr, "Using default RGBA in %s...\n", __func__);
}
return FULL_NUCKED;
}
/*::------------------------------------------------------------------::*/
/*
* voir aussi les modules scale.c, zoom.c et warp[0|1|2].c
*/
/*::------------------------------------------------------------------::*/

View File

@@ -26,35 +26,37 @@ long hit, mess;
#endif #endif
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s : %p -> %p %f %f 0x%x\n", __func__, fprintf(stderr, ">>> %s ( %p %p %f %f 0x%x )\n", __func__,
src, dst, kx, ky, flags); src, dst, kx, ky, flags);
#endif #endif
/* initilaisation de variables de debug/comptage */ if (flags) {
fprintf(stderr, "in %s, flags muste be 0x0000\n", __func__);
return WRONG_FLAG;
}
/* initialisation de variables de debug/comptage */
#if DEBUG_LEVEL #if DEBUG_LEVEL
hit = mess = 0L; hit = mess = 0L;
#endif #endif
for (xd=0; xd<dst->width; xd++) for (xd=0; xd<dst->width; xd++) {
{
dxs = (double)xd * kx; dxs = (double)xd * kx;
for (yd=0; yd<dst->height; yd++) for (yd=0; yd<dst->height; yd++) {
{
rd = gd = bd = 42; rd = gd = bd = 42;
dys = (double)yd * ky; /* kikoo lol */ dys = (double)yd * ky; /* kikoo lol */
xs = (int)dxs; xs = (int)dxs;
ys = (int)dys; ys = (int)dys;
if ( Image_xy_inside(src, xs, ys) ) if ( Image_xy_inside(src, xs, ys) ) {
{
Image_getRGB(src, xs, ys, &rd, &gd, &bd); Image_getRGB(src, xs, ys, &rd, &gd, &bd);
#if DEBUG_LEVEL #if DEBUG_LEVEL
hit++; hit++;
#endif #endif
} }
#if DEBUG_LEVEL #if DEBUG_LEVEL
else mess++; else { mess++; }
#endif #endif
Image_plotRGB(dst, xd, yd, rd, gd, bd); Image_plotRGB(dst, xd, yd, rd, gd, bd);
} }
@@ -67,25 +69,117 @@ fprintf(stderr, "%s -> hit=%ld mess=%ld\n", __func__, hit, mess);
return BAD_ZOOM; return BAD_ZOOM;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int Image_zoom_000(Image_Desc *src, Image_Desc *dst, Image_Rect *rect) /*
* Very old non-working code get an update on Thu 24 Sep 2022
*
* We have two versions:
* zoom_000 without interpolation
* zoom_001 with a pseudo bi-linear interpolation
* Public intercace:
* Image_zoom_extract(src, dst, rect, flags)
*/
/* this is a semi-private function */
int Image_zoom_000(Image_Desc *src, Image_Desc *dst, Image_Rect *rect,
float kx, float ky)
{ {
int xd, yd, r, g, b; int xd, yd, xs, ys, r, g, b;
double fxd, fyd; float ftmp;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "%s ( %p %p %p )\n", __func__, src, dst, rect); fprintf(stderr, ">>> %s ( %p %p %p )\n", __func__, src, dst, rect);
#endif #endif
for (yd=0; yd<dst->height; yd++) for (yd=0; yd<dst->height; yd++) {
{ ftmp = ((float)yd) / ky;
fyd = (double)yd; ys = (int) (ftmp);
for (xd=0; xd<dst->height; xd++) ys += rect->y;
{ /*
fxd = (double)xd; fprintf(stderr, " yd %5d -> %8.3f ys %5d\n", yd, ftmp, ys);
*/
for (xd=0; xd<dst->width; xd++) {
xs = (int) ((float)xd / kx);
xs += rect->x;
if ( Image_xy_inside(src, xs, ys) )
{ Image_getRGB(src, xs, ys, &r, &g, &b); }
else
{ r = g = b = 127; }
Image_plotRGB(dst, xd, yd, r, g, b);
} }
} }
return FULL_NUCKED; return FUNC_IS_BETA;
}
/*::------------------------------------------------------------------::*/
/* */
/* nouveau Fri 23 Sep 2022 02:27:00 PM CEST */
/* this is a semi-private function */
/* */
int Image_zoom_001(Image_Desc *src, Image_Desc *dst, Image_Rect *rect,
float kx, float ky)
{
int xd, yd, xs, ys, r, g, b;
double dxs, dys;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %p %.3f %.3f)\n", __func__,
src, dst, rect, kx, ky);
#endif
for (yd=0; yd<dst->height; yd++) {
dys = (double)rect->y + (((double)yd) / ky);
ys = (int)dys;
for (xd=0; xd<dst->width; xd++) {
dxs = (double)rect->x + ((double)xd / kx);
xs = (int)dxs;
if ( Image_xy_inside(src, xs, ys) )
{
/* see 'scale.c' for this func */
Image_getpix_bilin(src, dxs, dys, &r, &g, &b);
}
else
{ r = g = b = 127; }
Image_plotRGB(dst, xd, yd, r, g, b);
}
}
return FUNC_IS_BETA;
}
/*::------------------------------------------------------------------::*/
/* */
/* nouveau Fri 23 Sep 2022 02:16:55 PM CEST */
/* */
int Image_zoom_extract(Image_Desc *src, Image_Desc *dst, Image_Rect *rect,
int flags)
{
int foo;
float kx, ky;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %p 0x%x)\n", __func__, src, dst, rect, flags);
#endif
kx = (float)dst->width / (float)rect->w;
ky = (float)dst->height / (float)rect->h;
#if DEBUG_LEVEL
fprintf(stderr, " kx %8.3f ky %8.3f\n", kx, ky);
#endif
/* this is ugly code ! */
if (flags)
{ foo = Image_zoom_001(src, dst, rect, kx, ky); }
else
{ foo = Image_zoom_000(src, dst, rect, kx, ky); }
if (foo) {
fprintf(stderr, "got %d in %s\n", foo, __func__);
return foo;
}
return FUNC_IS_ALPHA;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/

View File

@@ -14,12 +14,13 @@ HTML_DIR=$(DESTDIR)/html
# pour tracer plein de trucs: -DDEBUG_LEVEL=1 # pour tracer plein de trucs: -DDEBUG_LEVEL=1
# if IMGCOMMENT, the image comment is written to the TGA file, # if IMGCOMMENT, the image comment is written to the TGA file,
# but this files can't be loaded by Xv... # but this files can't be loaded by Xv...
#
# pour coredumper dans les situations graves: -DABORT=1 # pour coredumper dans les situations graves: -DABORT=1
# #
# use -Wmissing-prototypes ? # use -Wmissing-prototypes ?
LIBIMG_OPT=-DFORCE_ABORT=0 -DDEBUG_LEVEL=0 -DIMGCOMMENT=0 LIBIMG_OPT=-DFORCE_ABORT=0 -DDEBUG_LEVEL=0 -DIMGCOMMENT=0
CC_OPTS=-Wall -W -g -ansi -O3 -fPIC -no-pie CC_OPTS=-Wall -W -g -ansi -O1 -fPIC -no-pie
CC_HACKS=-DNEED_ALLOCA_H CC_HACKS=-DNEED_ALLOCA_H
CFLAGS= $(CC_OPTS) \ CFLAGS= $(CC_OPTS) \
@@ -34,3 +35,7 @@ RANLIB=wc -c
# modify it 'as you like' # modify it 'as you like'
AR=ar AR=ar
#
# and valgrind is your friend
#

View File

@@ -1,23 +1,37 @@
# libtthimage # libtthimage
Ce kluge a pour but de brotcher les images avec vigueur. Ce kluge a pour but avoué de brotcher les images avec vigueur.
Du code né dans les années 1986 sur un Kenitec 286 sous msdos 4 ou 5, Du code né dans les années 1990 sur un Kenitec 286 sous msdos 4 ou 5,
puis s'est un jour retrouvé dans un Linux (kernel 0.99) et qui végète puis qui s'est un jour retrouvé dans un Linux (kernel 0.99) et qui végète
depuis ~2005. Il est venu le temps de le remettre en route. depuis ~2005. Il est venu le temps de le remettre en route, mais
la tâche n'est pas terminée.
## Construction ## Construction
Tout va bien se passer. Tout va bien se passer. Mais c'est assez rudimentaire, il y a deux scripts.
Le premier, [`build.sh`](./build.sh), va compiler la bibliothèque et les utilitaires.
Le second, [`install.sh`](./install.sh) va mettre les choses au bon endroit.
Il est vivement conseillé de bien les lire avant de les utiliser.
Les options globales de compilation sont dans
[Paramakes.mk](Paramakes.mk). Là aussi, soyez attentifs.
## Utilisation ## Utilisation
C'est là que ça se complique. C'est là que ça se [complique](Docs/). Même moi, parfois je m'y perds.
Vous poulez voir quelques [exemples](http://la.buvette.org/images/images.html)
de l'ancien temps, avant la reprise en main de ces dernières années.
## Les outils ## Les outils
Et ça sert à quoi ? Plein de petits [binaires](Tools/) qui font plein de choses
plus ou moins ésotériques. En général, pour avoir de l'aide,
il faut leur donner une seule option : `list`, ce qui n'est pas très
conventionnel, mais bon, *legacy*, toussa...
## La suite ? ## La suite ?
Bah, c'est l'heure du _gloumiam_, alors on passe à table. Bah, c'est l'heure du _gloumiam_, alors on passe à table.
Et après, on va continuer une grande campagne de nettoyage du
code, il reste un gazillion de warnings.

5
Tests/.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
a.scratch
*.tga

View File

@@ -1,14 +1,20 @@
# Some useless tests # Some useless tests ?
Tester, c'est douter. <u>Tester, c'est douter.</u>
## État des lieux ## État des lieux
Pas grand chose. Pas grand chose pour le moment. Mais comme j'utilise régulièrement
et depuis très longtemps cet amas de fonctions, on peut dire que
les tests sont fait *in-vivo* sans formalisme formalisé.
Allez quand même voir `config.sh` et `functions.sh` pour avoir une idée Allez quand même voir `config.sh` et `functions.sh` pour avoir une idée
du désastre actuel. Il reste beaucoup de choses à faire. du désastre actuel. Il reste beaucoup de choses à faire.
## Mais encore ? ## Mais encore ?
Dans le répertoire `Lib/` il y a un `essais.c` assez prometteur. Dans le répertoire `Lib/` il y a un `essais.c` assez
[prometteur](../Lib/essais.c) et en constante évolution.
Il manque à son [driver](../Lib/testtga.c) une gestion plus
fluide de la sélection
des essais à faire tourner.

15
Tests/essai_genplot2.sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/bash
echo "------------------------------------------"
echo "GO" | ./mk_dessin.awk > a.scratch
wc a.scratch
echo "------------------------------------------"
../Tools/genplot2 -s 640x480
errcode=$?
echo "code retour genplot2 = " $errcode
echo "------------------------------------------"
echo "------------------------------------------"

View File

@@ -0,0 +1,2 @@
this directory is for temporary files made from tests.

View File

@@ -4,7 +4,7 @@
test_des_xpers () test_des_xpers ()
{ {
command=$1 command=$1
echo ; echo " Test du xper $command" echo ; echo "======= Test du xper $command"
# generation d'une image sur laquelle travailler # generation d'une image sur laquelle travailler
$COMDIR/tga_mires mircol0 $SRC "hard xper '$command'" $COMDIR/tga_mires mircol0 $SRC "hard xper '$command'"

27
Tests/mk_dessin.awk Executable file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/awk -f
# ce joli programme fabrique un fichier de donnees qui sera
# utile au bon deroulement de 'essai_genplot2.sh'
BEGIN { nbretraits = 20000 }
END {
for (trait=0; trait<nbretraits; trait++)
{
if (0.498 > rand())
{
posx += rand()
posy += rand()
print posx, posy, 1
}
else
{
posx -= rand()
posy -= rand()
print posx, posy, 2
}
}
}
# job done

28
Tests/t_recurse.sh Executable file
View File

@@ -0,0 +1,28 @@
#!/bin/bash
set -e
source="dauphine2.tga"
if [ $# -eq 2 ] ; then
source="$1"
fi
identify $source ; echo
rm -f frames/R*.tga
maxidx=250
for idx in $(seq 0 4 $maxidx)
do
dst=$(printf "frames/R%03d.tga" $idx)
coef=$(( $maxidx - $idx ))
echo "======> "$dst " coef " $coef
../Tools/tga_effects $source recurse $dst $coef
done
convert -delay 10 frames/R*.tga recurse.gif
wc -c recurse.gif

View File

@@ -51,7 +51,7 @@ if (foo) { Image_print_error("load thin font", foo); }
foo = Image_t16x24_chars_map("16x24gruik", "all16X24chars.tga", 2); foo = Image_t16x24_chars_map("16x24gruik", "all16X24chars.tga", 2);
if (foo) { Image_print_error("load gruik font", foo); } if (foo) { Image_print_error("load gruik font", foo); }
fprintf(stderr, "--------------------------\n"); fprintf(stderr, "--------------------------------------\n");
/* /*
foo = essai_f1("pov.tga", "/tmp/aaaa_plop.tga", "0123456789"); foo = essai_f1("pov.tga", "/tmp/aaaa_plop.tga", "0123456789");

10
Tools/.gitignore vendored Normal file
View File

@@ -0,0 +1,10 @@
*.tga
*.scratch
tga_extract
tga_to_text
tga_plothisto
tga_plotmap
tga_resize
tga_fractales

View File

@@ -10,9 +10,11 @@ DEPS = ../tthimage.h Makefile tga_outils.h ../libtthimage.a
all: genplot2 \ all: genplot2 \
tga_cadre tga_effects tga_filtres tga_remap tga_tools \ tga_cadre tga_effects tga_filtres tga_remap tga_tools \
tga_combine tga_export tga_alpha \ tga_combine tga_export tga_alpha tga_extract \
tga_television tga_dither tga_applymap tga_makehf15 \ tga_television tga_dither tga_applymap tga_makehf15 \
tga_mires tga_incrust tga_pattern tga_equalize tga_mires tga_incrust tga_pattern tga_equalize \
tga_to_text tga_resize tga_plotmap tga_plothisto \
tga_fractales
# 'tga_info.c' do not compile yet # 'tga_info.c' do not compile yet
@@ -28,6 +30,25 @@ genplot2: genplot2.c $(DEPS) fonctions.o
#----------------------------------------------------------------- #-----------------------------------------------------------------
fractales.o: fractales.c fractales.h Makefile
gcc $(CFLAGS) -c $<
tga_fractales: tga_fractales.c $(DEPS) fractales.o fonctions.o
gcc $(CFLAGS) $< fractales.o ../libtthimage.a fonctions.o \
-lm -o $@
tga_resize: tga_resize.c $(DEPS) fonctions.o
gcc $(CFLAGS) $< ../libtthimage.a fonctions.o -lm -o $@
tga_plotmap: tga_plotmap.c $(DEPS) fonctions.o
gcc $(CFLAGS) $< ../libtthimage.a fonctions.o -lm -o $@
tga_plothisto: tga_plothisto.c $(DEPS) fonctions.o
gcc $(CFLAGS) $< ../libtthimage.a fonctions.o -lm -o $@
tga_to_text: tga_to_text.c $(DEPS) fonctions.o
gcc $(CFLAGS) $< ../libtthimage.a fonctions.o -lm -o $@
tga_alpha: tga_alpha.c $(DEPS) fonctions.o tga_alpha: tga_alpha.c $(DEPS) fonctions.o
gcc $(CFLAGS) $< ../libtthimage.a fonctions.o -lm -o $@ gcc $(CFLAGS) $< ../libtthimage.a fonctions.o -lm -o $@
@@ -73,11 +94,15 @@ tga_tools: tga_tools.c $(DEPS) fonctions.o
tga_incrust: tga_incrust.c $(DEPS) fonctions.o tga_incrust: tga_incrust.c $(DEPS) fonctions.o
gcc $(CFLAGS) $< ../libtthimage.a fonctions.o -lm -o $@ gcc $(CFLAGS) $< ../libtthimage.a fonctions.o -lm -o $@
# tga_info: tga_info.c $(DEPS) fonctions.o tga_extract: tga_extract.c $(DEPS) fonctions.o
# gcc $(CFLAGS) $< ../libimage.a fonctions.o -lm -o $@
tga_pattern: tga_pattern.c $(DEPS) fonctions.o
gcc $(CFLAGS) $< ../libtthimage.a fonctions.o -lm -o $@ gcc $(CFLAGS) $< ../libtthimage.a fonctions.o -lm -o $@
tga_info: tga_info.c $(DEPS) fonctions.o
gcc $(CFLAGS) $< ../libimage.a fonctions.o -lm -o $@
tga_pattern: tga_pattern.c $(DEPS) fonctions.o
gcc $(CFLAGS) $< ../libtthimage.a fonctions.o -lm -o $@
#----------------------------------------------------------------- #-----------------------------------------------------------------

View File

@@ -1,8 +1,10 @@
# Tools # Tools
Pour utiliser toutes ces fonctions, il y a une collection d'utilitaires Pour utiliser toutes les fonctions de la bibliothèque,
spécialisés. Leur interface en `CLI` est assez rudimentaire, mais la il y a une collection d'utilitaires spécialisés.
plupart savent donner quelques indices avec la commande `list`. Exemple: Leur interface en `CLI` est assez rudimentaire, mais
la plupart savent donner quelques indices avec la
commande `list`. Exemple:
``` ```
tth@konrad:~/Devel/libtthimage$ tga_filtres list tth@konrad:~/Devel/libtthimage$ tga_filtres list
@@ -12,7 +14,7 @@ Usage:
tga_filtres <src.tga> FILTR <dst.tga> [p1] ... [pn] tga_filtres <src.tga> FILTR <dst.tga> [p1] ... [pn]
-+- This is the `tthimage' library v0.4.50 (dwtfywl 2022) tTh -+- This is the `tthimage' library v0.4.50 (dwtfywl 2022) tTh
commande | type arg | explication commande | type arg | explication
------------+----------+------------------------------------ ------------+----------+------------------------------
liss2x2 | | lissage 2x2 liss2x2 | | lissage 2x2
hipass | | hipass | |
lopass | | lopass | |
@@ -29,25 +31,46 @@ La colonne du milieu indique le type des paramètres :
## tga_alpha ## tga_alpha
Manipulation du canal alpha (la transparence), lequel canal Manipulation du canal alpha (la transparence), lequel canal
est globalement mal géré par l'ensemble de libtthimage. est globalement mal géré par l'ensemble de la libtthimage.
## tga_applymap ## tga_applymap
Ce qui est considéré comme une map ici vient d'un antique
logiciel de fractales sous ms-dos :
[Fractint](https://fractint.org/). Quelques exemples de
ces fichiers sont dans le répertoire `Datas/` du projet.
Vous rencontrerez parfois des messages d'erreur comme
« *color map is to big* » ou « *only 97 entries in foo.map* ».
Pas d'inquiétude, tout va bien se passer.
Dans le premier cas, les lignes en excédent sont ignorées,
et dans le second, les valeurs manquantes sont mises au noir.
La gestion de la ligne de commande est désastreuse. **À REFAIRE** La gestion de la ligne de commande est désastreuse. **À REFAIRE**
## tga_cadre ## tga_cadre
Pas mal de façons de mettre un cadre sur l'image. Il existe pas mal de façons de mettre un cadre sur l'image,
Niveau de kitchitude assez élevé. avec un niveau de kitchitude assez élevé.
Paramètres mal documentés. Les paramètres sont mal documentés.
## tga_combine ## tga_combine
```
Usage:
tga_combine s1.tga s2.tga MODE d.tga [PARAMS]
```
Il existe plein de façon de combiner deux images, la commande
`tga_combine list` vous les fera découvrir, la cinquième va vous étonner.
Les paramètres sont mal documentés.
## tga_dither ## tga_dither
Comment drastiquement réduire le nombre de couleurs d'une image ?
## tga_export ## tga_export
Attendu avec impatience, il aura le support complet des PNG. Attendu avec impatience, il aura le support complet des PNG. Un jour...
## tga_effects ## tga_effects
@@ -55,31 +78,98 @@ Attendu avec impatience, il aura le support complet des PNG.
## tga_filtres ## tga_filtres
UTSL : [tga_filtres.c](caractère \textbf{invisible})
## tga_incrust ## tga_incrust
## tga_makehf15 ## tga_makehf15
Pour les POViste acharnés. De façon étrange,
[Povray](https://povray.org/) a choisi de stocker des
champs d'altitude dans les images Targa, en n'utilisant que
15 bits pour la valeur.
## tga_to_text
Mis au point pour les imports dans d'autres langages,
comme Awk, Fortran ou R. Chaque ligne du fichier généré
contient cinq champs : x, y, r, g, b.
Attention, il peut vite générer d'énormes fichiers.
## tga_mires ## tga_mires
La génération de diverses image de test ou de calibration. La génération de diverses image de test ou de calibration.
## tga_pattern ## tga_pattern
Les résultats sont très ésotériques et l'aide en ligne est
vraiment trop nulle...
## tga_remap ## tga_remap
Usage: `tga_remap M <src.tga> <color.map> <dst.tga>`
Le paramètre `M` peut prendre les valeurs 0, 1, 2, 11, 12 ou 13.
Je ne sais plus à quoi ça correspond.
## tga_television ## tga_television
## tga_tools ## tga_tools
Celui ci est très utile pour la recherche de problèmes ou l'automatisation Celui ci est très utile pour la recherche de problèmes ou l'automatisation
de certaines tâches. Exemple : de certaines tâches. Un exemple rapide :
``` ```
tth@konrad:~/Devel/libtthimage$ tga_tools getdimweb mire.tga tth@redlady:~/Devel/libtthimage$ tga_tools getdimweb foo.tga
width=512 height=512 width=640 height=480
tth@konrad:~/Devel/libtthimage$ tth@redlady:~/Devel/libtthimage$ tga_tools getdimpov foo.tga
-w640 -h480
tth@redlady:~/Devel/libtthimage$
``` ```
### version
### surface
### getdims, getdimx, getdimpov, getdimweb
renvoie une chaine de caractère donnant les dimensions de l'image
en différents formats.
### width, height
renvoie chacune des deux dimensions.
### grminmax
### message
Flags: un entier. Si non nul, change l'encre et le papier pour
d'autres valeurs. La chaine de caractère doit être (sjmsb) encodée
en CP-850, voire même comme celles du Locomotive du CPC.
### structs
Affichage d'information (boutisme, taille des structures) qui ne
seront utiles qu'aux codeurs.
```
tth@redlady:~/Devel/libtthimage/Tools$ ./tga_tools structs
petit = 1234 -> 34 12
grand = 12345678 -> 78 56 34 12 00 00 00 00
basic types : short=2 int=4 long=8 ptr=8
Image_Desc : 1296
Image_Rect : 24
RGBA : 16
A_BitPlane : 128
RGB_map : 1624
Image_Point : 8
```
### header
### timestamp
### prhisto
Calcul et affichage en mode texte de l'histogramme d'une image.
Un exemple d'utilisation avec gnuplot serait le bienvenu.
### tag7
### environ
### mk_rgb
### mk_hgrad
## genplot2 ## genplot2
Outil de tracé pseudo-générique et farci de bugs. *WIP ME HARDLY !*

16
Tools/essayage.sh Executable file
View File

@@ -0,0 +1,16 @@
#!/bin/bash
set -e
make genplot2
cat > a.scratch << __EOT__
0 0 0
320 0 2
320 240 2
0 240 2
0 0 2
320 240 7
__EOT__
./genplot2 -v -s 640x480 a.scratch foo.tga

View File

@@ -17,8 +17,8 @@ char *strdup(const char *s);
#include "tga_outils.h" #include "tga_outils.h"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int
cherche_mot_clef(char *mot, mot_clef *liste, int *pmode, int *pnbarg) int cherche_mot_clef(char *mot, mot_clef *liste, int *pmode, int *pnbarg)
{ {
int idx = 0; int idx = 0;
@@ -48,8 +48,7 @@ fprintf(stderr, "%s : %s not found\n", __func__, mot);
return -1; return -1;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int liste_mots_clefs(mot_clef *liste, int flag)
liste_mots_clefs(mot_clef *liste, int flag)
{ {
mot_clef *pmc; mot_clef *pmc;
@@ -79,7 +78,7 @@ return 0;
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
* INPUT str string to scan for an integer * INPUT str string to scan for an integer
* pval pointer to the retrun value * pval pointer to the return value
* k * not used * * k * not used *
* *
* OUTPUT 1 successfuly make a conversion * OUTPUT 1 successfuly make a conversion
@@ -104,6 +103,31 @@ fprintf(stderr, "%s: %s: '%s' -> %ld -> %d\n",
return 1; return 1;
} }
/*::------------------------------------------------------------------::*/
/* Thu 17 Nov 2022
* input str a string like '640x480'
* pw, ph pointers to result
*
* output 0 on ok, INVALID_PARAM on error
*/
int parse_size_param(char *str, int *pw, int *ph)
{
int tw, th, foo;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' %p %p )\n", __func__,
str, pw, ph);
#endif
foo = sscanf(str, "%dx%d", &tw, &th);
if (2 != foo) {
fprintf(stderr, "%s: fail %d on '%s'\n", __func__, foo, str);
return INVALID_PARAM;
}
/* fprintf(stderr, " %d %d\n", tw, th); */
*pw = tw; *ph = th;
return 0;
}
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* input: str string to scan for four csv int /* input: str string to scan for four csv int
prect rectangle struct who need datas prect rectangle struct who need datas
@@ -135,6 +159,10 @@ cptr = strtok(cptr, ",");
while (NULL != cptr) { while (NULL != cptr) {
fprintf(stderr, "%3d %p = '%s'\n", idx, cptr, cptr); fprintf(stderr, "%3d %p = '%s'\n", idx, cptr, cptr);
foo = sscanf(cptr, "%d", &val); foo = sscanf(cptr, "%d", &val);
if (1 != foo) {
fprintf(stderr, "%s: err sscanf on '%s'\n", __func__, cptr);
exit(1);
}
/* /*
* no error check ? * no error check ?
*/ */
@@ -149,14 +177,15 @@ while (NULL != cptr) {
idx++; idx++;
} }
free(cptr);
return 0; return 0;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
static Param params[NB_PARAMS]; static Param params[NB_PARAMS];
int int parse_parametres(int argc, char *argv[], char *types, int prem)
parse_parametres(int argc, char *argv[], char *types, int prem)
{ {
int foo, idxt; int foo, idxt;
int entier; int entier;
@@ -363,11 +392,11 @@ return params[rang].p.i;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int static int verboselevel;
must_be_verbose(void)
int must_be_verbose(void)
{ {
char *envvar; char *envvar;
envvar = getenv(NOM_VAR_ENV_VERBOSE); envvar = getenv(NOM_VAR_ENV_VERBOSE);
if ((envvar!=NULL) && !strcmp(envvar, "yes")) if ((envvar!=NULL) && !strcmp(envvar, "yes"))
{ {
@@ -378,9 +407,24 @@ if ((envvar!=NULL) && !strcmp(envvar, "yes"))
} }
return 0; return 0;
} }
/* new Fri 18 Nov 2022 11:48:06 PM CET */
int set_verbosity(int level)
{
int tmplevel;
tmplevel = verboselevel;
verboselevel = level;
return tmplevel;
}
int get_verbosity(void)
{
return verboselevel;
}
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int int dump_command_line(int argc, char *argv[], int force)
dump_command_line(int argc, char *argv[], int force)
{ {
char *envvar; char *envvar;
int flag=0, foo; int flag=0, foo;
@@ -406,11 +450,9 @@ int set_new_seed(int k)
char *ptr; char *ptr;
long seed; long seed;
if (k) fprintf(stderr, "%s: k %d\n", __func__, k);
if (NULL==(ptr=getenv("FIXED_SEED"))) { if (NULL==(ptr=getenv("FIXED_SEED"))) {
/* no fixed seed in context, doing semi-random */ /* no fixed seed in context, doing semi-random */
srand(getpid()); srand(getpid() + k);
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "no FIXED_SEED, first rand is number : %d\n", rand()); fprintf(stderr, "no FIXED_SEED, first rand is number : %d\n", rand());
#endif #endif
@@ -418,10 +460,6 @@ if (NULL==(ptr=getenv("FIXED_SEED"))) {
else { else {
/* try to parse the env var */ /* try to parse the env var */
seed = strtol(ptr, NULL, 0); seed = strtol(ptr, NULL, 0);
#if DEBUG_LEVEL
fprintf(stderr, "%s : strtol(%s) -> %ld\n",
__func__, ptr, seed);
#endif
srand(seed); srand(seed);
} }

384
Tools/fractales.c Normal file
View File

@@ -0,0 +1,384 @@
/*
fractales.c
===========
*....................................................*
. warning, this is a 'work in progress' .
. .
. don't trust prototypes for building .
. serious applications... .
*....................................................*
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <tthimage.h>
#include "fractales.h"
/*::------------------------------------------------------------------::*/
void Image_fractales_print_version(int flag)
{
printf("*** Fractales (%s) v 0.0.12\n", __FILE__);
if (flag)
{
printf("\tcompiled %s , %s\n", __DATE__, __TIME__);
}
}
/*::------------------------------------------------------------------::*/
/*
* fonction de comparaison de deux variables 'double'
*/
int compare_double(double a, double b)
{
return 0;
}
/*::------------------------------------------------------------------::*/
/*
* cette fonction a été repompé (sans honte :) du livre de
* Roger T. Stevens, "Fractal Programming in C" éditée par
* M&T Books.
* Ceci dit, elle est un peu trop monolithique, puisque l'équation
* à résoudre est codée en dur.
*/
int Newton_0(Image_Desc *im, int maxiter)
{
int col, row, i;
double dcol, drow;
double Xmax, Xmin, Ymax, Ymin;
double deltaX, deltaY, denom;
double X, Y, Xsquare, Ysquare, Xold, Yold;
Xmax = Ymax = 3.5; Xmin = Ymin = -3.5;
deltaX = (Xmax-Xmin)/(double)im->width;
deltaY = (Ymax-Ymin)/(double)im->height;
for (col=0; col<im->width; col++)
{
dcol = (double)col;
for (row=0; row<im->height; row++)
{
drow = (double)row;
X = Xmin + dcol * deltaX;
Y = Ymin + drow * deltaY;
Xsquare = 0.0;
Ysquare = 0.0;
Xold = Yold = 42.0;
for (i=0; i<maxiter; i++)
{
Xsquare = X * X;
Ysquare = Y * Y;
denom = 3*((Xsquare-Ysquare)*(Xsquare-Ysquare) +
4*Xsquare*Ysquare);
if (denom < 0.0000001)
denom = 0.0000001;
X = .6666667*X + (Xsquare - Ysquare)/denom;
Y = .6666667*Y + 2*X*Y/denom;
if ((Xold==X) && (Yold==Y))
break;
} /* finbo sur maxiter */
if (X > 0)
{
Image_plotRGB(im, col, row, 0, 0, 0);
}
else
{
if (Y > 0)
Image_plotRGB(im, col, row, 255, 0, 0);
else
Image_plotRGB(im, col, row, 0, 0, 255);
}
}
if (0 == col%5)
fprintf(stderr, "newton 0: col %5d / %5d\r", col, im->width);
}
return 0;
}
/*::------------------------------------------------------------------::*/
/*
* C'est pas encore fini ce truc ?
*/
int GingerBreadMan(Image_Desc *im, int maxiter)
{
double x1, y1, x2, y2;
int iter;
x1 = 10.0;
y1 = 0.333;
for (iter=0; iter<maxiter; iter++)
{
x2 = 1.0 - y1 + abs(x1);
y2 = x1;
printf("%9g %9g\n", x2, y2);
x1 = x2;
y1 = y2;
}
return 0;
}
/*::------------------------------------------------------------------::*/
/*
En fait, il faudrait travailler sur deux images...
*/
int Image_Random_Walker_0(Image_Desc *im, Image_Desc *dst,
int nbpass, int nbsteps)
{
int pass, step, foo;
int x, y, ra, ga, ba, rb, gb, bb;
if ( (foo=Image_compare_desc(im, dst)) )
{
fprintf(stderr, "Random_Walker_0: images are differents %d\n", foo);
return foo;
}
for (pass=0; pass<nbpass; pass++)
{
x = rand() % im->width;
y = rand() % im->height;
ra = Image_R_pixel(im, x, y);
ga = Image_G_pixel(im, x, y);
ba = Image_B_pixel(im, x, y);
/* printf("\tP%d\t\tX%d\tY%d\t%d,%d,%d\n", pass, x, y, ra, ga, ba); */
for (step=0; step<nbsteps; step++)
{
x += (rand()%3)-1;
if (x<0) x += im->width;
if (x>=im->width) x -= im->width;
y += (rand()%3)-1;
if (y<0) y += im->height;
if (y>=im->height) y -= im->height;
rb = Image_R_pixel(im, x, y);
gb = Image_G_pixel(im, x, y);
bb = Image_B_pixel(im, x, y);
Image_plotRGB(dst, x, y,
(ra+rb+rb)/3, (ga+gb+gb)/3, (ba+bb+bb)/3);
}
}
return 0;
}
/*::------------------------------------------------------------------::*/
#define XMIN (-1.5)
#define XMAX (1.5)
#define YMIN (-1.5)
#define YMAX (1.5)
int Image_Julia_0_0(Image_Desc *im, RGB_map *pmap, int fuzz,
double cx, double cy)
{
int col, row;
double deltaX, deltaY, dx, dy, x2, y2;
long debut, fin;
int iter, r, g, b, maxiter;
debut = time(NULL);
fprintf(stderr, "Julia_0_0: %dx%d\n", im->width, im->height);
deltaX = (XMAX - XMIN) / im->width;
deltaY = (YMAX - YMIN) / im->height;
maxiter = 0;
/*
* si pas de palette définie, en créer une ?
*/
for (row=0; row<im->height; row++)
{
dy = YMIN + (double)row * deltaY;
for (col=0; col<im->width; col++)
{
#if DEBUG_LEVEL
printf("%5d %5d ", row, col);
#endif
dx = XMIN + (double)col * deltaX;
iter = 0;
x2 = y2 = 0.0;
while ( (iter < fuzz) &&
((x2 + y2) < 4.0) )
{
x2 = dx * dx;
y2 = dy * dy;
dx = 2 * dx * dy + cx;
dy = x2 - y2 + cy;
iter++;
}
if (iter > maxiter)
maxiter = iter;
if (iter >= fuzz)
{
r = g = b = 255;
}
else
{
r = pmap->red[iter%pmap->nbre];
g = pmap->green[iter%pmap->nbre];
b = pmap->blue[iter%pmap->nbre];
}
Image_plotRGB(im, col, row, r, g, b);
#if DEBUG_LEVEL
printf(" %3d \r", iter);
#endif
}
}
fin = time(NULL);
printf("duree du calcul: %ld secondes, maxiter: %d\n", fin-debut, maxiter);
return 0;
}
/*::------------------------------------------------------------------::*/
#define XA -2.0
#define XB 2.0
#define YA -2.0
#define YB 1.3
int Image_Mandelbrot_0(Image_Desc *image, int maxiter)
{
int Y, X;
int r, g, b;
double zr, zi, fx, fy, real, imag, fiter, dist2;
long debut, fin, temps; /* pour chronometrer */
int iter, out, foo;
double tmpr, tmpi;
debut = time(NULL);
out = 0;
for (Y=0; Y<image->height; Y++)
{
fprintf(stderr, "ligne %4d sur %d\r", Y, image->height);
fy = (double)Y;
real = ( fy / (double)image->height * (YB-YA) ) + YA;
for (X=0; X<image->width; X++)
{
fx = (double)X;
imag = ( fx / (double)image->width * (XB-XA) ) + XA;
iter = 0;
zr = zi = 0.0;
do
{
iter++;
dist2 = zr*zr + zi*zi;
if (dist2 > 4.0)
{
out++;
break;
}
/*
* calculer le mandelbrot
* ----------------------
* la formule est:
* z0 = 0 + 0i
* z1 = z0^2 + c;
* ...
*/
tmpr = zr*zr - zi*zi;
tmpi = 2.0 * zr * zi;
zr = tmpr + real;
zi = tmpi + imag;
} while (iter < maxiter);
fiter = (double)iter / (double)maxiter;
Image_color_x(zr, zi, &r, &g, &b);
Image_plotRGB(image, X, Y, r, g, b);
}
fflush(stderr);
}
fin = time(NULL);
temps = fin - debut;
if (temps < 500)
{
foo = 's';
}
else
{
foo = 'm';
temps /= 60;
}
printf("\nMandelbrot_0: temps d'execution = %ld %c\n", temps, foo);
printf("Mandelbrot_0: nombre de points dehors = %d\n", out);
return 0;
}
/*::------------------------------------------------------------------::*/
int Lorenz_Orbits(Image_Desc *img, int iters,
double a, double b, double c, double dt)
{
int pass;
double dx, dy, dz, dxp, dyp, dzp;
FILE *fp;
if (NULL == (fp=fopen("lorenz.dat", "w"))) {
perror("lorenz datafile");
exit(1);
}
fprintf(stderr, "%s ( %p %d / %f %f %f %f )\n", __func__, img, iters,
a, b, c, dt);
dx = dy = dz = 0.0001;
for (pass=0; pass<iters; pass++) {
fprintf(fp, "%6d %8f %8f %8f\n", pass, dx, dy, dz);
dxp = dx - (a*dx + a*dy) * dt;
dyp = dy + (b*dx - dy - dz*dz) * dt;
dzp = dz - (c*dz + dx*dy) * dt;
dx = dxp, dy = dyp, dz = dzp;
}
fclose(fp);
return 42;
}
/*::------------------------------------------------------------------::*/
/*
* et un PopCorn ?
*/
/*::------------------------------------------------------------------::*/

25
Tools/fractales.h Normal file
View File

@@ -0,0 +1,25 @@
/*
fractales.h
-----------
*....................................................*
. warning, this is a 'work in progress' .
. don't trust prototypes for building .
. serious applications... .
*....................................................*
*/
void Image_fractales_print_version(int flag);
int GingerBreadMan(Image_Desc *im, int maxiter);
int Image_Random_Walker_0(Image_Desc *im, Image_Desc *dst,
int nbpass, int nbsteps);
int Image_Julia_0_0(Image_Desc *, RGB_map *, int, double, double);
int Image_Mandelbrot_0(Image_Desc *image, int maxiter);
int Newton_0(Image_Desc *im, int maxiter);
int Lorenz_Orbits(Image_Desc *img, int iters,
double a, double b, double c, double dt);

View File

@@ -6,18 +6,21 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h>
#include <getopt.h>
#include "tga_outils.h" #include "tga_outils.h"
#define XMIN 0 #define XMIN 0
#define YMIN 0 #define YMIN 0
#define XMAX 640 /* constant from a 'dddd' */ #define XMAX 800 /* constant from a 'dddd' */
#define YMAX 480 /* constant from a 'dddd' */ #define YMAX 600 /* constant from a 'dddd' */
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
static Image_Desc *image; static Image_Desc *image;
static RGB_map map; static RGB_map map;
static int curX, curY; static int curX, curY;
static int verbeux;
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
int initgr(int largeur, int hauteur) int initgr(int largeur, int hauteur)
{ {
@@ -28,7 +31,7 @@ if (NULL==(image=Image_alloc(largeur, hauteur, 3))) {
exit(3); exit(3);
} }
printf("Genplot2: initgr %d %d\n", largeur, hauteur); if (verbeux) fprintf(stderr, "Genplot2: initgr %d %d\n", largeur, hauteur);
for (foo=0; foo<8; foo++) { for (foo=0; foo<8; foo++) {
#if DEBUG_LEVEL #if DEBUG_LEVEL
printf("\tPal(%d) = ", foo); printf("\tPal(%d) = ", foo);
@@ -56,14 +59,14 @@ fprintf(stderr, "\tMOVE %5d %5d\n", x, y);
curX = x; curY = y; curX = x; curY = y;
return 0; return 0;
} }
/*::------------------------------------------------------------------::*/
int draw(int x, int y, int color) int draw(int x, int y, int color)
{ {
RGBA rgba; RGBA rgba;
int idx; int idx;
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "\tDRAW %5d %5d to %5d %5d\n", curX, curY, x, y); fprintf(stderr, "\tdraw %5d %5d to %5d %5d\n", curX, curY, x, y);
#endif #endif
idx = color % 8; idx = color % 8;
@@ -74,7 +77,16 @@ if (idx != color) {
rgba.r = map.red[color]; rgba.r = map.red[color];
rgba.g = map.green[color]; rgba.g = map.green[color];
rgba.b = map.blue[color]; rgba.b = map.blue[color];
Image_draw_line(image, curX, curY, x, y, &rgba);
/* new Mon 19 Dec 2022 12:53:32 PM CET
check for special cases: eg horizontal lines
*/
if (y == curY) {
Image_H_line(image, curX, x, y, &rgba);
}
else {
Image_draw_line(image, curX, curY, x, y, &rgba);
}
curX = x; curY = y; curX = x; curY = y;
return 0; return 0;
} }
@@ -82,35 +94,70 @@ return 0;
int endgr(char *filename) int endgr(char *filename)
{ {
fprintf(stderr, "genplot2 is saving to '%s'\n", filename); if (verbeux) fprintf(stderr, "genplot2 is saving to '%s'\n", filename);
Image_TGA_save(filename, image, 0); Image_TGA_save(filename, image, 0);
return 0; return 0;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
void help_me(char *proggy)
{
fprintf(stderr, "%s build %s %s\n", proggy, __DATE__, __TIME__);
puts("options:");
puts("\t-v\t\tdo some blablage");
puts("\t-s WxH\t\tset image size");
}
/*::------------------------------------------------------------------::*/
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
char *filename, *image; char *filename, *image;
FILE *fp; FILE *fp;
int outw, outh; /* size of output pic */
double x, y, xmin, ymin, xmax, ymax; double x, y, xmin, ymin, xmax, ymax;
double fx, fy, f, X, Y; double fx, fy, f, X, Y;
double xC, yC, XC, YC, c1, c2; double xC, yC, XC, YC, c1, c2;
int v, nbp, opt, foo;
int v, nbp; /* setting some default values */
outw = XMAX; outh = YMAX;
filename = "a.scratch"; image = "image.tga";
/*---------- processing command line arguments */ /*---------- processing command line arguments */
if (argc<=1) filename = "a.scratch"; while ((opt = getopt(argc, argv, "hs:v")) != -1) {
else filename = argv[1]; switch (opt) {
case 'h':
help_me(argv[0]);
exit(0);
case 's': /* size of output pic */
foo = parse_size_param(optarg, &outw, &outh);
break;
case 'v':
verbeux = 1;
break;
default:
fprintf(stderr, "invalid opt %d\n", opt);
exit(1);
break;
}
}
if (argc<=optind) filename = "a.scratch";
else filename = argv[optind];
if (argc<=2) image = "image.tga"; if (argc<=optind+1) image = "image.tga";
else image = argv[2]; else image = argv[optind+1];
/*----------- giving to the yuser some useless informations --- */ /*----------- giving to the yuser some useless informations --- */
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "*** Genplot2 v 1.0.8 (dwtfywl) 1995,2010,2022 TontonTh \n"); fprintf(stderr, "*** Genplot2 v 1.0.10 (dwtfywl) 1995,2010,2022 TontonTh \n");
fprintf(stderr, "hardcoded picsize : %d %d\n", XMAX, YMAX);
#endif #endif
if (verbeux) {
fprintf(stderr, "argc %d optind %d file '%s' image '%s'\n",
argc, optind, filename, image);
fprintf(stderr, " picsize : %d %d\n", outw, outh);
}
/*----------- opening input file and getting MIN and MAX values */ /*----------- opening input file and getting MIN and MAX values */
@@ -120,8 +167,8 @@ if ((fp = fopen(filename, "r"))==NULL) {
} }
nbp = 0; nbp = 0;
xmin = 9999999; xmax = -9999999; xmin = 9999999.99; xmax = -9999999.99;
ymin = 9999999; ymax = -9999999; ymin = 9999999.99; ymax = -9999999.99;
while ( fscanf(fp, "%lf %lf %d", &x, &y, &v) == 3 ) { while ( fscanf(fp, "%lf %lf %d", &x, &y, &v) == 3 ) {
nbp++; nbp++;
@@ -137,20 +184,26 @@ if (nbp == 0)
fprintf(stderr, "omg, I'v found _ZERO_ points for plotting...\n"); fprintf(stderr, "omg, I'v found _ZERO_ points for plotting...\n");
exit(2); exit(2);
} }
if (nbp == 1)
{
fprintf(stderr, "omg, I can't do any job with only one point.\n");
exit(2);
}
fprintf(stderr, "Genplot2: found %d points\n", nbp); fprintf(stderr, "Genplot2: found %d points\n", nbp);
/*---------- computing coefficients (temporary hack !-) */ /*---------- computing coefficients (temporary hack !-) */
fx = (XMAX-XMIN-1)/(xmax-xmin); fx = (outw-XMIN-1)/(xmax-xmin);
fy = (YMAX-YMIN-1)/(ymax-ymin); fy = (outh-YMIN-1)/(ymax-ymin);
#if DEBUG_LEVEL #if DEBUG_LEVEL
fprintf(stderr, "fc = %12f fy = %12f\n", fx, fy); fprintf(stderr, "fc = %12f fy = %12f\n", fx, fy);
#endif #endif
f = (fx<fy?fx:fy); f = (fx<fy?fx:fy);
xC = 0.5*(xmin+xmax); yC = 0.5*(ymin+ymax); xC = 0.5*(xmin+xmax); yC = 0.5*(ymin+ymax);
XC = 0.5*(XMIN+XMAX); YC = 0.5*(YMIN+YMAX); XC = 0.5*(XMIN+outw); YC = 0.5*(YMIN+outh);
c1 = XC-f*xC; c2 = YC-f*yC; c1 = XC-f*xC; c2 = YC-f*yC;
@@ -159,7 +212,7 @@ fprintf(stderr, "c1 = %12f c2 = %12f\n", c1, c2);
#endif #endif
/*------------- and now, plotting the image ! */ /*------------- and now, plotting the image ! */
initgr(XMAX, YMAX); initgr(outw, outh);
fp = fopen(filename, "r"); fp = fopen(filename, "r");
puts(""); puts("");

58
Tools/tga_2x2contrast.c Normal file
View File

@@ -0,0 +1,58 @@
/*
2x2 contrast enhancer
---------------------
:::::::::::::::::::::::::::::::::::::::::
:::::: NEED ACCURATE DOCUMENTATION ::::::
:::::::::::::::::::::::::::::::::::::::::
*/
#include <stdio.h>
#include <stdlib.h>
#include "tga_outils.h"
/*::------------------------------------------------------------------::*/
void usage(void)
{
fprintf(stderr, "* tga_2x2contrast v 0.18 [%s] %s\n",
TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT);
fprintf(stderr, "Usage:\n\ttga_2x2contrast <src.tga> <dst.tga>\n");
Image_print_version(0);
exit(5);
}
/*::------------------------------------------------------------------::*/
int main(int argc, char *argv[])
{
Image_Desc *src, *dst;
int foo;
dump_command_line(argc, argv, 0);
if (argc != 3)
usage();
if ( (src=Image_TGA_alloc_load(argv[1])) == NULL )
{
fprintf(stderr, "tga_2x2contrast: can't load \"%s\" ...\n", argv[2]);
exit(1);
}
if ( (dst=Image_clone(src, 1)) == NULL )
{
exit(1);
}
foo = Image_2x2_contrast(src, dst);
if (foo)
{
fprintf(stderr, "tga_2x2contrast: %d / %s\n", foo, Image_err2str(foo));
}
foo = Image_TGA_save(argv[2], dst, 0);
exit (0);
}
/*::------------------------------------------------------------------::*/

Some files were not shown because too many files have changed in this diff Show More