Compare commits

...

7 Commits

Author SHA1 Message Date
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
12 changed files with 144 additions and 126 deletions

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

2
Lib/.gitignore vendored
View File

@ -1,4 +1,6 @@
*.png *.png
*.gif
cflow.txt cflow.txt

View File

@ -1,8 +1,9 @@
# 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.
Look at the `Makefile` for no more explanations. More pertinent informations can be found in
[`tthimage.h`](../tthimage.h).
## Text primitives ## Text primitives

View File

@ -216,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);
} }
} }
@ -582,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;
} }
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
@ -795,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;
@ -812,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);
} }
@ -821,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);
@ -1159,7 +1155,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) * 4; 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;
@ -1353,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;
@ -1377,7 +1372,7 @@ 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) {
@ -1397,8 +1392,11 @@ 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);
@ -1494,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);

View File

@ -17,14 +17,12 @@
*/ */
#define PIXEL_COPY(ip, ix, iy, op, ox, oy) \ #define PIXEL_COPY(ip, ix, iy, op, ox, oy) \
do { \ do { \
op->Rpix[oy][x] = ip->Rpix[y][x]; \ (op->Rpix[oy])[ox] = (ip->Rpix[iy])[ix]; \
op->Gpix[oy][x] = ip->Gpix[y][x]; \ (op->Gpix[oy])[ox] = (ip->Gpix[iy])[ix]; \
op->Bpix[oy][x] = ip->Bpix[y][x]; \ (op->Bpix[oy])[ox] = (ip->Bpix[iy])[ix]; \
} while (0) } while (0)
#define SZPIC 5777 #define SZPIC 4096
double tthi_dtime(void);
void essai_pixcopy(int usemacro) void essai_pixcopy(int usemacro)
{ {
@ -32,11 +30,13 @@ 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, rand()); Image_pattern_000(alice, 0);
Image_TGA_save("alice.tga", alice, 0);
T0 = tthi_dtime(); T0 = tthi_dtime();
count = 0L; count = 0L;
@ -48,6 +48,7 @@ if (usemacro) {
count++; count++;
} }
} }
fname = "bob1.tga";
} }
else { else {
for (y=0; y<SZPIC; y++) { for (y=0; y<SZPIC; y++) {
@ -56,17 +57,18 @@ else {
count++; count++;
} }
} }
fname = "bob0.tga";
} }
T1 = tthi_dtime(); T1 = tthi_dtime();
foo = Image_TGA_save("bob.tga", bob, 0); foo = Image_TGA_save(fname, 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; perpix = ((T1-T0) / (double)count) * 1e6;
fprintf(stderr, "%s : %10ld pixels, elapsed %9.6f seconds ==> %5.3g µs/ppix\n", fprintf(stderr, "%s : %10ld pixels, elapsed %9.6f seconds ==> %9.6f µs/pix\n",
usemacro ? "macro" : "func ", usemacro ? "macro" : "func ",
count, T1-T0, perpix); count, T1-T0, perpix);
@ -79,7 +81,7 @@ int main(int argc, char *argv[])
{ {
int i; int i;
fprintf(stderr, "******** %s is running *********\n", argv[0]); fprintf(stderr, "*********** %s ************\n", argv[0]);
if (argc > 1) { if (argc > 1) {
fprintf(stderr, "argument: %s\n", argv[1]); fprintf(stderr, "argument: %s\n", argv[1]);

View File

@ -93,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;
@ -192,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);
@ -246,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;
@ -269,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;
@ -309,6 +300,7 @@ 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;
@ -321,8 +313,7 @@ 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;
@ -331,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 )
{ {
@ -352,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();
@ -368,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);
@ -387,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
@ -407,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();
@ -419,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
@ -443,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;
@ -466,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;
} }
@ -545,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)
{ {
@ -563,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;
} }
@ -592,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

@ -53,7 +53,7 @@ else
Image_start_chrono("Essai", 0); Image_start_chrono("Essai", 0);
for (idx=0; idx<1; idx++) { for (idx=0; idx<3; 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,17 +64,24 @@ for (idx=0; idx<1; 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);

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.

View File

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

View File

@ -50,9 +50,9 @@ 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
@ -61,7 +61,8 @@ 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
`testtga list` vous les fera découvrir, la cinquième va vous étonner. `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
@ -77,11 +78,16 @@ 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. 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 ## tga_to_text
@ -102,6 +108,11 @@ 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

View File

@ -4,7 +4,7 @@
http://la.buvette.org/devel/libimage/ http://la.buvette.org/devel/libimage/
*/ */
#ifndef IMAGE_VERSION_STRING #ifndef IMAGE_VERSION_STRING
#define IMAGE_VERSION_STRING "0.4.51 pl 85" #define IMAGE_VERSION_STRING "0.4.51 pl 91"
/*::------------------------------------------------------------------::*/ /*::------------------------------------------------------------------::*/
/* /*
@ -315,10 +315,15 @@ 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 */