From 2b26645b49e5c286715509ad857ae077463a2b59 Mon Sep 17 00:00:00 2001 From: tth Date: Thu, 13 Feb 2020 20:44:22 +0100 Subject: [PATCH] big commit for 2 new funcs --- doc/the_floatimg_hack.tex | 33 ++++++++++++++++++----- floatimg.h | 7 ++++- funcs/Makefile | 5 +++- funcs/geometry.c | 56 +++++++++++++++++++++++++++++++++++++++ funcs/sfx0.c | 2 +- funcs/t.c | 33 +++++++++++++++++++++-- lib/fimg-core.c | 21 ++++++++++++--- 7 files changed, 142 insertions(+), 15 deletions(-) create mode 100644 funcs/geometry.c diff --git a/doc/the_floatimg_hack.tex b/doc/the_floatimg_hack.tex index 2f58a5ca..df6181e8 100644 --- a/doc/the_floatimg_hack.tex +++ b/doc/the_floatimg_hack.tex @@ -12,7 +12,7 @@ \usepackage{pifont} % caractères rigolos \usepackage{enumitem} -\setitemize[1]{label={\ding{82}}} +\setitemize[1]{label={\ding{87}}} \frenchbsetup{CompactItemize=false} % \usepackage{color} @@ -72,6 +72,16 @@ IRC de Freenode. % XXX \pagebreak % ------------------------------------------------------------------- +\section{Théorie}\index{théorie} + +XXX\index{XXX} + +Pour le moment, seule la quête de l'empirisme absolu a été +visée. Les justifications mathématiques attendent le retour +du schmod777. + +% ------------------------------------------------------------------- + \section{Premier exemple}\index{exemple}\label{exemple} \textsc{FloatImg} a débuté sous la forme de quelques fonctions @@ -403,6 +413,22 @@ de pixel flottant. % ---------------------------------- +\subsection{Géométrie}\index{géométrie}\label{geometrie} + +Très prochainement, le retour du blitter\index{blitter}. + +\begin{verbatim} +/* module funcs/geometry.c */ +int fimg_halfsize_0(FloatImg *src, FloatImg *dst, int notused); +\end{verbatim} + +Attention lors de l'appel, le descripteur \texttt{dst} ne doit pas +contenir d'image, et doit être effacé avec un bon +\texttt{memset(\&result, 0, sizeof(FloatImg));} bien senti. +Et le résultat est très moyen : il n'y a pas d'interpolation. + +% ---------------------------------- + \subsection{Exportation}\index{export}\label{export} Notre format de fichier étant totalement inconnu, il nous @@ -793,11 +819,6 @@ aléatoire, surtout avec une caméra qui bouge. \textbf{Là, il manque un schéma\dots} -\subsubsection{shoot.sh}\index{shoot.sh}\label{shoot.sh} - -\hspace{4cm}XXX\index{XXX} - - \subsection{video-infos}\index{video-infos}\label{video-infos} Que contient, que peut faire mon périphérique \textsl{àlc} ? diff --git a/floatimg.h b/floatimg.h index 3889d096..d9a05b7d 100644 --- a/floatimg.h +++ b/floatimg.h @@ -2,7 +2,7 @@ * floatimg.h */ -#define FIMG_VERSION 89 +#define FIMG_VERSION 90 /* * in memory descriptor @@ -31,6 +31,7 @@ typedef struct { #define FIMG_TYPE_GRAY 1 #define FIMG_TYPE_RGB 3 #define FIMG_TYPE_RGBA 4 +#define FIMG_TYPE_RGBZ 99 #define FILE_TYPE_FIMG 1 #define FILE_TYPE_PNM 2 @@ -58,6 +59,7 @@ void fimg_printhead(FloatImg *h); int fimg_describe(FloatImg *head, char *txt); char *fimg_str_type(int type); int fimg_plot_rgb (FloatImg *head, int x, int y, float r, float g, float b); +int fimg_get_rgb(FloatImg *head, int x, int y, float *rgb); int fimg_clear(FloatImg *fimg); int fimg_add_rgb(FloatImg *head, int x, int y, float r, float g, float b); int fimg_rgb_constant(FloatImg *head, float r, float g, float b); @@ -98,6 +100,9 @@ int fimg_cos_010(FloatImg *s, FloatImg *d, double maxval); int fimg_mk_gray_from(FloatImg *src, FloatImg*dst, int k); int fimg_desaturate(FloatImg *src, FloatImg *dst, int k); +/* module funcs/geometry.c */ +int fimg_halfsize_0(FloatImg *src, FloatImg *dst, int notused); + /* module funcs/rampes.c */ int fimg_hdeg_a(FloatImg *img, double dcoef); int fimg_vdeg_a(FloatImg *img, double dcoef); diff --git a/funcs/Makefile b/funcs/Makefile index 10ab5916..d4d538c7 100644 --- a/funcs/Makefile +++ b/funcs/Makefile @@ -3,7 +3,7 @@ COPT = -Wall -fpic -g -no-pie -DDEBUG_LEVEL=0 DEPS = ../floatimg.h Makefile OBJS = fimg-png.o fimg-tiff.o misc-plots.o filtrage.o utils.o \ - fimg-libpnm.o rampes.o sfx0.o + fimg-libpnm.o rampes.o sfx0.o geometry.o #--------------------------------------------------------------- @@ -30,6 +30,9 @@ misc-plots.o: misc-plots.c $(DEPS) filtrage.o: filtrage.c $(DEPS) gcc $(COPT) -c $< +geometry.o: geometry.c $(DEPS) + gcc $(COPT) -c $< + sfx0.o: sfx0.c $(DEPS) gcc $(COPT) -c $< diff --git a/funcs/geometry.c b/funcs/geometry.c new file mode 100644 index 00000000..26065d3e --- /dev/null +++ b/funcs/geometry.c @@ -0,0 +1,56 @@ +/* + * FLOATIMG + * distorsions géométriques - coredumping ? + */ + +#include + +#include "../floatimg.h" + +/* --------------------------------------------------------------------- */ +/* + * really crude function, need more work... + */ +int fimg_halfsize_0(FloatImg *src, FloatImg *dst, int notused) +{ +int wd, hd; +int foo, x, y; +float pixel[3]; + +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( %p %p %d )\n", __func__, + src, dst, notused); +#endif + + /* no magic check here ? */ +if (dst->width || dst->height) { + fprintf(stderr, "*** %s: image at %p not empty\n", __func__, dst); + fimg_describe(dst, "destination halfsize"); + return -2; + } + +wd = src->width / 2; hd = src->height / 2; +foo = fimg_create(dst, wd, hd, FIMG_TYPE_RGB); +if (foo) { + fprintf(stderr, "%s: err create %d\n", __func__, foo); + return -3; + } + +for (y=0; y diff --git a/funcs/t.c b/funcs/t.c index 54e6cffb..615ad453 100644 --- a/funcs/t.c +++ b/funcs/t.c @@ -10,8 +10,37 @@ int verbosity; -int fimg_killcolors_a(FloatImg *fimg, float fval); +/* --------------------------------------------------------------------- */ +int essai_geometrie(char *infile) +{ +FloatImg fimg, result; +int foo; +if (NULL != infile) { + fprintf(stderr, "loading %s\n", infile); + fimg_create_from_dump(infile, &fimg); + } +else { + fimg_create(&fimg, 512, 512, FIMG_TYPE_RGB); + fimg_draw_something(&fimg); + } + +foo = fimg_save_as_pnm(&fimg, "source.pnm", 0); + +memset(&result, 0, sizeof(FloatImg)); + +foo = fimg_halfsize_0(&fimg, &result, 0); +fprintf(stderr, "retour halfsize -> %d\n", foo); +if (foo) { + return -2; + } + +fimg_describe(&result, "result after halfsize"); + +foo = fimg_save_as_pnm(&result, "something.pnm", 0); + +return 0; +} /* --------------------------------------------------------------------- */ int essai_sfx0(char *infile) { @@ -134,7 +163,7 @@ int foo; puts("++++++++++++++++++++++++++++++++"); -foo = essai_sfx0("03384.fimg"); +foo = essai_geometrie("foo.fimg"); return 0; } diff --git a/lib/fimg-core.c b/lib/fimg-core.c index 121b67cb..909e7bbe 100644 --- a/lib/fimg-core.c +++ b/lib/fimg-core.c @@ -294,10 +294,23 @@ return 0; } /* --------------------------------------------------------------------- */ +/* nouveau 12 fevrier 2020 */ +int fimg_get_rgb(FloatImg *head, int x, int y, float *prgb) +{ +int offset; +if (head->type != FIMG_TYPE_RGB) { +#if DEBUG_LEVEL > 1 + fprintf(stderr, "%s : type %d is bad.\n", __func__, head->type); +#endif + return -1; + } +offset = x + (y * head->width); +prgb[0] = head->R[offset]; +prgb[1] = head->G[offset]; +prgb[2] = head->B[offset]; + +return 0; +} /* --------------------------------------------------------------------- */ - - - -