Compare commits
No commits in common. "97ad716bd2b7c3970c1bc8cd713084314e4d5f00" and "f4c38251868bbd7bb2995b5921615da83fae93e7" have entirely different histories.
97ad716bd2
...
f4c3825186
@ -1,4 +1,4 @@
|
|||||||
# libtthimage, la doc
|
# libtthimage
|
||||||
|
|
||||||
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. Il est encore loin d'être parfait.
|
en ligne de commande.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@ -28,4 +28,4 @@ dans le fichier Paramakes.mk !
|
|||||||
|
|
||||||
## Utilisation
|
## Utilisation
|
||||||
|
|
||||||
??? *Insérez ici quelques exemples d'utilisation des tools.*
|
???
|
||||||
|
2
Lib/.gitignore
vendored
2
Lib/.gitignore
vendored
@ -1,6 +1,4 @@
|
|||||||
|
|
||||||
*.png
|
*.png
|
||||||
*.gif
|
|
||||||
|
|
||||||
cflow.txt
|
cflow.txt
|
||||||
|
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
# The tTh image processing 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
|
Look at the `Makefile` for no more explanations.
|
||||||
[`tthimage.h`](../tthimage.h).
|
|
||||||
|
|
||||||
|
|
||||||
## Text primitives
|
## Text primitives
|
||||||
|
56
Lib/essais.c
56
Lib/essais.c
@ -216,17 +216,18 @@ 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -581,30 +582,32 @@ 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("warp-essai-0.tga", dst, 0);
|
Image_TGA_save("Pictures/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("warp-center-rotate.tga", dst, 0);
|
Image_TGA_save("Pictures/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("warp-shift-xy.tga", dst, 0);
|
Image_TGA_save("Pictures/warp-shift-xy.tga", dst, 0);
|
||||||
foo = Image_shift_x(src, dst, ax);
|
foo = Image_shift_x(src, dst, ax);
|
||||||
Image_TGA_save("warp-shift-x.tga", dst, 0);
|
Image_TGA_save("Pictures/warp-shift-x.tga", dst, 0);
|
||||||
foo = Image_shift_y(src, dst, ay);
|
foo = Image_shift_y(src, dst, ay);
|
||||||
Image_TGA_save("warp-shift-y.tga", dst, 0);
|
Image_TGA_save("Pictures/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;
|
||||||
}
|
}
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
@ -792,7 +795,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;
|
||||||
@ -809,7 +812,8 @@ 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);
|
||||||
}
|
}
|
||||||
@ -817,11 +821,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("aaaa-classif0.tga", dst, 0);
|
Image_TGA_save("Pictures/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("aaaa-classif1.tga", dst, 0);
|
Image_TGA_save("Pictures/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);
|
||||||
@ -1155,7 +1159,7 @@ Image_dump_descriptor(source, "just after load");
|
|||||||
* 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;
|
wf = source->width; hf = (source->height) * 4;
|
||||||
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;
|
||||||
@ -1349,7 +1353,8 @@ Image_DeAllocate(finale); free(finale);
|
|||||||
return 42;
|
return 42;
|
||||||
}
|
}
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
int Test_des_tamppools(char *imgname, int param)
|
int
|
||||||
|
Test_des_tamppools(char *imgname, int param)
|
||||||
{
|
{
|
||||||
void *ptr;
|
void *ptr;
|
||||||
int foo;
|
int foo;
|
||||||
@ -1372,7 +1377,7 @@ int Test_des_filtres(char *srcname, int k)
|
|||||||
Image_Desc *src, *dst;
|
Image_Desc *src, *dst;
|
||||||
int foo;
|
int foo;
|
||||||
|
|
||||||
printf("=============== Filtres =====[ %s ]====[ %d ]====\n", srcname, k);
|
printf("=============== LES FILTRES =====[ %s ]====[ %d ]====\n", srcname, k);
|
||||||
|
|
||||||
src = Image_TGA_alloc_load(srcname);
|
src = Image_TGA_alloc_load(srcname);
|
||||||
if (NULL == src) {
|
if (NULL == src) {
|
||||||
@ -1392,11 +1397,8 @@ foo = Image_filtre_Prewitt(src, dst, 5);
|
|||||||
Image_TGA_save("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("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("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);
|
||||||
@ -1492,17 +1494,3 @@ 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);
|
|
||||||
}
|
|
||||||
/* ============================== */
|
|
||||||
/*::------------------------------------------------------------------::*/
|
|
||||||
|
|
||||||
|
@ -27,8 +27,6 @@ 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);
|
||||||
|
24
Lib/foo.c
24
Lib/foo.c
@ -17,12 +17,14 @@
|
|||||||
*/
|
*/
|
||||||
#define PIXEL_COPY(ip, ix, iy, op, ox, oy) \
|
#define PIXEL_COPY(ip, ix, iy, op, ox, oy) \
|
||||||
do { \
|
do { \
|
||||||
(op->Rpix[oy])[ox] = (ip->Rpix[iy])[ix]; \
|
op->Rpix[oy][x] = ip->Rpix[y][x]; \
|
||||||
(op->Gpix[oy])[ox] = (ip->Gpix[iy])[ix]; \
|
op->Gpix[oy][x] = ip->Gpix[y][x]; \
|
||||||
(op->Bpix[oy])[ox] = (ip->Bpix[iy])[ix]; \
|
op->Bpix[oy][x] = ip->Bpix[y][x]; \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
#define SZPIC 4096
|
#define SZPIC 5777
|
||||||
|
|
||||||
|
double tthi_dtime(void);
|
||||||
|
|
||||||
void essai_pixcopy(int usemacro)
|
void essai_pixcopy(int usemacro)
|
||||||
{
|
{
|
||||||
@ -30,13 +32,11 @@ Image_Desc *alice, *bob;
|
|||||||
int x, y, foo;
|
int x, y, foo;
|
||||||
double T0, T1, perpix;
|
double T0, T1, perpix;
|
||||||
long count;
|
long count;
|
||||||
char *fname;
|
|
||||||
|
|
||||||
alice = Image_alloc(SZPIC, SZPIC, IMAGE_RGB);
|
alice = Image_alloc(SZPIC, SZPIC, IMAGE_RGB);
|
||||||
bob = Image_alloc(SZPIC, SZPIC, IMAGE_RGB);
|
bob = Image_alloc(SZPIC, SZPIC, IMAGE_RGB);
|
||||||
|
|
||||||
Image_pattern_000(alice, 0);
|
Image_pattern_000(alice, rand());
|
||||||
Image_TGA_save("alice.tga", alice, 0);
|
|
||||||
|
|
||||||
T0 = tthi_dtime();
|
T0 = tthi_dtime();
|
||||||
count = 0L;
|
count = 0L;
|
||||||
@ -48,7 +48,6 @@ if (usemacro) {
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fname = "bob1.tga";
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
for (y=0; y<SZPIC; y++) {
|
for (y=0; y<SZPIC; y++) {
|
||||||
@ -57,18 +56,17 @@ else {
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fname = "bob0.tga";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
T1 = tthi_dtime();
|
T1 = tthi_dtime();
|
||||||
|
|
||||||
foo = Image_TGA_save(fname, bob, 0);
|
foo = Image_TGA_save("bob.tga", bob, 0);
|
||||||
if (foo) {
|
if (foo) {
|
||||||
fprintf(stderr, "%s: save -> %d\n", __func__, foo);
|
fprintf(stderr, "%s: save -> %d\n", __func__, foo);
|
||||||
}
|
}
|
||||||
|
|
||||||
perpix = ((T1-T0) / (double)count) * 1e6;
|
perpix = (T1-T0) / (double)count;
|
||||||
fprintf(stderr, "%s : %10ld pixels, elapsed %9.6f seconds ==> %9.6f µs/pix\n",
|
fprintf(stderr, "%s : %10ld pixels, elapsed %9.6f seconds ==> %5.3g µs/ppix\n",
|
||||||
usemacro ? "macro" : "func ",
|
usemacro ? "macro" : "func ",
|
||||||
count, T1-T0, perpix);
|
count, T1-T0, perpix);
|
||||||
|
|
||||||
@ -81,7 +79,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
fprintf(stderr, "*********** %s ************\n", argv[0]);
|
fprintf(stderr, "******** %s is running *********\n", argv[0]);
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
fprintf(stderr, "argument: %s\n", argv[1]);
|
fprintf(stderr, "argument: %s\n", argv[1]);
|
||||||
|
110
Lib/image.c
110
Lib/image.c
@ -93,7 +93,8 @@ 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_alloc(int width, int height, int type)
|
Image_Desc *
|
||||||
|
Image_alloc(int width, int height, int type)
|
||||||
{
|
{
|
||||||
Image_Desc *header;
|
Image_Desc *header;
|
||||||
int foo;
|
int foo;
|
||||||
@ -191,18 +192,19 @@ return header;
|
|||||||
/*
|
/*
|
||||||
This fonction build another image from a model.
|
This fonction build another image from a model.
|
||||||
*/
|
*/
|
||||||
Image_Desc * Image_clone (Image_Desc *src, int copy)
|
Image_Desc *
|
||||||
|
Image_clone (Image_Desc *src, int copy)
|
||||||
{
|
{
|
||||||
Image_Desc *image;
|
Image_Desc *image;
|
||||||
|
|
||||||
if ( NULL == src )
|
if ( src==NULL )
|
||||||
{
|
{
|
||||||
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 ( NULL == image )
|
if ( image==NULL )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Image_clone: cloned descriptor is NULL\n");
|
fprintf(stderr, "Image_clone: cloned descriptor is NULL\n");
|
||||||
exit(5);
|
exit(5);
|
||||||
@ -244,16 +246,20 @@ 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 Image_clear( Image_Desc *image, int r, int g, int b )
|
int
|
||||||
|
Image_clear( Image_Desc *image, int r, int g, int b )
|
||||||
{
|
{
|
||||||
int x, y;
|
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;
|
||||||
@ -263,9 +269,12 @@ 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 (x=0; x<image->width; x++) {
|
for (y=0; y<image->height; y++)
|
||||||
|
{
|
||||||
|
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;
|
||||||
@ -300,7 +309,6 @@ if (IMAGE_RGB != img->type) {
|
|||||||
|
|
||||||
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++) {
|
||||||
/* please, use memset here */
|
|
||||||
(img->Rpix[y])[x] = rgba->r;
|
(img->Rpix[y])[x] = rgba->r;
|
||||||
(img->Gpix[y])[x] = rgba->g;
|
(img->Gpix[y])[x] = rgba->g;
|
||||||
(img->Bpix[y])[x] = rgba->b;
|
(img->Bpix[y])[x] = rgba->b;
|
||||||
@ -313,7 +321,8 @@ 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 Image_set_comment(Image_Desc *image, char *text)
|
int
|
||||||
|
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;
|
||||||
@ -322,7 +331,8 @@ 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 Image_plot_gray(Image_Desc *img, int x, int y, int v)
|
int
|
||||||
|
Image_plot_gray(Image_Desc *img, int x, int y, int v)
|
||||||
{
|
{
|
||||||
if ( x<0 || y<0 || x>=img->width || y>=img->height )
|
if ( x<0 || y<0 || x>=img->width || y>=img->height )
|
||||||
{
|
{
|
||||||
@ -342,7 +352,8 @@ 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();
|
||||||
@ -357,7 +368,8 @@ 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);
|
||||||
@ -375,9 +387,11 @@ if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
|
|||||||
return OLL_KORRECT;
|
return OLL_KORRECT;
|
||||||
}
|
}
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
int Image_getRGB(Image_Desc *img, int x, int y, int *pr, int *pg, int *pb)
|
int
|
||||||
|
Image_getRGB(Image_Desc *img, int x, int y, int *pr, int *pg, int *pb)
|
||||||
{
|
{
|
||||||
if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
|
if ( x<0 || y<0 || x>=img->width || y>=img->height )
|
||||||
|
{
|
||||||
/* may be an #if DEBUG_LEVEL here ? */
|
/* 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
|
||||||
@ -393,9 +407,11 @@ if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
|
|||||||
return OLL_KORRECT;
|
return OLL_KORRECT;
|
||||||
}
|
}
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
int Image_getRGBA(Image_Desc *img, int x, int y, int *pr, int *pg, int *pb, int *pa)
|
int
|
||||||
|
Image_getRGBA(Image_Desc *img, int x, int y, int *pr, int *pg, int *pb, int *pa)
|
||||||
{
|
{
|
||||||
if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
|
if ( x<0 || y<0 || x>=img->width || y>=img->height )
|
||||||
|
{
|
||||||
fprintf(stderr, "ERR GETRGBA X %4d Y %4d\n", x, y);
|
fprintf(stderr, "ERR GETRGBA X %4d Y %4d\n", x, y);
|
||||||
#if FORCE_ABORT
|
#if FORCE_ABORT
|
||||||
abort();
|
abort();
|
||||||
@ -403,9 +419,10 @@ 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",
|
{
|
||||||
__func__, img->type, Image_type2str(img->type));
|
fprintf(stderr, "Image get RGBA: bad image type: %d, %s\n",
|
||||||
|
img->type, Image_type2str(img->type));
|
||||||
#if FORCE_ABORT
|
#if FORCE_ABORT
|
||||||
abort();
|
abort();
|
||||||
#endif
|
#endif
|
||||||
@ -426,14 +443,16 @@ 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;
|
||||||
@ -447,36 +466,44 @@ return OLL_KORRECT;
|
|||||||
/*
|
/*
|
||||||
lecture d'une des composantes de l'image.
|
lecture d'une des composantes de l'image.
|
||||||
*/
|
*/
|
||||||
int Image_R_pixel(Image_Desc *img, int x, int y)
|
int
|
||||||
|
Image_R_pixel(Image_Desc *img, int x, int y)
|
||||||
{
|
{
|
||||||
if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
|
if ( x<0 || y<0 || x>=img->width || y>=img->height )
|
||||||
|
{
|
||||||
fprintf(stderr, "ERR READ R PIX X%d Y%d\n", x, y);
|
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 Image_G_pixel(Image_Desc *img, int x, int y)
|
int
|
||||||
|
Image_G_pixel(Image_Desc *img, int x, int y)
|
||||||
{
|
{
|
||||||
if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
|
if ( x<0 || y<0 || x>=img->width || y>=img->height )
|
||||||
|
{
|
||||||
fprintf(stderr, "ERR READ G PIX X%d Y%d\n", x, y);
|
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 Image_B_pixel(Image_Desc *img, int x, int y)
|
int
|
||||||
|
Image_B_pixel(Image_Desc *img, int x, int y)
|
||||||
{
|
{
|
||||||
if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
|
if ( x<0 || y<0 || x>=img->width || y>=img->height )
|
||||||
|
{
|
||||||
fprintf(stderr, "ERR READ B PIX X%d Y%d\n", x, y);
|
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 Image_A_pixel(Image_Desc *img, int x, int y)
|
int
|
||||||
|
Image_A_pixel(Image_Desc *img, int x, int y)
|
||||||
{
|
{
|
||||||
if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
|
if ( x<0 || y<0 || x>=img->width || y>=img->height )
|
||||||
|
{
|
||||||
fprintf(stderr, "ERR A PIX X%d Y%d\n", x, y);
|
fprintf(stderr, "ERR A PIX X%d Y%d\n", x, y);
|
||||||
return OUT_OF_IMAGE;
|
return OUT_OF_IMAGE;
|
||||||
}
|
}
|
||||||
@ -518,7 +545,7 @@ return 0;
|
|||||||
}
|
}
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
/*
|
/*
|
||||||
* no boundary control ? XXX
|
* no boundary control ?
|
||||||
*/
|
*/
|
||||||
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,16 +563,18 @@ 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 = "%s: Image at %p have no 'Dead Beef' in it\n";
|
char *fmt = "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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -563,7 +592,8 @@ 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 Image_DeAllocate(Image_Desc *im)
|
int
|
||||||
|
Image_DeAllocate(Image_Desc *im)
|
||||||
{
|
{
|
||||||
int line;
|
int line;
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ else
|
|||||||
|
|
||||||
Image_start_chrono("Essai", 0);
|
Image_start_chrono("Essai", 0);
|
||||||
|
|
||||||
for (idx=0; idx<3; idx++) {
|
for (idx=0; idx<1; idx++) {
|
||||||
foo = Test_Egalisations(fichier, 0);
|
foo = Test_Egalisations(fichier, 0);
|
||||||
fprintf(stderr, " essai egalisation -> %d\n", foo);
|
fprintf(stderr, " essai egalisation -> %d\n", foo);
|
||||||
foo = Essai_Televisions(fichier, 10);
|
foo = Essai_Televisions(fichier, 10);
|
||||||
@ -64,24 +64,17 @@ for (idx=0; idx<3; idx++) {
|
|||||||
fprintf(stderr, " essai filtres -> %d\n", foo);
|
fprintf(stderr, " essai filtres -> %d\n", foo);
|
||||||
foo = Test_RGBmask(fichier);
|
foo = Test_RGBmask(fichier);
|
||||||
fprintf(stderr, " essai rgb mask -> %d\n", foo);
|
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);
|
|
||||||
|
|
||||||
|
fprintf(stderr, "********* %s: fin passe %d\n", argv[0], idx);
|
||||||
fprintf(stderr, "\n*************** %s: fin passe %d ******\n\n",
|
|
||||||
argv[0], idx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
foo = Essai_color_2_map(fichier, idx);
|
|
||||||
fprintf(stderr, " essai col2map -> %d\n", foo);
|
|
||||||
|
|
||||||
foo = test_du_jpeg_reader("in.jpeg");
|
foo = test_du_jpeg_reader("in.jpeg");
|
||||||
fprintf(stderr, " essai lecture jpeg -> %d\n", foo);
|
fprintf(stderr, " essai lecture jpeg -> %d\n", foo);
|
||||||
|
|
||||||
|
foo = Test_Dithering(fichier, 17);
|
||||||
|
fprintf(stderr, "essai dithering -> %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);
|
||||||
|
|
||||||
|
@ -1,20 +1,14 @@
|
|||||||
# Some useless tests ?
|
# Some useless tests
|
||||||
|
|
||||||
<u>Tester, c'est douter.</u>
|
Tester, c'est douter.
|
||||||
|
|
||||||
## État des lieux
|
## État des lieux
|
||||||
|
|
||||||
Pas grand chose pour le moment. Mais comme j'utilise régulièrement
|
Pas grand chose.
|
||||||
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
|
Dans le répertoire `Lib/` il y a un `essais.c` assez prometteur.
|
||||||
[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.
|
|
||||||
|
@ -81,8 +81,8 @@ tga_extract: tga_extract.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_info: tga_info.c $(DEPS) fonctions.o
|
||||||
gcc $(CFLAGS) $< ../libimage.a fonctions.o -lm -o $@
|
# gcc $(CFLAGS) $< ../libimage.a fonctions.o -lm -o $@
|
||||||
|
|
||||||
tga_pattern: tga_pattern.c $(DEPS) fonctions.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 $@
|
||||||
|
@ -50,9 +50,9 @@ La gestion de la ligne de commande est désastreuse. **À REFAIRE**
|
|||||||
|
|
||||||
## tga_cadre
|
## tga_cadre
|
||||||
|
|
||||||
Il existe pas mal de façons de mettre un cadre sur l'image,
|
Pas mal de façons de mettre un cadre sur l'image.
|
||||||
avec un niveau de kitchitude assez élevé.
|
Niveau de kitchitude assez élevé.
|
||||||
Les paramètres sont mal documentés.
|
Paramètres mal documentés.
|
||||||
|
|
||||||
## tga_combine
|
## tga_combine
|
||||||
|
|
||||||
@ -61,8 +61,7 @@ Usage:
|
|||||||
tga_combine s1.tga s2.tga MODE d.tga [PARAMS]
|
tga_combine s1.tga s2.tga MODE d.tga [PARAMS]
|
||||||
```
|
```
|
||||||
Il existe plein de façon de combiner deux images, la commande
|
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.
|
`testtga list` vous les fera découvrir, la cinquième va vous étonner.
|
||||||
Les paramètres sont mal documentés.
|
|
||||||
|
|
||||||
## tga_dither
|
## tga_dither
|
||||||
|
|
||||||
@ -78,16 +77,11 @@ Attendu avec impatience, il aura le support complet des PNG. Un jour...
|
|||||||
|
|
||||||
## 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,
|
Pour les POViste acharnés.
|
||||||
[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
|
## tga_to_text
|
||||||
|
|
||||||
@ -108,11 +102,6 @@ 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
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
http://la.buvette.org/devel/libimage/
|
http://la.buvette.org/devel/libimage/
|
||||||
*/
|
*/
|
||||||
#ifndef IMAGE_VERSION_STRING
|
#ifndef IMAGE_VERSION_STRING
|
||||||
#define IMAGE_VERSION_STRING "0.4.51 pl 91"
|
#define IMAGE_VERSION_STRING "0.4.51 pl 85"
|
||||||
|
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
/*
|
/*
|
||||||
@ -315,15 +315,10 @@ int Image_G_pixel(Image_Desc *img, int x, int y);
|
|||||||
int Image_B_pixel(Image_Desc *img, int x, int y);
|
int Image_B_pixel(Image_Desc *img, int x, int y);
|
||||||
int Image_A_pixel(Image_Desc *img, int x, int y);
|
int Image_A_pixel(Image_Desc *img, int x, int y);
|
||||||
|
|
||||||
/* Mon Aug 12 2024 : this function may be rewrited with a macro ? */
|
|
||||||
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);
|
||||||
|
|
||||||
int Image_compare_desc(Image_Desc *a, Image_Desc *b);
|
int Image_compare_desc(Image_Desc *a, Image_Desc *b);
|
||||||
|
|
||||||
/*::------------------------------------------------------------------::*/
|
|
||||||
/* module functions.c */
|
|
||||||
|
|
||||||
double tthi_dtime(void);
|
|
||||||
|
|
||||||
/*::------------------------------------------------------------------::*/
|
/*::------------------------------------------------------------------::*/
|
||||||
/* module pixels.c */
|
/* module pixels.c */
|
||||||
|
Loading…
Reference in New Issue
Block a user