Compare commits

..

No commits in common. "2e0809b69184cee98a50c5af2b0d5620203a36c1" and "162e04e6fcaeff78f3dadefffefbbc6aa9f70d89" have entirely different histories.

9 changed files with 74 additions and 140 deletions

3
Lib/.gitignore vendored
View File

@ -1,3 +0,0 @@
*.png

View File

@ -135,7 +135,8 @@ return foo;
* 3 octobre 2009 : il faudra la renommer pour etre XXX
* en accord avec 'tga_cadre' qui la nomme "sweep". XXX
*/
int Image_cadre_C(Image_Desc *im, int r, int g, int b, int n)
int
Image_cadre_C(Image_Desc *im, int r, int g, int b, int n)
{
int x, y, x2, y2, ir, ig, ib;
float fx, fy;
@ -149,7 +150,8 @@ fn = (float)(n*n);
x2 = im->width / 2;
y2 = im->height / 2;
for (y=0; y<im->height; y++) {
for (y=0; y<im->height; y++)
{
/*
* distance au bord HAUT BAS le plus proche
*/
@ -157,7 +159,8 @@ for (y=0; y<im->height; y++) {
else fy = (float)((im->height - y)-1);
fy = fy*fy;
for (x=0; x<im->width; x++) {
for (x=0; x<im->width; x++)
{
/*
* distance au bord DROITE GAUCHE le plus proche
*/
@ -169,7 +172,8 @@ for (y=0; y<im->height; y++) {
if (fx < fy) d = fx;
else d = fy;
if (d < fn) {
if (d < fn)
{
coef = d / fn;
ir = (im->Rpix[y])[x];
ig = (im->Gpix[y])[x];
@ -466,49 +470,5 @@ for (y=0; y<im->height; y++)
return OLL_KORRECT;
}
/*::------------------------------------------------------------------::*/
/* nouveau : Mon 12 Sep 2022 10:47:18 PM CEST
*/
int Image_cadre_std2(Image_Desc *im, int r, int g, int b, int nh, int nv)
{
int x, y;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p %d %d %d %d %d )\n", __func__,
im, r, g, b, nh, nv);
#endif
for (y=0; y<im->height; y++)
{
for (x=0; x<nv; x++)
{
(im->Rpix[y])[x] = r;
(im->Gpix[y])[x] = g;
(im->Bpix[y])[x] = b;
}
for (x=0; x<nv; x++)
{
Image_plotRGB(im, x+im->width - nv, y, r, g, b);
}
}
for (x=0; x<im->width; x++)
{
for (y=0; y<nh; y++)
{
(im->Rpix[y])[x] = r;
(im->Gpix[y])[x] = g;
(im->Bpix[y])[x] = b;
}
for (y=0; y<nh; y++)
{
(im->Rpix[y+im->height-nh])[x] = r;
(im->Gpix[y+im->height-nh])[x] = g;
(im->Bpix[y+im->height-nh])[x] = b;
}
}
return FUNC_IS_BETA;
}
/*::------------------------------------------------------------------::*/
/* et maintenant ? on peut aller voir 'cadres2.c' ? */
/*::------------------------------------------------------------------::*/

View File

@ -19,7 +19,7 @@ Image_print_version(int flag)
char *ptr;
fflush(stdout);
printf("-+- This is the `tthimage' library v%s (wtfyw 2022) tTh\n",
printf("-+- This is the `tthimage' library v%s (dwtfywl 2022) tTh\n",
IMAGE_VERSION_STRING);
if (flag)
{
@ -594,25 +594,29 @@ fprintf(stderr, " %p %p %p %p\n", im->Rpix, im->Gpix, im->Bpix, im->Apix);
im->magic = 0L; /* mark dirty/invalid. */
im->type = IMAGE_NONE; /* -1, et tusors */
if (im->Rpix != NULL) {
if (im->Rpix != NULL)
{
for (line=0; line<im->height; line++)
if (im->Rpix[line] != NULL) free(im->Rpix[line]);
free(im->Rpix); im->Rpix = NULL;
}
if (im->Gpix != NULL) {
if (im->Gpix != NULL)
{
for (line=0; line<im->height; line++)
if (im->Gpix[line] != NULL) free(im->Gpix[line]);
free(im->Gpix); im->Gpix = NULL;
}
if (im->Bpix != NULL) {
if (im->Bpix != NULL)
{
for (line=0; line<im->height; line++)
if (im->Bpix[line] != NULL) free(im->Bpix[line]);
free(im->Bpix); im->Bpix = NULL;
}
if (im->Apix != NULL) {
if (im->Apix != NULL)
{
for (line=0; line<im->height; line++)
if (im->Apix[line] != NULL) free(im->Apix[line]);
free(im->Apix); im->Apix = NULL;

View File

@ -11,7 +11,8 @@
#include "../tthimage.h"
/*::------------------------------------------------------------------::*/
int Image_pixeliz_0(Image_Desc *src, Image_Desc *dst, int w, int h)
int
Image_pixeliz_0(Image_Desc *src, Image_Desc *dst, int w, int h)
{
int x, y, foo, N;
int r, g, b;

View File

@ -1,12 +1,10 @@
/*
------ libtthimage ------
PNG aka "portable network graphics"s.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <png.h>
@ -18,69 +16,46 @@
#include "../tthimage.h"
/*
* http://www.libpng.org/pub/png/pngbook.html
* les infos et le code ici viennent de
* http://www.libpng.org/pub/png/pngbook.html
*/
/* static mainprog_info wpng_info; */
/*::------------------------------------------------------------------::*/
void write_png_version_info(void)
static void writepng_version_info(void)
{
fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n",
PNG_LIBPNG_VER_STRING, png_libpng_ver);
fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n",
ZLIB_VERSION, zlib_version);
fprintf(stderr, " Compiled with libpng %s; using libpng %s.\n",
PNG_LIBPNG_VER_STRING, png_libpng_ver);
fprintf(stderr, " Compiled with zlib %s; using zlib %s.\n",
ZLIB_VERSION, zlib_version);
}
/*::------------------------------------------------------------------::*/
Image_Desc * Image_PNG_alloc_load(char *fname, int k)
{
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( '%s' %d )\n", __func__, fname, k);
write_png_version_info();
fprintf(stderr, "%s ( '%s' %d )\n", __func__, fname, k);
writepng_version_info();
#endif
return NULL;
}
/*::------------------------------------------------------------------::*/
/*
* http://zarb.org/~gc/html/libpng.html
* https://gist.github.com/niw/5963798
*/
int Image_save_as_PNG(Image_Desc *img, char *fname, int p1, int p2)
{
FILE *fp;
int x, y, foo;
png_structp png;
png_infop info;
FILE *fp;
int x, y, foo;
png_uint_32 pngv;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s ( %p '%s' %d %d )\n", __func__, img, fname, p1, p2);
write_png_version_info();
fprintf(stderr, "%s ( %p '%s' %d %d )\n", __func__, img, fname, p1, p2);
writepng_version_info();
#endif
fp = fopen(fname, "wb");
if (NULL == fp) {
perror(fname);
return BASIC_IO_WR_ERR;
}
png = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
info = png_create_info_struct(png);
if (setjmp(png_jmpbuf(png))) abort();
png_init_io(png, fp);
png_set_IHDR( png,
info,
img->width, img->height,
8,
PNG_COLOR_TYPE_RGBA,
PNG_INTERLACE_NONE,
PNG_COMPRESSION_TYPE_DEFAULT,
PNG_FILTER_TYPE_DEFAULT );
png_write_info(png, info);
return FULL_NUCKED;
}
/*::------------------------------------------------------------------::*/

View File

@ -5,11 +5,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <png.h>
#include "../tthimage.h"
void write_png_version_info(void);
/*::------------------------------------------------------------------::*/
/*::------------------------------------------------------------------::*/
@ -18,10 +15,12 @@ int main(int argc, char *argv[])
{
Image_Desc *img;
int foo;
char *fname = "proto.png";
char *fname = "foo.png";
Image_print_version(0);
writepng_version_info();
if (2==argc) {
fname = argv[1];
}

View File

@ -7,8 +7,8 @@ Tester, c'est douter.
Pas grand chose.
Allez quand même voir `config.sh` et `functions.sh` pour avoir une idée
du désastre actuel. Il reste beaucoup de choses à faire.
du désastre actuel
## 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 prometeur.

View File

@ -11,8 +11,8 @@
#define XMIN 0
#define YMIN 0
#define XMAX 640 /* constant from a 'dddd' */
#define YMAX 480 /* constant from a 'dddd' */
#define XMAX 4096 /* constant from a 'dddd' */
#define YMAX 4096 /* constant from a 'dddd' */
/*::------------------------------------------------------------------::*/
static Image_Desc *image;
@ -23,22 +23,20 @@ int initgr(int largeur, int hauteur)
{
int foo, r, v, b, dummy;
if (NULL==(image=Image_alloc(largeur, hauteur, 3))) {
if ((image=Image_alloc(largeur, hauteur, 3))==NULL)
{
fprintf(stderr, "hu hu, 'man addswap' :)\n");
exit(3);
}
printf("Genplot2: initgr %d %d\n", largeur, hauteur);
for (foo=0; foo<8; foo++) {
#if DEBUG_LEVEL
printf("\n\tinitgr %d %d\n", largeur, hauteur);
for (foo=0; foo<8; foo++)
{
printf("\tPal(%d) = ", foo);
#endif
r = foo & 1 ? 255 : 0;
v = foo & 2 ? 255 : 0;
b = foo & 4 ? 255 : 0;
#if DEBUG_LEVEL
printf("%02X %02X %02X\n", r, v, b);
#endif
map.red[foo] = r;
map.green[foo] = v;
map.blue[foo] = b;
@ -51,7 +49,7 @@ return 0;
int move(int x, int y)
{
#if DEBUG_LEVEL
fprintf(stderr, "\tMOVE %5d %5d\n", x, y);
printf("\tMOVE %5d %5d\n", x, y);
#endif
curX = x; curY = y;
return 0;
@ -63,7 +61,7 @@ RGBA rgba;
int idx;
#if DEBUG_LEVEL
fprintf(stderr, "\tDRAW %5d %5d to %5d %5d\n", curX, curY, x, y);
printf("\tDRAW %5d %5d to %5d %5d\n", curX, curY, x, y);
#endif
idx = color % 8;
@ -82,7 +80,7 @@ return 0;
int endgr(char *filename)
{
fprintf(stderr, "genplot2 is saving to '%s'\n", filename);
fprintf(stderr, "saving '%s'\n", filename);
Image_TGA_save(filename, image, 0);
return 0;
@ -106,15 +104,17 @@ else filename = argv[1];
if (argc<=2) image = "image.tga";
else image = argv[2];
fprintf(stderr, "*** Genplot2 v 1.0.4 [%s] (dwtfywl) 1995,2010 TontonTh \n",
TGA_OUTILS_VERSION);
/*----------- giving to the yuser some useless informations --- */
#if DEBUG_LEVEL
fprintf(stderr, "*** Genplot2 v 1.0.8 (dwtfywl) 1995,2010,2022 TontonTh \n");
fprintf(stderr, "hardcoded picsize : %d %d\n", XMAX, YMAX);
#endif
/*----------- opening input file and getting MIN and MAX values */
if ((fp = fopen(filename, "r"))==NULL) {
if ((fp = fopen(filename, "r"))==NULL)
{
perror("fichier d'entree");
exit(1);
}
@ -122,13 +122,16 @@ if ((fp = fopen(filename, "r"))==NULL) {
nbp = 0;
xmin = 9999999; xmax = -9999999;
ymin = 9999999; ymax = -9999999;
while ( fscanf(fp, "%lf %lf %d", &x, &y, &v) == 3 ) {
while ( fscanf(fp, "%lf %lf %d", &x, &y, &v) == 3 )
{
nbp++;
if (x > xmax) xmax = x;
if (x < xmin) xmin = x;
if (y > ymax) ymax = y;
if (y < ymin) ymin = y;
}
fclose(fp);
@ -144,26 +147,23 @@ fprintf(stderr, "Genplot2: found %d points\n", nbp);
fx = (XMAX-XMIN-1)/(xmax-xmin);
fy = (YMAX-YMIN-1)/(ymax-ymin);
#if DEBUG_LEVEL
fprintf(stderr, "fc = %12f fy = %12f\n", fx, fy);
#endif
fprintf(stderr, "\nfc = %12f fy = %12f\n", fx, fy);
f = (fx<fy?fx:fy);
xC = 0.5*(xmin+xmax); yC = 0.5*(ymin+ymax);
XC = 0.5*(XMIN+XMAX); YC = 0.5*(YMIN+YMAX);
c1 = XC-f*xC; c2 = YC-f*yC;
#if DEBUG_LEVEL
fprintf(stderr, "c1 = %12f c2 = %12f\n", c1, c2);
#endif
/*------------- and now, plotting the image ! */
initgr(XMAX, YMAX);
fp = fopen(filename, "r");
puts("");
while ( fscanf(fp, "%lf %lf %d", &x, &y, &v) == 3 ) {
while ( fscanf(fp, "%lf %lf %d", &x, &y, &v) == 3 )
{
#if DEBUG_LEVEL
fprintf(stderr, "%12f %12f %d\n", x, y, v);
#endif

View File

@ -4,7 +4,7 @@
http:///la.buvette.org/devel/libimage/
*/
#ifndef IMAGE_VERSION_STRING
#define IMAGE_VERSION_STRING "0.4.51 pl 21"
#define IMAGE_VERSION_STRING "0.4.51 pl 18"
/*::------------------------------------------------------------------::*/
/*
@ -481,10 +481,10 @@ typedef struct
* que Gcc grinke feroce dessus...
*/
int Image_mosaic_0(Image_Desc *src, Image_Desc *dst, int sx, int sy, int flg);
int Image_mosaic_simple(Image_Desc *src, Image_Desc *dst);
int Image_mosaic_0(Image_Desc *src, Image_Desc *dst, int sx, int sy, int flg);
int Image_mosaic_simple(Image_Desc *src, Image_Desc *dst);
void Image_mosaic_prctrl(IMAGE_MOSAIC_CTRL *ctrl, char *txt);
int Image_mosaic_iterateur(IMAGE_MOSAIC_CTRL *ctrl, int yo);
int Image_mosaic_iterateur(IMAGE_MOSAIC_CTRL *ctrl, int yo);
/*::------------------------------------------------------------------::*/
/* module des vignettes (nex 15 mai 2007) */
@ -1113,12 +1113,10 @@ int Image_pix2ptl(Image_Desc *img, int seuil, Image_PtList *ptl);
int Image_cadre_A(Image_Desc *im);
int Image_cadre_B(Image_Desc *im, int larg);
int Image_cadre_cracra(Image_Desc *im, int larg, int k);
int Image_cadre_C(Image_Desc *, int r, int g, int b, int sz);
int Image_cadre_C(Image_Desc *, int, int, int, int);
int Image_cadre_bruit(Image_Desc *, int, int, int, int);
int Image_cadre_E(Image_Desc *, int, int, int, int);
int Image_cadre_std2(Image_Desc *im, int r, int g, int b, int nh, int nv);
int Image_cadre_pattern_0(Image_Desc *, Image_Desc *, int);
int Image_cadre_pattern_1(Image_Desc *im, Image_Desc *pat, int n);
int Image_cadre_pattern_2(Image_Desc *im, Image_Desc *pat, int n);