Compare commits

...

53 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
69 changed files with 1912 additions and 605 deletions

1
.gitignore vendored
View File

@@ -3,6 +3,7 @@
libtthimage.a
cscope.out
gmon.out
Lib/foo
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

@@ -1,4 +1,4 @@
# libtthimage
# libtthimage, la doc
Les fichiers [HTML](html/) que vous avez ici sont des versions historiques,
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.
Je vous conseille de vérifier leurs pertinences, et en particulier
les options `-p` et `-pg` que j'oublie parfois d'enlever avant
le _/push_.
le _push_.
Le script [build.sh](../build.sh) tente d'automatiser les
compilations de la bibilothèque, des tests et des outils
en ligne de commande.
en ligne de commande. Il est encore loin d'être parfait.
## Installation
@@ -28,4 +28,4 @@ dans le fichier Paramakes.mk !
## Utilisation
???
??? *Insérez ici quelques exemples d'utilisation des tools.*

3
Lib/.gitignore vendored
View File

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

View File

@@ -8,7 +8,7 @@ include ../Paramakes.mk
DEPS = ../tthimage.h ../Paramakes.mk Makefile
all: foo testtga
all: foo testtga t_png testbmp
#-----------------------------------------------------------------
@@ -63,6 +63,8 @@ extractbits.o: extractbits.c $(DEPS)
filtadapt.o: filtadapt.c $(DEPS)
filtres.o: filtres.c $(DEPS)
falsecolors.o: falsecolors.c $(DEPS)
functions.o: functions.c $(DEPS) # new Aug 15, 2024
gadgrect.o: gadgrect.c $(DEPS)
glitch.o: glitch.c $(DEPS)
@@ -132,7 +134,6 @@ vignetize.o: vignetize.c $(DEPS)
warp0.o: warp0.c $(DEPS)
warp1.o: warp1.c $(DEPS)
warp2.o: warp2.c $(DEPS)
warp3.o: warp3.c $(DEPS)
zoom.o: zoom.c $(DEPS)
@@ -152,7 +153,8 @@ OBJECTS = 7seg.o \
dither.o dither2.o dither3.o \
doublesz.o drawalpha.o drawing.o drawpatt.o \
effects.o effects2.o effects3.o extractbits.o \
filtadapt.o filtres.o \
filtadapt.o filtres.o falsecolors.o \
functions.o \
gadgrect.o glitch.o gradient.o \
halfsize.o \
image.o imprime.o \
@@ -175,9 +177,10 @@ OBJECTS = 7seg.o \
text0.o text1.o text16x24.o \
tga.o tools.o turtle.o \
vignetize.o \
warp0.o warp1.o warp2.o warp3.o \
warp0.o warp1.o warp2.o \
zoom.o
# build the static library
../libtthimage.a: $(OBJECTS)
$(AR) rs $@ $?
$(RANLIB) $@

View File

@@ -1,8 +1,9 @@
# The tTh image processind library
# The tTh image processing library
Ugly software born around 1995 on a MS-Dos 286 computer.
Look at the `Makefile` for no more explanations.
Look at the [`Makefile`](Makefile) for no more explanations.
More pertinent informations can be found in
[`tthimage.h`](../tthimage.h).
## Text primitives

View File

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

View File

@@ -2,7 +2,7 @@
calcluts.c
----------
voir aussi: luts15bits.c
voir aussi: luts15bits.c & palettes.c
*/
@@ -42,7 +42,7 @@ for (foo=0; foo<256; foo++) {
lut[foo] = quux;
}
return FUNC_IS_BETA;
return FUNC_IS_ALPHA;
}
/*::------------------------------------------------------------------::*/
int Image_calclut_foo(int *lut, int v0, int v255)
@@ -67,7 +67,7 @@ for (foo=0; foo<256; foo++) {
if (fp!=stdout) fclose(fp);
return FUNC_IS_BETA;
return FUNC_IS_ALPHA;
}
/*::------------------------------------------------------------------::*/
int Image_load_lut(int *lut, char *fname, int flag)
@@ -98,6 +98,6 @@ for (idx=0; idx<256; idx++) {
fclose(fp);
return FUNC_IS_BETA;
return FUNC_IS_ALPHA;
}
/*::------------------------------------------------------------------::*/

View File

@@ -51,13 +51,13 @@ static int compare_teinte(struct elem *p1, struct elem *p2)
{
int r1, g1, b1, r2, b2, g2;
r1 = (( (p1->rgb) >>8)&0xf)<<4;
g1 = (( (p1->rgb) >>4)&0xf)<<4;
b1 = ( (p1->rgb) &0xf)<<4;
r1 = (( (p1->rgb) >>8)&0xf) <<4;
g1 = (( (p1->rgb) >>4)&0xf) <<4;
b1 = ( (p1->rgb) &0xf) <<4;
r2 = (( (p2->rgb) >>8)&0xf)<<4;
g2 = (( (p2->rgb) >>4)&0xf)<<4;
b2 = ( (p2->rgb) &0xf)<<4;
r2 = (( (p2->rgb) >>8)&0xf) <<4;
g2 = (( (p2->rgb) >>4)&0xf) <<4;
b2 = ( (p2->rgb) &0xf) <<4;
/* printf("%8d %8d\n", p1->compte, p2->compte);
return (p1->rgb - p2->rgb); */
@@ -66,7 +66,9 @@ return ( (r1+g1+b1) - (r2+g2+b2) );
}
/*::------------------------------------------------------------------::*/
/*
* XXX please explain parameters usage !
*/
#define TAILLE (1<<12)
int Image_calc_Map_4bits(Image_Desc *img, RGB_map *map, int nbre)
{
@@ -80,13 +82,13 @@ fprintf(stderr, " Calc map 4 bits: nbre = %d\n", nbre);
#endif
if ( (nbre<1) || (nbre>255) ) {
fprintf(stderr, "Calc map 4 bits: nbre %d out of range\n", nbre);
fprintf(stderr, "%s: nbre %d out of range\n", __func__, nbre);
return BAD_COLOR_NUMBER;
}
surface = img->width * img->height;
#if DEBUG_LEVEL
fprintf(stderr, " calc Map 4 bits: surface de l'image = %ld pixels\n", surface);
fprintf(stderr, "%s: surface de l'image = %ld pixels\n", __func__, surface);
#endif
for (x=0; x<TAILLE; x++) {
@@ -112,7 +114,7 @@ for (x=0; x<img->width; x++) {
}
}
#if DEBUG_LEVEL
fprintf(stderr, " Map4bits: compte maximum = %ld\n", maxi);
fprintf(stderr, "%s: compte maximum = %ld\n", __func__, maxi);
#endif
/*
@@ -123,7 +125,7 @@ qsort(elems, TAILLE, sizeof(struct elem), compare_compteur);
/*
* trier la palette, certe, mais dans quel ordre ?
* 28 Jan 2002: why ?
* 28 Jan 2002: why ?
*/
qsort(elems, nbre, sizeof(struct elem), compare_teinte);

View File

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

View File

@@ -4,7 +4,7 @@
made by Thierry Boudet, aka "Oulala", aka "Tonton Th".
ces fonctions combinent de diverses façons deux images
ces fonctions combinent de diverses facons deux images
de memes dimensions. on pourra, par exemple, les utiliser
pour comparer deux traitements.
*/
@@ -22,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 sy, int oy, int zak)
@@ -30,11 +30,11 @@ int Image_combine_lines(Image_Desc *s1, Image_Desc *s2, Image_Desc *d,
int foo, x, y, my, r, g, b;
if (sy == 0) {
fprintf(stderr, "Combine Lines: sy is zer0 and zak is %d\n", zak);
fprintf(stderr, "%s: sy is 0 and zak is %d\n", __func__, zak);
return DIVISOR_IS_ZERO;
}
if ( (foo=Image_compare_desc(s1, s2)) ) {
fprintf(stderr, "Combine Lines: sources are differents (%d)\n", foo);
fprintf(stderr, "%s: sources are differents (%d)\n", __func__, foo);
return foo;
}
@@ -65,7 +65,7 @@ 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 sx, int ox, int zak)
@@ -241,8 +241,8 @@ return OLL_KORRECT;
}
/*::------------------------------------------------------------------::*/
/*
* le flag 'yo' decide quelle image sera en haut à droite.
* les paramètres p1 & p2 ne sont pas utilisés.
* le flag 'yo' decide quelle image sera en haut a droite.
* les parametres p1 & p2 ne sont pas utilises.
*/
int Image_combine_diagonale(Image_Desc *s1, Image_Desc *s2, Image_Desc *d,
int yo, int p1, int p2)
@@ -252,7 +252,7 @@ int x, y, r, g, b;
int vertical, offset;
if ( p1 || p2 ) {
fprintf(stderr, "in %s bad p1 %d or bad p2 %d\n", __func__, p1, p2);
fprintf(stderr, "%s: bad p1 %d or bad p2 %d\n", __func__, p1, p2);
}
if ( (foo=Image_compare_desc(s1, s2)) ) {
@@ -300,6 +300,7 @@ for (y=0; y<s1->height; y++) {
}
/*
* 30 sept 2008 : est-ce que cette fonction a subi un bon fuzzing ?
* 9 aout 2024 : non, pas encore ;)
*/
return OLL_KORRECT;
}
@@ -352,7 +353,7 @@ return OLL_KORRECT;
/*
* fonction faite pour le finisseur de DBvsEE
*
* 6 oct 2001: une version qui permettrait de spécifier les
* 6 oct 2001: une version qui permettrait de specifier les
* seuils en r,g et b serait assez pratique aussi.
*/
int Image_combine_if_not_black(Image_Desc *s1, Image_Desc *s2, Image_Desc *d)

View File

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

View File

@@ -10,51 +10,62 @@
/*::------------------------------------------------------------------::*/
/*
* new: Fri Sep 15 20:18:35 UTC 2023
* inspired by the sam func in FloatImg
* inspired by the same func in FloatImg
*/
int Image_egalise_cos01(Image_Desc *source, Image_Desc *but, int k)
{
int lut[256], uc;
int idx, foo;
/* int x, y, pix; */
(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); */
}
/*
* old original code, replaced...
*
for (y=0; y<source->height; y++) {
for (x=0; x<source->width; x++) {
pix = source->Rpix[y][x];
but->Rpix[y][x] = lut[pix];
pix = source->Gpix[y][x];
but->Gpix[y][x] = lut[pix];
pix = source->Bpix[y][x];
but->Bpix[y][x] = lut[pix];
}
}
*
* ... by a func from 'calculs.c'
*/
Image_LUT_mono(source, but, lut);
return FUNC_IS_BETA;
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;
}
/*::------------------------------------------------------------------::*/
/*

View File

@@ -16,7 +16,9 @@ int Image_dither_Bayer_0(Image_Desc *s, Image_Desc *d, int uh)
{
int dx, dy, x, y, r, g, b;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, s, d, uh);
#endif
/* directement copie de la page 389 de "Bitmapped graphics" de
Steve Rimmer. */
@@ -63,7 +65,9 @@ int Image_dither_crude(Image_Desc *s, Image_Desc *d, int uh)
int x, y, r, g, b;
int som;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, s, d, uh);
#endif
if (s != d) Image_clear(d, 0, 0, 0);
@@ -105,14 +109,16 @@ return OLL_KORRECT;
}
/*::------------------------------------------------------------------::*/
/*
* ça ne marche pas très fort, ce truc...
* Il ne marche pas tres fort, ce truc...
*/
int Image_dither_2x2(Image_Desc *s, Image_Desc *d, int uh)
{
int x, y, xm, ym;
int r, g, b, v;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, s, d, uh);
#endif
x = s->width; xm = (x&1) ? (x-1) : x;
y = s->height; ym = (y&1) ? (y-1) : y;
@@ -153,7 +159,9 @@ int Image_dither_seuil_random(Image_Desc *s, Image_Desc *d, int uh)
int x, y, r, g, b;
int foo;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, s, d, uh);
#endif
if ( (foo=Image_compare_desc(s, d)) ) {
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);
@@ -192,7 +200,9 @@ int x, y, xa, xb, inc, errR, errG, errB;
int r, g, b, dr, dg, db;
int foo;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, s, d, uh);
#endif
if ( (foo=Image_compare_desc(s, d)) ) {
fprintf(stderr, "%s: images are differents %d\n", __func__, foo);

View File

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

View File

@@ -69,8 +69,7 @@ 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++)
{
for(foo=0; foo<256; foo++) {
((uint16_t *)matrice)[foo] = foo;
}
/* brasssage de la matrice */

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

@@ -145,7 +145,7 @@ Image_TGA_save("Pictures/aaaa-luminance-128.tga", dst, 0);
foo = Image_luminance(src, dst, 200);
Image_TGA_save("Pictures/aaaa-luminance-200.tga", dst, 0);
foo = Image_luminance(src, dst, 500);
if (foo) Image_print_error(__func__, foo);
if (foo) Image_print_error((char *)__func__, foo);
Image_TGA_save("Pictures/aaaa-luminance-500.tga", dst, 0);
@@ -216,18 +216,17 @@ if (NULL==(src=Image_TGA_alloc_load(srcname))) {
}
/* on va creer le receptacle des horreurs */
if (NULL==(dst=Image_clone(src, 0))) {
fprintf(stderr, "%s: err clone\n", __func__);
exit(5);
}
/* ah bravo ! enfin un test unitaire appelable
* depuis le test unitaire */
for (idx=0; idx<20; idx++)
{
for (idx=0; idx<20; idx++) {
foo = Image_essai_col_reduce(src, dst, 133, idx);
printf("le retour de l'essai_col_reduce %d est %d\n", idx, foo);
if (OLL_KORRECT==foo)
{
sprintf(fname, "Pictures/aaaa-colredux-%02d.tga", idx);
if (OLL_KORRECT==foo) {
sprintf(fname, "aaaa-colredux-%02d.tga", idx);
Image_TGA_save(fname, dst, 0);
}
}
@@ -376,7 +375,7 @@ if ( NULL == (nucked=Image_clone(origine, 1)) ) {
foo = Image_essai_zoom(origine, nucked, 1.18, 0.42, 0);
if (foo) {
fprintf(stderr, "In %s, essai zoom -> %d\n", foo);
fprintf(stderr, "In %s, essai zoom -> %d\n", __func__, foo);
}
Image_TGA_save("Pictures/aaaa-zoom.tga", nucked, 0);
@@ -471,7 +470,6 @@ int rotule, foo;
Image_Desc *origine, *imgtmp;
char chaine[100];
int filtre[11];
int w3, h3;
Image_Rect rect;
static int datas_sobel[] =
@@ -513,9 +511,6 @@ printf("image originale @ %p\n", origine);
imgtmp = Image_clone(origine, 1);
w3 = origine->width * 3;
h3 = origine->height * 3;
if (flags) memcpy(filtre, datas_prewitt, sizeof(filtre));
else memcpy(filtre, datas_sobel, sizeof(filtre));
@@ -586,32 +581,30 @@ int foo, ax, ay;
printf("====== essais Warping sur %s (k=%d) ====\n", srcname, k);
if (NULL == (src = Image_TGA_alloc_load(srcname)) )
{
if (NULL == (src = Image_TGA_alloc_load(srcname)) ) {
fprintf(stderr, "Err loading '%s'\n", srcname);
exit(5);
}
dst = Image_clone(src, 0);
foo = Image_warp_essai_0(src, dst, 33.5, 100, 100);
Image_TGA_save("Pictures/warp-essai-0.tga", dst, 0);
Image_TGA_save("warp-essai-0.tga", dst, 0);
foo = Image_center_rotate(src, dst, 21.5);
Image_TGA_save("Pictures/warp-center-rotate.tga", dst, 0);
Image_TGA_save("warp-center-rotate.tga", dst, 0);
ax = (src->width * 2) / 3;
ay = (src->height * 2) / 3;
foo = Image_shift_xy(src, dst, ax, ay);
Image_TGA_save("Pictures/warp-shift-xy.tga", dst, 0);
Image_TGA_save("warp-shift-xy.tga", dst, 0);
foo = Image_shift_x(src, dst, ax);
Image_TGA_save("Pictures/warp-shift-x.tga", dst, 0);
Image_TGA_save("warp-shift-x.tga", dst, 0);
foo = Image_shift_y(src, dst, ay);
Image_TGA_save("Pictures/warp-shift-y.tga", dst, 0);
Image_TGA_save("warp-shift-y.tga", dst, 0);
Image_DeAllocate(src); free(src);
Image_DeAllocate(dst); free(dst);
return 42;
}
/*::------------------------------------------------------------------::*/
@@ -799,7 +792,7 @@ Image_DeAllocate(dst); free(dst);
return 42;
}
/*::------------------------------------------------------------------::*/
int Test_classif(char *srcname, int k)
int Test_Classif(char *srcname, int k)
{
Image_Desc *src, *dst;
int foo;
@@ -816,8 +809,7 @@ static Une_Classe_Sph classs[] =
{ 0, 255, 0, DC, 0, 255, 0 }
};
if (NULL == (src = Image_TGA_alloc_load(srcname)) )
{
if (NULL == (src = Image_TGA_alloc_load(srcname)) ) {
fprintf(stderr, "Err loading '%s'\n", srcname);
exit(5);
}
@@ -825,11 +817,11 @@ dst = Image_clone(src, 0);
foo = Image_classif_0(src, dst);
Image_print_error("essai classif 0", foo);
Image_TGA_save("Pictures/aaaa-classif0.tga", dst, 0);
Image_TGA_save("aaaa-classif0.tga", dst, 0);
foo = Image_classif_1(src, dst, classs, 5, 0);
Image_print_error("essai classif 1", foo);
Image_TGA_save("Pictures/aaaa-classif1.tga", dst, 0);
Image_TGA_save("aaaa-classif1.tga", dst, 0);
Image_DeAllocate(src); free(src);
Image_DeAllocate(dst); free(dst);
@@ -838,23 +830,29 @@ return 42;
}
/*::------------------------------------------------------------------::*/
/* new 24 avril 2007, essais sur le module rgbmask.c */
int
Test_rgbmask(char *srcname)
int Test_RGBmask(char *srcname)
{
Image_Desc *source, *image ;
int foo;
fprintf(stderr, "=============== %s on %s ==============\n", __func__, srcname);
source = Image_TGA_alloc_load(srcname);
image = Image_clone(source, 0);
foo = Image_rgbmask_H(source, image, 0);
Image_TGA_save("Pictures/aaaa-rgbmaskH.tga", image, 0);
Image_TGA_save("aaaa-rgbmaskH.tga", image, 0);
foo = Image_rgbmask_V(source, image, 0);
Image_TGA_save("Pictures/aaaa-rgbmaskV.tga", image, 0);
Image_TGA_save("aaaa-rgbmaskV.tga", image, 0);
foo = Image_rgbmask_2(source, image, 0);
Image_TGA_save("Pictures/aaaa-rgbmask2.tga", image, 0);
Image_TGA_save("aaaa-rgbmask2.tga", image, 0);
foo = Image_rgbmask_R(source, image, 0);
Image_TGA_save("Pictures/aaaa-rgbmaskR.tga", image, 0);
Image_TGA_save("aaaa-rgbmaskR.tga", image, 0);
Image_DeAllocate(source); free(source);
Image_DeAllocate(image); free(image);
return 42;
}
@@ -1055,15 +1053,47 @@ Image_DeAllocate(finale); free(finale);
return 0;
}
/*::------------------------------------------------------------------::*/
int
Test_Egalisations(char *nomsource, int k)
/* new: Sat Aug 10 15:32:01 UTC 2024 */
int Essai_Televisions(char *nomsource, int k)
{
Image_Desc *image, *resultat;
int foo;
fprintf(stderr, "================ Televisions %s %d ========\n", nomsource, k);
image = Image_TGA_alloc_load(nomsource);
printf("%s : image loaded %p\n", __func__, image);
resultat = Image_clone(image, 0);
printf("%s : image cloned %p\n", __func__, resultat);
foo = Image_TV_old(image, resultat, 127, 127, 127);
printf("\tTV old -> %d\n", foo);
Image_TGA_save("aaaa_tv_old.tga", resultat, 0);
foo = Image_TV_pix_0(image, resultat, 7, 7, 0);
printf("\tTV pix 0 -> %d\n", foo);
Image_TGA_save("aaaa_tv_pix_0.tga", resultat, 0);
foo = Image_TV_cplus_v1(image, resultat, 7);
printf("\tTV cplus v1 -> %d\n", foo);
Image_TGA_save("aaaa_tv_cplusV1.tga", resultat, 0);
Image_DeAllocate(image); free(image);
Image_DeAllocate(resultat); free(resultat);
return FULL_NUCKED;
}
/*::------------------------------------------------------------------::*/
int Test_Egalisations(char *nomsource, int k)
{
Image_Desc *image, *deuxieme, *troisieme;
int x, y;
fprintf(stderr, "============= Egalisations %s %d =====\n", nomsource, k);
fprintf(stderr, "================ Egalisations %s %d =====\n", nomsource, k);
image= Image_TGA_alloc_load(nomsource);
image = Image_TGA_alloc_load(nomsource);
printf("image loaded %p\n", image);
deuxieme = Image_clone(image, 0);
@@ -1074,18 +1104,17 @@ troisieme = Image_clone(image, 0);
printf("image 3 cloned %p\n", troisieme);
Image_egalise_RGB(image, troisieme, 0);
for (x=0; x<image->width; x++)
{
if (x < image->width/3)
{
for (y=0; y<image->height; y++)
for (x=0; x<image->width; x++) {
if (x < image->width/3) {
for (y=0; y<image->height; y++) {
Image_pixel_copy(image, x, y, troisieme, x, y);
}
}
else
if (x > image->width/3*2)
{
for (y=0; y<image->height; y++)
if (x > image->width/3*2) {
for (y=0; y<image->height; y++) {
Image_pixel_copy(deuxieme, x, y, troisieme, x, y);
}
}
#if DEBUG_LEVEL > 2
@@ -1095,7 +1124,7 @@ for (x=0; x<image->width; x++)
printf("saving resultat...\n");
Image_marque_1(troisieme, "Egalisations", 0);
Image_TGA_save("Pictures/aaaa_egal.tga", troisieme, 0);
Image_TGA_save("aaaa_egal.tga", troisieme, 0);
Image_DeAllocate(image); free(image);
Image_DeAllocate(deuxieme); free(deuxieme);
Image_DeAllocate(troisieme); free(troisieme);
@@ -1103,30 +1132,30 @@ Image_DeAllocate(troisieme); free(troisieme);
return 42;
}
/*::------------------------------------------------------------------::*/
int
Test_Dithering(char *nomsource, int k)
int Test_Dithering(char *nomsource, int k)
{
Image_Desc *source, *image, *deuxieme, *finale;
Image_Rect rect;
int foo;
int foo, wf, hf;
int x2, y2;
RGBA ink, pap;
fprintf(stderr, "========== Dithering on %s (%d) =======\n", nomsource, k);
fprintf(stderr, "============== Dithering on %s (%d) =======\n", nomsource, k);
source = Image_TGA_alloc_load(nomsource);
if (NULL == source)
{
if (NULL == source) {
fprintf(stderr, "%s:%s err load %s\n", __FILE__, __func__, nomsource);
exit(5);
}
#if DEBUG_LEVEL
Image_dump_descriptor(source, "just after load");
#endif
/*
* est-ce bien necessaire ?
*/
/* Image_egalise_RGB(source, source, 0); */
wf = source->width; hf = (source->height) * 3;
x2 = source->width / 2; y2 = source->height / 2;
rect.w = x2; rect.h = y2;
rect.x = 0; rect.y = 0;
@@ -1134,24 +1163,22 @@ rect.x = 0; rect.y = 0;
ink.r = 255, ink.g = 255, ink.b = 100; ink.a = 255;
pap.r = 30, pap.g = 30, pap.b = 155; pap.a = 255;
finale = Image_alloc(source->width, (source->height)*3, 3);
if (NULL == finale)
{
finale = Image_alloc(wf, hf, 3);
if (NULL == finale) {
fprintf(stderr, "%s:%s:%d err alloc image\n",
__FILE__, __func__, __LINE__);
exit(5);
}
printf("image finale allocated %p\n", finale);
Image_clear(finale, 0, 200, 0);
printf("image finale %dx%d allocated at %p\n", wf, hf, finale);
image = Image_MakeHalfSize(source, 0);
if (NULL == image)
{
if (NULL == image) {
fprintf(stderr, "%s:%s:%d err halfsize image\n",
__FILE__, __func__, __LINE__);
exit(5);
}
printf("image Half -> %p\n", image);
printf("%s: image Half at %p\n", __func__, image);
Image_DeAllocate(source); free(source);
Image_copy_rect(image, &rect, finale, 0, 0);
@@ -1197,17 +1224,20 @@ Image_txt1_box_0(finale, "3x3 2", x2, y2*3, 4, &pap, &ink, 0);
foo = Image_dither_bayer8x8rnd(image, deuxieme, 5000, 0);
printf("retour Dither bayer8x8rnd = %d\n", foo);
Image_copy_rect(deuxieme, &rect, finale, x2, y2*4);
Image_txt1_box_0(finale, "bayer 8x8 rnd rgb", x2, y2*4, 4, &pap, &ink, 0);
Image_txt1_box_0(finale, "bayer8xrnd rgb", x2, y2*4, 4, &pap, &ink, 0);
foo = Image_dither_bayer8x8rnd(image, deuxieme, 5000, 1);
printf("retour Dither bayer8x8rnd = %d\n", foo);
Image_copy_rect(deuxieme, &rect, finale, 0, y2*4);
Image_txt1_box_0(finale, "bayer 8x8 rnd grey", 0, y2*4, 4, &pap, &ink, 0);
Image_txt1_box_0(finale, "bayer8x8rndgrey", 0, y2*4, 4, &pap, &ink, 0);
Image_TGA_save("Pictures/aaaa_dithering.tga", finale, 0);
printf("++++++ test dither\n");
Image_dump_descriptor(finale, "just before save");
Image_TGA_save("aaaa_dithering.tga", finale, 0);
Image_DeAllocate(image); free(image);
Image_DeAllocate(deuxieme); free(deuxieme);
Image_DeAllocate(finale); free(finale);
printf("++++++ fin essais dither\n");
return 0;
}
@@ -1226,8 +1256,7 @@ return -1;
}
/*::------------------------------------------------------------------::*/
/* new 21 juillet 2007 - ave St Exupery */
int
Test_Effects_A(char *nomsource, int flag)
int Test_Effects_A(char *nomsource, int flag)
{
Image_Desc *source, *image, *deuxieme, *finale;
int foo;
@@ -1236,8 +1265,7 @@ RGBA ink, pap;
printf("=== %s %s === %s === %d ===\n", __FILE__, __func__, nomsource, flag);
if (flag)
{
if (flag) {
fprintf(stderr, "%s: flag is %d ?\n", __func__, flag);
}
@@ -1245,8 +1273,7 @@ ink.r = 255, ink.g = 255, ink.b = 100; ink.a = 255;
pap.r = 30, pap.g = 30, pap.b = 155; pap.a = 255;
source = Image_TGA_alloc_load(nomsource);
if (NULL==source)
{
if (NULL==source) {
fprintf(stderr, "%s : il manque '%s'\n", __func__, nomsource);
exit(1);
}
@@ -1322,8 +1349,7 @@ Image_DeAllocate(finale); free(finale);
return 42;
}
/*::------------------------------------------------------------------::*/
int
Test_des_tamppools(char *imgname, int param)
int Test_des_tamppools(char *imgname, int param)
{
void *ptr;
int foo;
@@ -1346,30 +1372,31 @@ int Test_des_filtres(char *srcname, int k)
Image_Desc *src, *dst;
int foo;
printf("======= LES FILTRES ===[ %s ]==[ %d ]====\n", srcname, k);
printf("=============== Filtres =====[ %s ]====[ %d ]====\n", srcname, k);
src = Image_TGA_alloc_load(srcname);
if (NULL == src)
{
if (NULL == src) {
fprintf(stderr, "%s can't load %s\n", __func__, srcname);
return 666;
}
dst = Image_clone(src, 1);
if (NULL == dst)
{
if (NULL == dst) {
fprintf(stderr, "mem failure in %s\n", __func__);
abort();
}
foo = Image_lissage_3x3(src, dst);
Image_TGA_save("Pictures/filtre-liss3x3.tga", dst, 0);
Image_TGA_save("filtre-liss3x3.tga", dst, 0);
if (foo) { fprintf(stderr, "%s: liss3x3 -> %d\n", __func__, foo); }
foo = Image_filtre_Prewitt(src, dst, 5);
Image_TGA_save("Pictures/filtre-prewitt-5.tga", dst, 0);
Image_TGA_save("filtre-prewitt-5.tga", dst, 0);
foo = Image_filtre_passe_haut(src, dst);
Image_TGA_save("Pictures/filtre-passe-haut.tga", dst, 0);
Image_TGA_save("filtre-passe-haut.tga", dst, 0);
/*
foo = Image_filtre_Sobel_4(src, dst, 0);
Image_TGA_save("Pictures/filtre-sobel-4.tga", dst, 0);
Image_TGA_save("filtre-sobel-4.tga", dst, 0);
*/
Image_DeAllocate(src); free(src);
Image_DeAllocate(dst); free(dst);
@@ -1465,3 +1492,17 @@ Image_DeAllocate(dst); free(dst);
return -1;
}
/*::------------------------------------------------------------------::*/
/* ============================== */
void essai_gradients(void)
{
int foo;
foo = Image_plot_H_gradient("foo.tga", 640, 200);
fprintf(stderr, "plot h gradient -> %d\n", foo);
foo = Image_plot_V_gradient("foo.tga", 900, 200);
fprintf(stderr, "plot v gradient -> %d\n", foo);
}
/* ============================== */
/*::------------------------------------------------------------------::*/

View File

@@ -27,6 +27,8 @@ int Essai_des_lut15bits(char *srcname, int k);
int Essai_des_mires(char *, int, int);
int Essai_des_zooms(char *srcname, int k);
int Test_Classif(char *srcname, int k);
int Essai_des_7_segments(char *srcname, int flag);
int Essai_des_distances(char *srcname, int nbre, int flag);
int Essai_des_cadres(char *srcname, int flags);
@@ -44,7 +46,7 @@ int Test_des_df3(char *txt, int k);
int Test_vignettes(char *srcname, int k);
int Test_classif(char *srcname, int k);
int Test_rgbmask(char *srcname);
int Test_RGBmask(char *srcname);
void Test_rgb2xyz(void);
int Essai_des_marquages(char *srcname, int nombre, char *texte);
@@ -68,7 +70,7 @@ int Test_des_pixeliz(char *srcname, int flags);
int Essai_des_bitblt(char *srcname, int k);
int Essai_des_gadgrect(char *srcname, int k);
int Essai_Television(char *source, int k);
int Essai_Televisions(char *source, int k);
/* dans essais2;c */
int Essai_des_big_chars(char *fname, int k);

100
Lib/foo.c
View File

@@ -8,53 +8,91 @@
/* ============================== */
int essai_false_colors(void)
/* 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)
{
int foo;
RGB_map luts;
Image_Desc *alice, *bob;
int x, y, foo;
double T0, T1, perpix;
long count;
char *fname;
foo = Image_gen_fc_lut(27e3, 33, &luts);
fprintf(stderr, "retour gen_fc_lut = %d\n", foo);
alice = Image_alloc(SZPIC, SZPIC, IMAGE_RGB);
bob = Image_alloc(SZPIC, SZPIC, IMAGE_RGB);
return -1;
Image_pattern_000(alice, 0);
Image_TGA_save("alice.tga", alice, 0);
T0 = tthi_dtime();
count = 0L;
if (usemacro) {
for (y=0; y<SZPIC; y++) {
for (x=0; x<SZPIC; x++) {
PIXEL_COPY(alice, x, y, bob, x, y);
count++;
}
}
fname = "bob1.tga";
}
else {
for (y=0; y<SZPIC; y++) {
for (x=0; x<SZPIC; x++) {
Image_pixel_copy(alice, x, y, bob, x, y);
count++;
}
}
fname = "bob0.tga";
}
T1 = tthi_dtime();
foo = Image_TGA_save(fname, bob, 0);
if (foo) {
fprintf(stderr, "%s: save -> %d\n", __func__, foo);
}
perpix = ((T1-T0) / (double)count) * 1e6;
fprintf(stderr, "%s : %10ld pixels, elapsed %9.6f seconds ==> %9.6f µs/pix\n",
usemacro ? "macro" : "func ",
count, T1-T0, perpix);
/* end */
}
/* ============================== */
int essai_show_t16x24( char *text)
{
if (NULL != text)
Image_t16x24_essai("16x24thin", text, "16x24.tga");
else
Image_t16x24_essai("16x24gruik", "0123456789abcdef", "16x24.tga");
return 0;
}
/* ============================== */
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);
}
/* ============================== */
int main(int argc, char *argv[])
{
int i;
fprintf(stderr, "*** %s is running\n", argv[0]);
fprintf(stderr, "*********** %s ************\n", argv[0]);
if (argc > 1) {
fprintf(stderr, "argument: %s\n", argv[1]);
Image_print_version(0);
Image_print_version(2);
Image_print_sizeof_structs("foo");
}
else {
essai_false_colors();
for (i=0; i<5; i++) {
essai_pixcopy(0);
essai_pixcopy(1);
}
}
/*

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

@@ -18,7 +18,7 @@ void Image_print_version(int flag)
char *ptr;
fflush(stdout);
fprintf(stderr, "-+- This is the `tthimage' library v%s (wtfyw 2023) tTh\n",
fprintf(stderr, "-+- This is the `tthimage' library v%s (wtfyw 2024) tTh\n",
IMAGE_VERSION_STRING);
if (flag)
{
@@ -93,8 +93,7 @@ return 0;
* on the structure who describe the image.
* - - - > don't "free" this pointer, please.
*/
Image_Desc *
Image_alloc(int width, int height, int type)
Image_Desc * Image_alloc(int width, int height, int type)
{
Image_Desc *header;
int foo;
@@ -192,19 +191,18 @@ return header;
/*
This fonction build another image from a model.
*/
Image_Desc *
Image_clone (Image_Desc *src, int copy)
Image_Desc * Image_clone (Image_Desc *src, int copy)
{
Image_Desc *image;
if ( src==NULL )
if ( NULL == src )
{
fprintf(stderr, "Image_clone: source descriptor is NULL\n");
exit(5);
}
image = Image_alloc(src->width, src->height, src->type);
if ( image==NULL )
if ( NULL == image )
{
fprintf(stderr, "Image_clone: cloned descriptor is NULL\n");
exit(5);
@@ -246,20 +244,16 @@ return FUNC_IS_ALPHA;
* Helas, cette fonction ne marche que sur les images RGB
* et comment la rendre compatible tout-types sans tout casser ?
*/
int
Image_clear( Image_Desc *image, int r, int g, int b )
int Image_clear( Image_Desc *image, int r, int g, int b )
{
int x, y;
if (image->type == IMAGE_RGB)
{
for (y=0; y<image->height; y++)
{
if (image->type == IMAGE_RGB) {
for (y=0; y<image->height; y++) {
/*
* XXX here we can go faster with a few memset
*/
for (x=0; x<image->width; x++)
{
for (x=0; x<image->width; x++) {
(image->Rpix[y])[x] = r;
(image->Gpix[y])[x] = g;
(image->Bpix[y])[x] = b;
@@ -269,12 +263,9 @@ if (image->type == IMAGE_RGB)
return 0; /* ok, this 'return' here is a "spleyterie" :) */
}
if (image->type == IMAGE_RGBA)
{
for (y=0; y<image->height; y++)
{
for (x=0; x<image->width; x++)
{
if (image->type == IMAGE_RGBA) {
for (y=0; y<image->height; y++) {
for (x=0; x<image->width; x++) {
(image->Rpix[y])[x] = r;
(image->Gpix[y])[x] = g;
(image->Bpix[y])[x] = b;
@@ -309,6 +300,7 @@ if (IMAGE_RGB != img->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;
@@ -321,8 +313,7 @@ return FUNC_IS_BETA;
* every image in memory have a comment field, who is writen
* in TGA and PNM file when image is saved.
*/
int
Image_set_comment(Image_Desc *image, char *text)
int Image_set_comment(Image_Desc *image, char *text)
{
if (strlen(text) > IMG_OBJCOMMENT_LEN)
return STRING_TOO_LONG;
@@ -331,8 +322,7 @@ return OLL_KORRECT;
}
/* 10 nov 2001: no #define for this not-so-magic 254 value ? */
/*::------------------------------------------------------------------::*/
int
Image_plot_gray(Image_Desc *img, int x, int y, int v)
int Image_plot_gray(Image_Desc *img, int x, int y, int v)
{
if ( x<0 || y<0 || x>=img->width || y>=img->height )
{
@@ -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);
#endif
if ( x<0 || y<0 || x>=img->width || y>=img->height )
{
if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
fprintf(stderr, "Errplot RGB X=%d, Y=%d %d, %d, %d\n", x, y, r, g, b);
#if FORCE_ABORT
abort();
@@ -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)
{
if ( x<0 || y<0 || x>=img->width || y>=img->height )
{
if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
/* may be an #if DEBUG_LEVEL here ? */
fprintf(stderr, "Errplot RGBA X %4d Y %4d %d, %d, %d, %d\n",
x, y, r, g, b, a);
@@ -387,11 +375,9 @@ if ( x<0 || y<0 || x>=img->width || y>=img->height )
return OLL_KORRECT;
}
/*::------------------------------------------------------------------::*/
int
Image_getRGB(Image_Desc *img, int x, int y, int *pr, int *pg, int *pb)
int Image_getRGB(Image_Desc *img, int x, int y, int *pr, int *pg, int *pb)
{
if ( x<0 || y<0 || x>=img->width || y>=img->height )
{
if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
/* may be an #if DEBUG_LEVEL here ? */
fprintf(stderr, "ERR GETRGB X %4d Y %4d\n", x, y);
#if FORCE_ABORT
@@ -407,11 +393,9 @@ if ( x<0 || y<0 || x>=img->width || y>=img->height )
return OLL_KORRECT;
}
/*::------------------------------------------------------------------::*/
int
Image_getRGBA(Image_Desc *img, int x, int y, int *pr, int *pg, int *pb, int *pa)
int Image_getRGBA(Image_Desc *img, int x, int y, int *pr, int *pg, int *pb, int *pa)
{
if ( x<0 || y<0 || x>=img->width || y>=img->height )
{
if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
fprintf(stderr, "ERR GETRGBA X %4d Y %4d\n", x, y);
#if FORCE_ABORT
abort();
@@ -419,10 +403,9 @@ if ( x<0 || y<0 || x>=img->width || y>=img->height )
return OUT_OF_IMAGE;
}
if (img->type != IMAGE_RGBA)
{
fprintf(stderr, "Image get RGBA: bad image type: %d, %s\n",
img->type, Image_type2str(img->type));
if (img->type != IMAGE_RGBA) {
fprintf(stderr, "%s: bad image type: %d, %s\n",
__func__, img->type, Image_type2str(img->type));
#if FORCE_ABORT
abort();
#endif
@@ -443,16 +426,14 @@ return OLL_KORRECT;
*/
int Image_plot_channel(Image_Desc *img, char channel, int x, int y, int value)
{
if ( x<0 || y<0 || x>=img->width || y>=img->height )
{
if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
#if DEBUG_LEVEL
fprintf(stderr, "ERR PLOTCHANNEL X %4d Y %4d\n", x, y);
#endif
return OUT_OF_IMAGE;
}
switch (channel)
{
switch (channel) {
case 'r': case 'R': (img->Rpix[y])[x] = (uint8_t)(value&0xff); break;
case 'g': case 'G': (img->Gpix[y])[x] = (uint8_t)(value&0xff); break;
case 'b': case 'B': (img->Bpix[y])[x] = (uint8_t)(value&0xff); break;
@@ -466,44 +447,36 @@ return OLL_KORRECT;
/*
lecture d'une des composantes de l'image.
*/
int
Image_R_pixel(Image_Desc *img, int x, int y)
int Image_R_pixel(Image_Desc *img, int x, int y)
{
if ( x<0 || y<0 || x>=img->width || y>=img->height )
{
if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
fprintf(stderr, "ERR READ R PIX X%d Y%d\n", x, y);
return OUT_OF_IMAGE;
}
return (int)((img->Rpix[y])[x]);
}
int
Image_G_pixel(Image_Desc *img, int x, int y)
int Image_G_pixel(Image_Desc *img, int x, int y)
{
if ( x<0 || y<0 || x>=img->width || y>=img->height )
{
if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
fprintf(stderr, "ERR READ G PIX X%d Y%d\n", x, y);
return OUT_OF_IMAGE;
}
return (int)((img->Gpix[y])[x]);
}
int
Image_B_pixel(Image_Desc *img, int x, int y)
int Image_B_pixel(Image_Desc *img, int x, int y)
{
if ( x<0 || y<0 || x>=img->width || y>=img->height )
{
if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
fprintf(stderr, "ERR READ B PIX X%d Y%d\n", x, y);
return OUT_OF_IMAGE;
}
return (int)((img->Bpix[y])[x]);
}
int
Image_A_pixel(Image_Desc *img, int x, int y)
int Image_A_pixel(Image_Desc *img, int x, int y)
{
if ( x<0 || y<0 || x>=img->width || y>=img->height )
{
if ( x<0 || y<0 || x>=img->width || y>=img->height ) {
fprintf(stderr, "ERR A PIX X%d Y%d\n", x, y);
return OUT_OF_IMAGE;
}
@@ -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)
{
@@ -563,18 +536,16 @@ return OLL_KORRECT;
*/
int Image_compare_desc(Image_Desc *a, Image_Desc *b)
{
char *fmt = "Image at %p have no 'Dead Beef' in it\n";
char *fmt = "%s: Image at %p have no 'Dead Beef' in it\n";
if ( (a==NULL) || (b==NULL) ) return NULL_DESCRIPTOR;
if ( a->magic != MAGIC_OF_IMAGE )
{
fprintf(stderr, fmt, a);
if ( a->magic != MAGIC_OF_IMAGE ) {
fprintf(stderr, fmt, __func__, a);
return NOT_AN_IMAGE_DESC;
}
if ( b->magic != MAGIC_OF_IMAGE )
{
fprintf(stderr, fmt, a);
if ( b->magic != MAGIC_OF_IMAGE ) {
fprintf(stderr, fmt, __func__, a);
return NOT_AN_IMAGE_DESC;
}
@@ -592,8 +563,7 @@ return OLL_KORRECT;
c'est qu'il reste un pointeur fou chez
l'appelant ...
*/
int
Image_DeAllocate(Image_Desc *im)
int Image_DeAllocate(Image_Desc *im)
{
int line;

View File

@@ -64,7 +64,6 @@ printf("RGBA : %5ld\n", sizeof(RGBA));
printf("A_BitPlane : %5ld\n", sizeof(A_BitPlane));
printf("RGB_map : %5ld\n", sizeof(RGB_map));
printf("Image_Point : %5ld\n", sizeof(Image_Point));
printf("RGB LUTs : %5ld\n", sizeof(Image_LUTs));
}
/*::------------------------------------------------------------------::*/

View File

@@ -167,9 +167,9 @@ if ( (foo=Image_compare_desc(src, dst)) ) {
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((histb=(long *)alloca(256*sizeof(long))) == 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((cumlb=(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((cumlb=(int *)alloca(256*sizeof(int))) == NULL) return BUFFER_NO_MEM;
Image_histo_RGB(src, histr, histg, histb);

View File

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

View File

@@ -2,7 +2,7 @@
pov_hf15e.c
===========
opérations de morphologie mathématique appliquées
operations de morphologie mathematique appliquees
aux height-fields.
*/
@@ -18,40 +18,30 @@ static struct
int x, y;
} off[] =
{
{ -1, -1 },
{ 0, -1 },
{ 1, -1 },
{ -1, 0 },
{ 0, 0 },
{ 1, 0 },
{ -1, 1 },
{ 0, 1 },
{ 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 ?
*/
int
Image_hf15_dilate(Image_Desc *src, Image_Desc *dst, int coef)
int Image_hf15_dilate(Image_Desc *src, Image_Desc *dst, int coef)
{
(void)coef; /* KILL WARNING */
int foo;
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);
return foo;
}
for (y=1; y<dst->height-1; y++)
{
for (x=1; x<dst->width-1; x++)
{
for (y=1; y<dst->height-1; y++) {
for (x=1; x<dst->width-1; x++) {
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);
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
Image_hf15_erode(Image_Desc *src, Image_Desc *dst, int coef)
int Image_hf15_erode(Image_Desc *src, Image_Desc *dst, int coef)
{
(void)coef; /* KILL WARNING */
int foo;
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);
return foo;
}
for (y=1; y<dst->height-1; y++)
{
for (x=1; x<dst->width-1; x++)
{
for (y=1; y<dst->height-1; y++) {
for (x=1; x<dst->width-1; x++) {
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);
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;
#if DEBUG_LEVEL
fprintf(stderr, "Image PtList: alloc: %d '%s'\n", nbre, name);
fprintf(stderr, ">>> %s ( %d '%s' )\n", __func__, nbre, name);
#endif
if ( (ptr=malloc(sizeof(Image_PtList)))==NULL)
{
if ( (ptr=malloc(sizeof(Image_PtList)))==NULL) {
fprintf(stderr, "Image PtList: struct malloc failed\n");
#if FORCE_ABORT
abort();
@@ -56,8 +55,7 @@ if (strlen(name) < IMG_OBJNAME_LEN)
else
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");
#if FORCE_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 */
if (ptl->control != 0xfde9601a)
{
if (ptl->control != 0xfde9601a) {
fprintf(stderr, "ptl addpt: invalid point list %p\n", ptl);
#if FORCE_ABORT
abort();
@@ -91,12 +88,10 @@ if (ptl->control != 0xfde9601a)
/*
* 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;
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__);
exit(5);
}
@@ -117,7 +112,7 @@ return FUNC_IS_BETA;
/*
* attention, il est _important_ de respecter le format d'écriture
* 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.
*/
int Image_ptl_write(char *filename, Image_PtList *ptl)
@@ -125,17 +120,15 @@ int Image_ptl_write(char *filename, Image_PtList *ptl)
FILE *fp;
int foo;
if ( (fp=fopen(filename, "w"))==NULL )
{
fprintf(stderr, "Image PtList: write: fopen fail.\n");
if ( (fp=fopen(filename, "w"))==NULL ) {
fprintf(stderr, "%s: write %s fopen fail.\n", __func__, filename);
return FILE_CREATE_ERR;
}
fprintf(fp, "%8d\n", ptl->nbre);
fprintf(fp, "%08d%08d\n", ptl->width, ptl->height);
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",
ptl->points[foo].x, ptl->points[foo].y,
ptl->points[foo].h, ptl->points[foo].c);
@@ -155,8 +148,7 @@ int foo;
fprintf(stderr, ">>> %s ( '%s' %p )\n", __func__, filename, ptl);
#endif
if (ptl->control != 0xfde9601a)
{
if (ptl->control != 0xfde9601a) {
fprintf(stderr, "%s: no deadbeef in %p\n", __func__, ptl);
fprintf(stderr, " can't read '%s'\n", filename);
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);
#endif
if (ptl->control != 0xfde9601a)
{
if (ptl->control != 0xfde9601a) {
fprintf(stderr, "%s: no deadbeef in %p\n", __func__, ptl);
return 666;
}
@@ -198,8 +189,7 @@ return FULL_NUCKED;
int
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);
return 666;
}
@@ -211,19 +201,16 @@ return OLL_KORRECT;
/*::------------------------------------------------------------------::*/
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);
return 666;
}
if (idx < 0)
{
if (idx < 0) {
fprintf(stderr, "%s:%s point idx %d is negative, so bad !\n",
__FILE__, __func__, idx);
return FULL_NUCKED;
}
if (idx>ptl->nbre)
{
if (idx>ptl->nbre) {
fprintf(stderr, "%s:%s point idx %d is too big, so bad !\n",
__FILE__, __func__, idx);
return FULL_NUCKED;
@@ -243,8 +230,7 @@ int Image_ptl_boundingbox(Image_PtList *ptl, Image_Rect *box)
int xmin, ymin, xmax, ymax;
int foo;
if (ptl->control != 0xfde9601a)
{
if (ptl->control != 0xfde9601a) {
fprintf(stderr, "%s: no deadbeef in %p\n", __func__, ptl);
return 666;
}
@@ -252,8 +238,7 @@ if (ptl->control != 0xfde9601a)
xmin = ymin = 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 > xmax) xmax = ptl->points[foo].x;
if (ptl->points[foo].y < ymin) ymin = ptl->points[foo].y;

View File

@@ -4,6 +4,7 @@
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "../tthimage.h"
@@ -15,6 +16,8 @@
* fait le meme genre de truc, mais en bien mieux...
*
*/
/* Private variables */
static Image_Desc *S, *D;
static int seuil;
static int level, maxlevel;
@@ -25,7 +28,8 @@ Image_Rect rect;
int h1, h2, w1, w2, xx, yy, foo;
int mr, mg, mb, dr, dg, db, s;
level++;
level++; /* pourquoi ? */
if (level > maxlevel)
maxlevel = level;
@@ -35,10 +39,16 @@ fprintf(stderr, "%5d -> %3d %3d %3d %3d\n",
#endif
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;
#if DEBUG_LEVEL > 1
printf(" %7d V %3d %3d %3d D %3d %3d %3d S %3d (%d)\n",
pRect->w*pRect->h, mr, mg, mb, dr, dg, db, s, foo);
#if 1
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
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;
int foo;
#if 1
fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, image, dest, param);
#endif
rect.x = rect.y = 0;
rect.h = image->height;
rect.w = image->width;
@@ -135,17 +149,7 @@ fprintf(stderr, "-> fin recursion: %d, maxlevel=%d\n", foo, maxlevel);
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
*/
int
Image_rgbmask_H(Image_Desc *src, Image_Desc *dst, int gris)
int Image_rgbmask_H(Image_Desc *src, Image_Desc *dst, int gris)
{
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);
return foo;
}
Image_copy(src, dst); /* XXX pourquoi cette copie ? */
for (y=0; y<src->height; y++)
{
for (x=0; x<src->width; x++)
{
switch (y%3)
{
for (y=0; y<src->height; y++) {
for (x=0; x<src->width; x++) {
switch (y%3) {
case 0:
Image_plot_channel(dst, 'r', x, y, gris);
Image_plot_channel(dst, 'g', x, y, gris);
@@ -57,25 +52,19 @@ return FUNC_IS_BETA;
/*
* vertical lines
*/
int
Image_rgbmask_V(Image_Desc *src, Image_Desc *dst, int gris)
int Image_rgbmask_V(Image_Desc *src, Image_Desc *dst, int gris)
{
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);
return foo;
}
Image_copy(src, dst);
for (y=0; y<src->height; y++)
{
for (x=0; x<src->width; x++)
{
switch (x%3)
{
for (y=0; y<src->height; y++) {
for (x=0; x<src->width; x++) {
switch (x%3) {
case 0:
Image_plot_channel(dst, 'r', 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.
*/
int
Image_rgbmask_2(Image_Desc *src, Image_Desc *dst, int gris)
int Image_rgbmask_2(Image_Desc *src, Image_Desc *dst, int gris)
{
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);
return foo;
}
Image_copy(src, dst);
foo = 0;
for (y=0; y<src->height; y++)
{
for (x=0; x<src->width; x++)
{
for (y=0; y<src->height; y++) {
for (x=0; x<src->width; x++) {
foo++;
switch (foo%3)
{
switch (foo%3) {
case 0:
Image_plot_channel(dst, 'r', x, y, gris);
Image_plot_channel(dst, 'g', x, y, gris);
@@ -140,8 +124,7 @@ return FUNC_IS_BETA;
/*
* random dots - VERY BAD RESULTS :(
*/
int
Image_rgbmask_R(Image_Desc *src, Image_Desc *dst, int gris)
int Image_rgbmask_R(Image_Desc *src, Image_Desc *dst, int gris)
{
int foo, x, y;
@@ -149,20 +132,16 @@ int foo, x, y;
fprintf(stderr, "this function, %s(%d), is very buggy...\n", __func__, gris);
#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);
return foo;
}
Image_copy(src, dst);
for (y=0; y<src->height; y++)
{
for (x=0; x<src->width; x++)
{
for (y=0; y<src->height; y++) {
for (x=0; x<src->width; x++) {
foo = rand() % 3; /* mmmm pas tres bon :( */
switch (foo)
{
switch (foo) {
case 0:
Image_plot_channel(dst, 'r', x, y, gris);
Image_plot_channel(dst, 'g', x, y, gris);

View File

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

View File

@@ -123,13 +123,13 @@ xmax = src->width - w; ymax = src->height - h;
ox = (src->width % w) / 2;
oy = (src->height % h) / 2;
#if DEBUG_LEVEL
fprintf(stderr, "%s : offsets = %d %d\n", __func__, ox, oy);
fprintf(stderr, "%s : offsets = %d & %d\n", __func__, ox, oy);
#endif
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);
for (y=oy; y<ymax; y+=h) {
for (y=oy; y<(ymax-oy); y+=h) {
zone.y = y + (h/2);
r = src->Rpix[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)
{
@@ -200,7 +200,7 @@ int foo;
int y, taille;
#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
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);
#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++) {
switch (rand()%3) {

View File

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

View File

@@ -22,7 +22,9 @@ int foo;
fprintf(stderr, ">>> %s ( '%s' ) \n", __func__, filename);
#if 0
foo = try_to_read_a_jpeg_file(filename, &destimg);
#endif
return FULL_NUCKED;
}
@@ -30,7 +32,7 @@ return FULL_NUCKED;
int main(int argc, char *argv[])
{
char *fichier;
int foo;
int foo, idx;
printf("\n========== TestTga %s %s ==========\n", __DATE__, __TIME__);
Image_print_version(2);
@@ -39,8 +41,7 @@ Image_print_version(2);
Image_print_sizeof_structs("tth was here");
#endif
if (argc != 2)
{
if (argc != 2) {
printf("no args, using the testfile\n");
fichier = "wou.tga";
}
@@ -52,13 +53,34 @@ else
Image_start_chrono("Essai", 0);
foo = test_du_jpeg_reader("in.jpeg");
fprintf(stderr, " essai lecture jpeg -> %d\n", foo);
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);
fprintf(stderr, "\n*************** %s: fin passe %d ******\n\n",
argv[0], idx);
}
#if 0
foo = Test_Dithering(fichier, 17);
fprintf(stderr, "essai dithering -> %d\n", foo);
foo = test_du_jpeg_reader("in.jpeg");
fprintf(stderr, " essai lecture jpeg -> %d\n", foo);
Test_des_patterns("/tmp/pattt", 0, 0);
foo = Essai_des_jauges(fichier, 17);
@@ -74,6 +96,7 @@ Test_des_warpings(fichier, 17);
foo = Essai_des_Combines(fichier, 17);
fprintf(stderr, "essai combine -> %d\n", foo);
foo = Test_Dithering(fichier, 17);
Essai_des_Contrastes(fichier, 0);

View File

@@ -220,7 +220,8 @@ posx = x; posy = y;
for (foo=0; foo<t_texte; foo++) {
octet = ptrtxt[foo];
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;
}
Image_trace_caractere_2(im, priv_fonte, posx, posy, octet, paper, ink);
@@ -259,23 +260,19 @@ if ( (code < 0) || (code > 255)) {
paper.r = paper.g = paper.b = 0;
ink.r = ink.g = ink.b = 255;
rect.w = kx, rect.h = ky;
/*
* 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];
rect.y = (foo * ky) + y;
for (bar=0; bar<8; bar++)
{
for (bar=0; bar<8; bar++) {
rect.x = (bar * kx) + x;
rect.x = ((8-bar)*kx) + x;
if (octet & 1)
{
if (octet & 1) {
Image_paint_rect(im, &rect, 255, 198, 0);
Image_draw_rect(im, &rect, 0, 0, 80);
}

View File

@@ -179,7 +179,7 @@ fprintf(stderr, "%s: ltr %3d '%c' %4d %4d\n", __func__, lettre,
#endif
/*
* use default if not provided my caller
* use default if not provided by caller
*/
if (NULL==pap) pap = &blanc;
if (NULL==ink) ink = &noir;

View File

@@ -12,7 +12,7 @@
#include "../tthimage.h"
/*::------------------------------------------------------------------::*/
#define LIBTGA_VERSION "0.2.42"
#define LIBTGA_VERSION "0.2.43"
typedef struct {
uint8_t text_size;
@@ -27,6 +27,9 @@ typedef struct {
} Tga_file_header;
/*::------------------------------------------------------------------::*/
/*
*
*/
int Image_TGA_write_header(FILE *fp, Tga_file_header *head)
{
fwrite (&head->text_size, 1, 1, fp);
@@ -423,6 +426,8 @@ return OLL_KORRECT;
/* new 1er mai 2007 (la france qui bosse tout le temps) */
int Image_TGA_show_header(char *filename, int flag)
{
(void)flag; /* WARNING KILLER */
FILE *fp;
Tga_file_header header;
int foo;
@@ -443,7 +448,7 @@ if (foo) {
foo = Image_TGA_print_header(&header);
if (foo)
{
;
fprintf(stderr, "%s: something is wrong\n", __func__);
}
return FUNC_NOT_FINISH;
@@ -497,8 +502,7 @@ return OLL_KORRECT;
* que les images RGB. il manque le GRIS !!!
* ! il manque aussi la decompression !
*/
Image_Desc *
Image_TGA_alloc_load(char *nom)
Image_Desc * Image_TGA_alloc_load(char *nom)
{
Tga_file_header head;
FILE *fp;
@@ -516,6 +520,11 @@ if ( (fp=fopen(nom, "rb")) == NULL )
memset(&head, 0, sizeof(Tga_file_header));
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
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

@@ -28,6 +28,9 @@ 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

View File

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

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;
}
/*::------------------------------------------------------------------::*/
int
Image_warp_essai_1(Image_Desc *src, Image_Desc *dst, double angle)
int Image_warp_essai_1(Image_Desc *src, Image_Desc *dst, double angle, double shift)
{
#if DEBUG_LEVEL
fprintf(stderr, "Warp 1: what I can do here ?\n");
#endif
fprintf(stderr, ">>> %s ( %p %p %f %f )\n", __func__, src, dst, angle, shift);
return FUNC_NOT_FINISH;
}

View File

@@ -14,12 +14,13 @@ HTML_DIR=$(DESTDIR)/html
# pour tracer plein de trucs: -DDEBUG_LEVEL=1
# if IMGCOMMENT, the image comment is written to the TGA file,
# but this files can't be loaded by Xv...
#
# pour coredumper dans les situations graves: -DABORT=1
#
# use -Wmissing-prototypes ?
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
CFLAGS= $(CC_OPTS) \

View File

@@ -1,34 +1,34 @@
# 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,
puis s'est un jour retrouvé dans un Linux (kernel 0.99) et qui végète
Du code né dans les années 1990 sur un Kenitec 286 sous msdos 4 ou 5,
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, mais
la tâche n'est pas terminée.
## Construction
Tout va bien se passer. Mais c'est assez rudimentaire, il y a deux scripts
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
[Paramakes.mk](Paramakes.mk). Là aussi, soyez attentifs.
## Utilisation
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 l'ancien temps, avant la reprise en main de ces dernières années.
## Les outils
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...
conventionnel, mais bon, *legacy*, toussa...
## La suite ?

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
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
du désastre actuel. Il reste beaucoup de choses à faire.
## 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

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

View File

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

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);
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");

6
Tools/.gitignore vendored
View File

@@ -3,4 +3,8 @@
*.scratch
tga_extract
tga_to_text
tga_plothisto
tga_plotmap
tga_resize
tga_fractales

View File

@@ -12,7 +12,9 @@ all: genplot2 \
tga_cadre tga_effects tga_filtres tga_remap tga_tools \
tga_combine tga_export tga_alpha tga_extract \
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
@@ -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
gcc $(CFLAGS) $< ../libtthimage.a fonctions.o -lm -o $@
@@ -77,8 +98,8 @@ tga_extract: tga_extract.c $(DEPS) fonctions.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_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
Pour utiliser toutes ces fonctions, il y a une collection d'utilitaires
spécialisés. Leur interface en `CLI` est assez rudimentaire, mais la
plupart savent donner quelques indices avec la commande `list`. Exemple:
Pour utiliser toutes les fonctions de la bibliothèque,
il y a une collection d'utilitaires spécialisés.
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
@@ -12,7 +14,7 @@ Usage:
tga_filtres <src.tga> FILTR <dst.tga> [p1] ... [pn]
-+- This is the `tthimage' library v0.4.50 (dwtfywl 2022) tTh
commande | type arg | explication
------------+----------+------------------------------------
------------+----------+------------------------------
liss2x2 | | lissage 2x2
hipass | |
lopass | |
@@ -29,17 +31,28 @@ La colonne du milieu indique le type des paramètres :
## tga_alpha
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
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**
## tga_cadre
Pas mal de façons de mettre un cadre sur l'image.
Niveau de kitchitude assez élevé.
Paramètres mal documentés.
Il existe pas mal de façons de mettre un cadre sur l'image,
avec un niveau de kitchitude assez élevé.
Les paramètres sont mal documentés.
## tga_combine
@@ -47,9 +60,9 @@ Paramètres mal documentés.
Usage:
tga_combine s1.tga s2.tga MODE d.tga [PARAMS]
```
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
@@ -65,10 +78,25 @@ Attendu avec impatience, il aura le support complet des PNG. Un jour...
## tga_filtres
UTSL : [tga_filtres.c](caractère \textbf{invisible})
## tga_incrust
## 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
La génération de diverses image de test ou de calibration.
@@ -80,19 +108,68 @@ vraiment trop nulle...
## 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_tools
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
width=512 height=512
tth@konrad:~/Devel/libtthimage$
tth@redlady:~/Devel/libtthimage$ tga_tools getdimweb foo.tga
width=640 height=480
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
Outil de tracé pseudo-générique et farci de bugs. WIP ME HARDLY !
Outil de tracé pseudo-générique et farci de bugs. *WIP ME HARDLY !*

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);

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

View File

@@ -11,7 +11,7 @@
/*::------------------------------------------------------------------::*/
void usage(int flag)
{
fprintf(stderr, "* tga_applymap v 0.0.14 [%s] (dwtfywl) Krabulator 1910\n",
fprintf(stderr, "* tga_applymap v 0.0.15 [%s] (dwtfywl) Krabulator 1910\n",
TGA_OUTILS_VERSION);
fprintf(stderr, " compiled %s at %s\n", __DATE__, __TIME__);
@@ -38,6 +38,8 @@ if ( (src=Image_TGA_alloc_load(argv[2])) == NULL ) {
exit(1);
}
memset(&map, 0, sizeof(map));
if ( (foo=Image_load_color_Map(argv[3], "map", &map)) ) {
fprintf(stderr, "%s: %s: err%d %s\n", argv[0], argv[3],
foo, Image_err2str(foo));

View File

@@ -442,7 +442,7 @@ switch (commande)
}
if (foo) {
fprintf(stderr, "%s: return code is %d\n", __FILE__, foo);
/* fprintf(stderr, "%s: return code is %d\n", __FILE__, foo); */
Image_print_error(argv[0], foo);
}

View File

@@ -15,6 +15,7 @@
#define EQ_STD 4
#define EQ_GRAY 8
#define EQ_COS01 9
#define EQ_COS010 10
#define EQ_2X2 12
#define EQ_LUMIN 14
#define EQ_SQUARE 16
@@ -28,6 +29,7 @@ mot_clef mots_clef[] =
{ "rgb", EQ_STD, "", "same as 'std'" },
{ "gray", EQ_GRAY, "", "gray based" },
{ "cos01", EQ_COS01, "", "cosinus 0->1" },
{ "cos010", EQ_COS010, "", "cosinus 0-1-0" },
{ "2x2", EQ_2X2, "", "2x2 matrix" },
{ "lumin", EQ_LUMIN, "i", "param: ident is 256" },
/* { "gamma", EQ_GAMMA, "d", "not implemented" },*/
@@ -40,7 +42,7 @@ mot_clef mots_clef[] =
/*::------------------------------------------------------------------::*/
void usage()
{
fprintf(stderr, "* tga_equalize v 0.0.23 [%s] (dwtfywl) tonton Th\n",
fprintf(stderr, "* tga_equalize v 0.0.25 [%s] (dwtfywl) tonton Th\n",
TGA_OUTILS_VERSION);
fprintf(stderr, " compiled %s at %s\n", __DATE__, __TIME__);
fprintf(stderr, "usage:\n\ttga_equalize avant.tga mode apres.tga [params]\n");
@@ -112,6 +114,10 @@ switch (commande)
foo = Image_egalise_cos01(src, dst, 0);
break;
case EQ_COS010:
foo = Image_egalise_cos010(src, dst, 0);
break;
case EQ_GAMMA:
fprintf(stderr, "no gamma func in %d\n", getpid());
foo = FULL_NUCKED;
@@ -123,6 +129,7 @@ switch (commande)
default:
fprintf(stderr, "unexpected command #%d\n", commande);
foo=-1;
break;
}

128
Tools/tga_fractales.c Normal file
View File

@@ -0,0 +1,128 @@
/*
FRACTALES
---------
Il reste beaucoup de travail sur cet outil:
- plasma
- popcorn
- newton: oct 2003, c'est en route. janv 2010 pas fini.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "tga_outils.h"
#include "fractales.h"
/*::------------------------------------------------------------------::*/
#define MANDEL0 1
#define JULIA00 2
#define GINGER 3
#define NEWTON0 10
#define NEWTON1 11
#define LORENZ0 12
mot_clef mots_clef[] =
{
{ "ginger", GINGER, "ii", "width & height" },
{ "julia00", JULIA00, "ii", "width & height" },
{ "mandel0", MANDEL0, "ii", "width & height" },
{ "newton0", NEWTON0, "ii", "width & height" },
{ "lorenz0", LORENZ0, "ii", "W & H" },
{ NULL, 0, NULL, NULL }
};
/*::------------------------------------------------------------------::*/
void usage(int flag)
{
Image_fractales_print_version(flag);
fprintf(stderr, "usage:\n\ttga_fractales type nom.tga [params]\n");
if (flag)
{
Image_print_version(1);
liste_mots_clefs(mots_clef, 42);
}
exit(1);
}
/*::------------------------------------------------------------------::*/
/*
* argv[1]: type fractale
* argv[2]: nom fichier.tga
*/
#define FIRST_PAR 3
int main (int argc, char *argv[])
{
Image_Desc *dst;
int foo, width, height;
int commande, nbargs, idx;
RGB_map map;
dump_command_line(argc, argv, 0);
if ( argc==2 && !strcmp(argv[1], "list") ) usage(1);
if ( argc < 3 ) usage(0);
idx = cherche_mot_clef(argv[1], mots_clef, &commande, &nbargs);
if (idx < 0)
{
fprintf(stderr, "tga_fractales: mot-clef %s inconnu...\n", argv[1]);
exit(5);
}
#if DEBUG_LEVEL
fprintf(stderr, "code commande %d\n", commande);
#endif
foo = parse_parametres(argc, argv, mots_clef[idx].ptypes, FIRST_PAR);
dst = NULL; /* gcc warning STFU */
switch (commande)
{
case MANDEL0:
width = GIP(0); height = GIP(1);
printf("mandelbrot 0: %dx%d\n", width, height);
dst = Image_alloc(width, height, 3);
foo = Image_Mandelbrot_0(dst, 300);
Image_print_error("mandelbrot 0", foo);
break;
case JULIA00:
width = GIP(0); height = GIP(1);
foo = Image_load_color_Map("volcano.map", "plop", &map);
Image_print_error("julia00: loadmap", foo);
dst = Image_alloc(width, height, 3);
Image_Julia_0_0(dst, &map, 3000, 0.333, 0.333);
Image_print_error("julia00: calcul", foo);
break;
case GINGER:
width = GIP(0); height = GIP(1);
printf("ginger bread man: %dx%d\n", width, height);
dst = Image_alloc(width, height, 3);
foo = GingerBreadMan(dst, 300);
Image_print_error("GingerBreadMan", foo);
break;
case NEWTON0:
width = GIP(0); height = GIP(1);
printf("newton 0: %dx%d\n", width, height);
dst = Image_alloc(width, height, 3);
foo = Newton_0(dst, 42);
Image_print_error("proto Newton 0", foo);
break;
case LORENZ0:
width = GIP(0); height = GIP(1);
printf("lorenz 0: %dx%d\n", width, height);
dst = Image_alloc(width, height, 3);
foo = Lorenz_Orbits(dst, 3000, 5.0, 15.0, 1.0, 0.02);
Image_print_error("lorenz 0", foo);
break;
default:
fprintf(stderr, "Cette fractale n'est pas disponible.\n");
exit(1);
break;
}
foo = Image_TGA_save(argv[2], dst, 0);
return 0;
}
/*::------------------------------------------------------------------::*/

View File

@@ -42,7 +42,7 @@ fprintf(stderr, "* TGA incrustator v 0.1.3 [%s] %s \n",
TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT);
fprintf(stderr, " compiled %s at %s\n", __DATE__, __TIME__);
fprintf(stderr, "usage:\n\ttga_incrust orig insert mode out\n");
fprintf(stderr, "usage:\n\ttga_incrust <orig.tga> <insert.tga> MODE <out.tga>\n");
if (flag) {
Image_print_version(0);

61
Tools/tga_plothisto.c Normal file
View File

@@ -0,0 +1,61 @@
/*
utilitaire pour plotter les histogrammes d'une image.
-----------------------------------------------------
*/
#include <stdio.h>
#include <stdlib.h>
#include "tga_outils.h"
void usage()
{
fprintf(stderr, "*** tga_plothisto v 0.1.3 [%s] %s\n",
TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT);
fprintf(stderr, "\nusage: tga_plothisto image.tga histo.tga [texte]\n\n");
Image_print_version(0);
exit(5);
}
int main (int argc, char *argv[])
{
Image_Desc *src;
long hr[256], hg[256], hb[256];
int foo;
char *texte;
dump_command_line(argc, argv, 0);
if (argc < 3)
{
/*fprintf(stderr, "argc = %d\n", argc);*/
usage();
}
if ( (src=Image_TGA_alloc_load(argv[1])) == NULL )
{
fprintf(stderr, "tga_plothisto, chargement '%s' failed\n", argv[1]);
exit(5);
}
foo = Image_histo_RGB(src, hr, hb, hg);
if (foo)
{
fprintf(stderr, "tga_plothisto, calcul histogramme: %d %s\n",
foo, Image_err2str(foo));
exit(5);
}
if (argc == 3) texte = argv[1];
else texte = argv[3];
foo = Image_plot_histo(argv[2], hr, hg, hb, texte);
if (foo)
{
fprintf(stderr, "tga_plothisto, dessin de '%s': %d %s\n",
argv[2], foo, Image_err2str(foo));
exit(5);
}
return 0;
}

64
Tools/tga_plotmap.c Normal file
View File

@@ -0,0 +1,64 @@
/*
----------------------------------------------
utilitaire pour tracer une map 'a la fractint'
----------------------------------------------
http://tth.zouh.org/libimage.html
----------------------------------------------
*/
#include <stdio.h>
#include <stdlib.h>
#include "tga_outils.h"
/* ------------------------------------------------------------------ */
void usage()
{
fprintf(stderr, "* tga_plotmap v 0.1.11 [%s] %s\n",
TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT);
fprintf(stderr, "usage:\n\ttga_plotmap colors.map graphe.tga [texte]\n\n");
Image_print_version(1);
exit(5);
}
#define CLASSIC 1
#define PAPER 2
#define SQUARE 3
mot_clef mots_clef[] =
{
{ "classic", CLASSIC, "", "classic" },
{ "paper", PAPER, "", "papier" },
{ "square", SQUARE, "", "square" },
{ NULL, 0, "", NULL }
};
/* ------------------------------------------------------------------ */
int main (int argc, char *argv[])
{
RGB_map map;
int foo;
dump_command_line(argc, argv, 0);
if ((argc!=3)&&(argc!=4)) usage();
foo = Image_load_color_Map(argv[1], "tga_plotmap", &map);
if (foo)
{
fprintf(stderr, "tga_plotmap, chargement '%s': %d %s\n",
argv[1], foo, Image_err2str(foo));
exit(5);
}
fprintf(stderr, "map file %s have %d colors\n", argv[1], map.nbre);
foo = Image_plot_Map(argv[2], &map, argc==4?argv[3]:argv[1]);
if (foo)
{
fprintf(stderr, "tga_plotmap, dessin de '%s': %d %s\n",
argv[2], foo, Image_err2str(foo));
}
return 0;
}

145
Tools/tga_resize.c Normal file
View File

@@ -0,0 +1,145 @@
/*
...............................
.redimensionnement d'une image.
...............................
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "tga_outils.h"
/*::------------------------------------------------------------------::*/
#define HALF_SIZE 1
#define DOUBLE_SIZE 2
#define PERCENT 3
#define NEWSIZE 4
mot_clef mots_clef[] =
{
{ "half", HALF_SIZE, "f", "0:crude 1:interpolate" },
{ "double", DOUBLE_SIZE, "f", "" },
{ "percent", PERCENT, "dii", "%%size, method, 0" },
{ "newsize", NEWSIZE, "iii", "newW newH method" }
};
/*::------------------------------------------------------------------::*/
void usage(int flag)
{
fprintf(stderr, "* Tga Resize v 0.0.13 [%s] %s\n",
TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT);
fprintf(stderr, "usage:\n");
fprintf(stderr, "\ttga_resize source.tga methode resultat.tga [params]\n");
if (flag)
liste_mots_clefs(mots_clef, 42);
else
Image_print_version(0);
exit(5);
}
/*::------------------------------------------------------------------::*/
/*
* argv[1] source.tga
* argv[2] méthode
* argv[3] destination.tga
*/
#define FIRST_PARAM 4
int main(int argc, char *argv[])
{
Image_Desc *src, *dst;
int foo, idx;
int commande, nbargs, interpol;
double scale, scaleX, scaleY;
int newW, newH;
dump_command_line(argc, argv, 0);
if ( argc==2 && !strcmp(argv[1], "list") ) usage(1);
if ( argc < 4) usage(0);
/*
* rechercher le mot clef dans la table
*/
idx = cherche_mot_clef(argv[2], mots_clef, &commande, &nbargs);
if (idx < 0)
{
fprintf(stderr, "keyword %s unknow\n", argv[1]);
exit(5);
}
/*
* décodage des paramètres
*/
foo = parse_parametres(argc, argv, mots_clef[idx].ptypes, FIRST_PARAM);
#if DEBUG_LEVEL
fprintf(stderr, "tga_resize: ret parse parameters = %d\n", foo);
#endif
if ((src = Image_TGA_alloc_load(argv[1]))==NULL)
{
fprintf(stderr, "tga_resize: can't load '%s'\n", argv[1]);
exit(5);
}
dst = NULL; /* secure the default case */
switch (commande)
{
case HALF_SIZE:
if ( (dst=Image_MakeHalfSize(src, GFP(0))) == NULL)
{
fprintf(stderr, "tga_resize: half: fatal error\n");
exit(1);
}
foo = 0;
break;
case DOUBLE_SIZE:
if ( (dst=Image_MakeDoubleSize(src, GFP(0))) == NULL)
{
fprintf(stderr, "tga_resize: double: fatal error\n");
exit(1);
}
foo = 0;
break;
case PERCENT:
scale = GDP(0) / 100.0;
interpol = GIP(1);
#if DEBUG_LEVEL
printf(" scale = %f\n", scale);
printf(" interpol = %d\n", interpol);
#endif
if ((dst = Image_new_scale(src, scale, scale, interpol))==NULL)
{
fprintf(stderr, "tga_resize: percent: fatal error\n");
exit(1);
}
break;
case NEWSIZE:
newW = GIP(0);
newH = GIP(1);
printf("new size: %d x %d\n", newW, newH);
scaleX = ((double)newW / (double)src->width);
scaleY = ((double)newH / (double)src->height);
printf("scales: X %f y %f\n", scaleX, scaleY);
if ((dst = Image_new_scale(src, scaleX, scaleY, GIP(2)))==NULL)
{
fprintf(stderr, "tga_resize: newsize: fatal error\n");
exit(1);
}
break;
}
/*
* sauvons vite ce precieux resultat
*/
if (dst != NULL)
foo = Image_TGA_save(argv[3], dst, 0);
return 0;
}
/*::------------------------------------------------------------------::*/

View File

@@ -43,7 +43,7 @@ mot_clef mots_clef[] =
/*::------------------------------------------------------------------::*/
void usage(int flag)
{
fprintf(stderr, "* tga_television v 0.0.24 [%s] %s\n",
fprintf(stderr, "* tga_television v 0.0.25 [%s] %s\n",
TGA_OUTILS_VERSION, TGA_OUTILS_COPYLEFT);
fprintf(stderr, " compiled %s at %s\n", __DATE__, __TIME__);
fprintf(stderr, "Usage:\n\ttga_television <src.tga> method <dst.tga> [params]\n");
@@ -139,7 +139,7 @@ switch (commande)
foo = Image_TV_triligne(src, dst, par[0]);
break;
case TV_PROTO:
case TV_PROTO: /* effet porno canal+ */
foo = Image_TV_cplus_v1(src, dst, par[0]);
break;

64
Tools/tga_to_text.c Normal file
View File

@@ -0,0 +1,64 @@
/*
* TGA to text
* ===========
* new: Mon Feb 26 23:21:21 UTC 2024
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "tga_outils.h"
/*::------------------------------------------------------------------::*/
/*
* Print a textual form of a picture, so you can read it
* with a software who can't read TGA files.
* Exemples: Fortran or Basic code, R, the statistic
* software. And maybe you cant write a shell script
* to convert from TGA to PNM :)
*/
int printf_this_picture(Image_Desc *pic, int flag)
{
int x, y, r, g, b;
if (flag) {
/* needed for easy import in Rstats */
printf(" X Y R G B\n");
}
for (y=0; y<pic->height; y++) {
for (x=0; x<pic->width; x++) {
printf("%5d %5d ", x, y);
Image_getRGB(pic, x, y, &r, &g, &b);
printf("%3d %3d %3d\n", r, g, b);
}
}
return 0;
}
/*::------------------------------------------------------------------::*/
int main (int argc, char *argv[])
{
Image_Desc *src;
int foo;
if (2!=argc) {
fprintf(stderr, "%s need a filename\n", argv[0]);
exit(2);
}
if ((src = Image_TGA_alloc_load(argv[1]))==NULL) {
fprintf(stderr, "TGA to text: can't load image %s\n", argv[1]);
exit(5);
}
foo = printf_this_picture(src, 0);
if (foo) {
fprintf(stderr, "printf_this_picture -> %d\n", foo);
}
return 0;
}
/*::------------------------------------------------------------------::*/

View File

@@ -141,8 +141,7 @@ fprintf(stderr, "%s -> %s : %dx%d, rgb %d,%d,%d\n", __func__, fname, w, h,
r, g, b);
#endif
if (w < 1 || h < 1)
{
if (w < 1 || h < 1) {
fprintf(stderr, "%s : img dims %d %d ?\n", __func__, w, h);
return 666;
}
@@ -168,8 +167,7 @@ Image_Desc *src;
fprintf(stderr, "timestamping '%s' to '%s' with '%s'\n", fnin, fnout, txt);
#endif
if ( (src=Image_TGA_alloc_load(fnin)) == NULL )
{
if ( (src=Image_TGA_alloc_load(fnin)) == NULL ) {
fprintf(stderr, "tga_tools, load of '%s' failed in %s\n",
fnin, __func__);
exit(5);
@@ -207,15 +205,23 @@ if (must_be_verbose()) {
__func__, fnin, fnout, txt, flag);
}
if ( (src=Image_TGA_alloc_load(fnin)) == NULL )
{
if ( (src=Image_TGA_alloc_load(fnin)) == NULL ) {
fprintf(stderr, "tga_tools, load of '%s' failed in %s\n",
fnin, __func__);
exit(5);
}
foo = Image_txt1_box_0(src, txt, posx, posy, 4, &pap, &ink, 0);
Image_TGA_save(fnout, src, 0);
if (foo) {
fprintf(stderr, "err txt1_box_0 = %d\n", foo);
return foo;
}
foo = Image_TGA_save(fnout, src, 0);
if (foo) {
fprintf(stderr, "%s: err TGA save = %d\n", __func__, foo);
return foo;
}
#if DEBUG_LEVEL
fprintf(stderr, "%s : saving %s\n", __func__, fnout);
@@ -234,21 +240,18 @@ if (flags) {
fprintf(stderr, "in %s, flags must be 0\n", __func__);
}
if ( (src=Image_TGA_alloc_load(filename)) == NULL )
{
if ( (src=Image_TGA_alloc_load(filename)) == NULL ) {
fprintf(stderr, "tga_tools, chargement '%s' failed\n", filename);
exit(5);
}
foo = Image_histo_RGB(src, hr, hb, hg);
if (foo)
{
if (foo) {
fprintf(stderr, "tga_tools, calcul histogramme: %d %s\n",
foo, Image_err2str(foo));
exit(5);
}
for (foo=0; foo<256; foo++)
{
for (foo=0; foo<256; foo++) {
printf("%3d %8ld %8ld %8ld\n", foo, hr[foo], hg[foo], hb[foo]);
}
@@ -260,15 +263,13 @@ int print_environ(void)
{
int foo;
char *ptr;
char *noms[] =
{
char *noms[] = {
NOM_VAR_ENV_VERBOSE, NOM_VAR_ENV_TIMING, "LIBIMAGE_PATH",
"TTH_CONF_DIR", "LIBIMAGE_DEBUG", "BITMAP_FONTS",
"FIXED_SEED", ENV_DEFAULT_RGBA
};
for (foo=0; foo<(int)(sizeof(noms)/sizeof(char *)); foo++)
{
for (foo=0; foo<(int)(sizeof(noms)/sizeof(char *)); foo++) {
ptr = getenv(noms[foo]);
printf("%5d %-25s %s\n", foo, noms[foo], ptr);
}
@@ -286,8 +287,7 @@ char buffer[100];
fprintf(stderr, "%s:%s %s %d\n", __FILE__, __func__, fname, value);
#endif
if ( (src=Image_TGA_alloc_load(fname)) == NULL )
{
if ( (src=Image_TGA_alloc_load(fname)) == NULL ) {
fprintf(stderr, "tga_tools, load of '%s' failed in %s\n",
fname, __func__);
exit(5);
@@ -339,16 +339,14 @@ foo = set_new_seed(42);
fprintf(stderr, "!!! set new seed -> %d\n", foo);
#endif
if (1 == argc)
{
if (1 == argc) {
fprintf(stderr, "* tga_tools v 0.1.33 (%s) *\n", __DATE__);
fprintf(stderr, "usage:\n\t%s action f.tga [params]\n", argv[0]);
liste_mots_clefs(commandes, 42);
exit(0);
}
if (-1 == (idx=cherche_mot_clef(argv[1], commandes, &mode, &nbarg)) )
{
if (-1 == (idx=cherche_mot_clef(argv[1], commandes, &mode, &nbarg)) ) {
fprintf(stderr, "action '%s' inconnue.\n", argv[1]);
exit(1);
}
@@ -452,7 +450,7 @@ switch(mode)
}
if (foo) {
fprintf(stderr, "*** at end of %s, foo was %d\n", __func__, foo);
/* fprintf(stderr, "*** at end of %s, foo was %d\n", __func__, foo); */
}
return 0;
}

View File

@@ -10,10 +10,13 @@ install -m 0644 tthimage.h $DESTDIR/include/tthimage.h
cp -v Datas/8x8thin Datas/16x24thin $DESTDIR/share/libimage/
cp -v Datas/8x8std Datas/16x24gruik $DESTDIR/share/libimage/
cp -v Datas/*.map $DESTDIR/share/libimage/
liste="genplot2 tga_cadre tga_effects tga_filtres tga_remap tga_tools \
tga_combine tga_television tga_dither tga_applymap tga_makehf15 \
tga_mires tga_incrust tga_pattern tga_equalize tga_alpha"
liste="genplot2 tga_cadre tga_effects tga_filtres tga_remap tga_tools \
tga_combine tga_television tga_dither tga_applymap tga_makehf15 \
tga_mires tga_incrust tga_pattern tga_equalize tga_alpha \
tga_to_text tga_plotmap tga_resize tga_extract tga_2x2contrast \
tga_plothisto tga_export tga_fractales"
for binaire in $liste
do

View File

@@ -4,7 +4,7 @@
http://la.buvette.org/devel/libimage/
*/
#ifndef IMAGE_VERSION_STRING
#define IMAGE_VERSION_STRING "0.4.51 pl 62"
#define IMAGE_VERSION_STRING "0.4.51 pl 91"
/*::------------------------------------------------------------------::*/
/*
@@ -98,7 +98,7 @@ typedef struct {
} Image_Rect;
/*
* new 11 Jan 2003: a struc like an Image_Rect, but with
* new 11 Jan 2003: a struct like an Image_Rect, but with
* double precision floating point coords.
*/
typedef struct {
@@ -121,7 +121,7 @@ typedef struct {
* memory descriptor for bits-planes
* 27 Dec 2001: c,a devient quoi, cette histoire de bitmaps ?
* 17 mars 2010: du code commence a venir...
*
* 12 février 2024, on a toujours rien vu.
*/
typedef struct {
unsigned int magic;
@@ -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_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_compare_desc(Image_Desc *a, Image_Desc *b);
/*::------------------------------------------------------------------::*/
/* module functions.c */
double tthi_dtime(void);
/*::------------------------------------------------------------------::*/
/* module pixels.c */
@@ -609,19 +614,15 @@ int Image_quelques_calculs(Image_Desc *image);
int Image_histo_RGB(Image_Desc *im, long *hr, long *hg, long *hb);
/* XXX may be we need a struct for RGB luts ? */
typedef struct {
unsigned int magic;
uint8_t R[256];
uint8_t G[256];
uint8_t B[256];
int flags;
} Image_LUTs;
int Image_LUT_RGB(Image_Desc *, Image_Desc *, int *, int *, int *);
int Image_LUT_mono(Image_Desc *src, Image_Desc *dst, int *lut);
/* falsecolors.c */
int Image_gen_fc_lut(float maxval, int nbslots, RGB_map *plut);
/*::------------------------------------------------------------------::*/
/* module distances.c */
@@ -1209,7 +1210,8 @@ int Image_insert_with_alpha(Image_Desc *img, Image_Desc *ins, int foo);
int Image_pix_square(Image_Desc *source, Image_Desc *but, int k);
int Image_pix_sqroot(Image_Desc *source, Image_Desc *but, int k);
int Image_egalise_cos01(Image_Desc *source, Image_Desc *but, int k);
int Image_egalise_cos01 (Image_Desc *source, Image_Desc *but, int k);
int Image_egalise_cos010 (Image_Desc *source, Image_Desc *but, int k);
/*::------------------------------------------------------------------::*/
/*
@@ -1310,7 +1312,7 @@ int Image_vectfont_text_0(Image_Desc *im, char *txt, int x, int y);
int Image_warp_essai_0(Image_Desc *src, Image_Desc *dst, double angle,
int xc, int yc);
int Image_warp_essai_1(Image_Desc *src, Image_Desc *dst, double angle);
int Image_warp_essai_1(Image_Desc *src, Image_Desc *dst, double ang, double off);
/*::------------------------------------------------------------------::*/
int Image_center_rotate(Image_Desc *src, Image_Desc *dst, double angle);
@@ -1323,7 +1325,6 @@ int Image_shift_y(Image_Desc *src, Image_Desc *dst, int oy);
int Image_center_rotate_xy(Image_Desc *src, Image_Desc *dst, double angle,
double x, double y);
/*::------------------------------------------------------------------::*/
/*::------------------------------------------------------------------::*/
/* anamorphose.c */