Compare commits

...

5 Commits

Author SHA1 Message Date
tTh 73a611e55f + voirenv 2022-09-12 01:39:21 +02:00
tTh f79ae3ef80 more bla 2022-09-12 01:36:48 +02:00
tTh 1fabb2c89f cosmetic + G2 2022-09-12 01:21:21 +02:00
tTh f2acdcef9b go tth, go ! 2022-09-12 01:20:28 +02:00
tTh 9e882d49cb add some ugly code 2022-09-12 01:18:07 +02:00
8 changed files with 243 additions and 10 deletions

View File

@ -460,15 +460,17 @@ et un exemple simple d'utilisation.
\section{Erreurs classiques}
Variables non initialisées.
\begin{itemize}
\item{Variables non initialisées.}
Sortir d'un tableau.
\item{Sortir d'un tableau (par le haut ou par le bas).}
Dépassement de la taille d'une chaine.
\item{Dépassement de la taille d'une chaine.}
Libérer deux fois la mémoire.
\item{Libérer deux fois la mémoire.}
\textsl{file pointer} invalide.
\item{\textsl{file pointer} invalide.}
\end{itemize}
% =========================================================
@ -480,7 +482,7 @@ XXX \index{XXX}
\section{Debug} \index{Debug}
Des outils et astuces en page \pageref{chap:Debug}.
Des outils et astuces en page \pageref{chap:debug}.
\begin{quote}
splint is an annotation-assisted lightweight static checker.
@ -520,6 +522,9 @@ functions for simultaneous generation of graphical output on different
types of devices.
\end{quote}
\lstinputlisting[language=c]{code/g2/un_dessin.c}
% =========================================================
\section{Ailleurs dans cet ouvrage}

View File

@ -62,6 +62,8 @@ x:y & Here x and y denotes an aspect ratio (e.g. 3:2 = 1.5). \\
\hline
\end{tabular}
% !!!
% est-il nécessaire de traduire ce tableau ?
\subsection{Écrire du texte}
@ -72,13 +74,23 @@ qui montre l'essentiel pour bien débuter. C'est une fonction
\lstinputlisting[language=sh]{code/tagpic.sh}
Une petite commande toute bête pour rajouter la date facilement à une photo
daprès les données EXIF\index{EXIF}~:
\begin{lstlisting}
convert nom_du_fichier_source.jpg -gravity SouthEast \
-font Fudd-Regular -pointsize 40 -fill white \
-annotate +20+20 "%[exif:DateTimeOriginal]" \
-quality 100 nom_du_fichier_destination.jpg
\end{lstlisting}
Quelques explications semblent nécessaires, parce que certaines
options sont un peu ésotériques et parfois inter-dépendantes\dots
\begin{itemize}
\item{txtfont}
\item{fontsize}
\item{kerning}
\item{kerning: espacement entre les caractères}
\item{colors}
\item{txtopts}
\item{gravity}
@ -89,13 +101,21 @@ Question : comment mettre une couleur de fond à ce texte ?
\subsection{montage}
Krkrkr
\begin{quote}
create a composite image by combining several separate images. The images are
tiled on the composite image optionally adorned with a border, frame,
image name, and more.
\end{quote}
Krkrkr\dots
\subsection{Faire des GIFs animées}\index{GIF}
Ces petites images clignotantes sont l'essence même du
Web\index{web} moderne depuis 1992 malgré leurs limitations,
et \texttt{convert} sait très bien les générer.
Encore un grand merci à Compuserve\index{Compuserve} pour cette
création essentielle à l'art graphique moderne.
\begin{verbatim}
convert -delay 20 -loop 0 a.png b.png c.png foo.gif
@ -124,9 +144,40 @@ changer la dimension de l'image. En détail, j'ai pas tout compris.
% ------------------------------------------
\subsection{conversion vers TGA} \index{TGA}
On trouve encore en circulation de très vieux logiciels qui ne savent lire
qu'un encore plus ancien format : \textsl{Targa file format}.
Et dans une variante bien précise.
Il nous faut donc une incantation bien précise :
\begin{lstlisting}
GOTO_TGA ()
{
convert $1 \
-compress none \
-alpha off \
-colorspace RGB \
-type truecolor \
$2
}
\end{lstlisting}
On peut aussi procéder autrement, avec les outils PNM\index{PNM} :
\begin{verbatim}
pngtopnm \$negatif | ppmtotga -rgb -norle > \$picz
\end{verbatim}
% ------------------------------------------
\subsection{Trucs}
convert -average frame*.png output.png
\begin{itemize}
\item{convert -average frame*.png output.png}
\end{itemize}
% ------------------------------------------
@ -146,7 +197,8 @@ l'IRC\index{IRC} \texttt{freenode\#paulla} \textit{:)}
\textsl{Perform generic image processing operations, through the G'MIC
language interpreter. gmic: GREYC's Magic for Image Computing.}
Gmic se base sur une grosse bibliothèque de fonctions écrite
Gmic se base sur une grosse\footnote{énorme, même. dans les deux sens\dots}
bibliothèque de fonctions écrite
en \texttt{C++}\index{C++} dont l'utilisation est bien
docummentée dans le livre ???\index{XXX}
@ -222,6 +274,8 @@ use it heavily.
et basé Gmic. C'est long à compiler, ça produit des binaires
énormes, mais il semble bien que ça puisse faire des trucs géniaux.
\subsection{\textsc{hello world}}
\begin{lstlisting}
#define cimg_use_png
#include "CImg.h"
@ -243,4 +297,11 @@ return 0;
}
\end{lstlisting}
\subsection{Questions...}
\begin{itemize}
\item{Comment virer le canal alpha à l'enregistrement d'une image en PNG ?}
\end{itemize}
% -------------------------------------------------------------------

21
code/.gitignore vendored Normal file
View File

@ -0,0 +1,21 @@
a.out
appelant
arguments
ex_curses
fifo-rx
fifo-tx
flydraw.gif
flydraw.png
foo
get-signal
hello
listen-osc
no-op
*.o
plugiciel.so
send-osc
thread-demo
voirenv
xform/yesyno

View File

@ -19,6 +19,9 @@ arguments: arguments.c Makefile
no-op: no-op.c Makefile
gcc -Wall $< -o $@
voirenv: voirenv.c Makefile
gcc -Wall $< -o $@
#------------- OSC -----------------------
osc: send-osc listen-osc

3
code/g2/Makefile Normal file
View File

@ -0,0 +1,3 @@
un_dessin: un_dessin.c
gcc -Wall $< -o $@

15
code/g2/un_dessin.c Normal file
View File

@ -0,0 +1,15 @@
/*
* DESSINER AVEC G2
*/
#include <stdio.h>
int main(int argc, char *argv[])
{
fprintf(stderr, "file %s compiled %s at %s\n", \
__FILE__, __DATE__, __TIME__);
return 0;
}

100
code/hardware/if_eth.c Normal file
View File

@ -0,0 +1,100 @@
/*
* code extrait des bas-fonds de l'internet obscur !
*
* DON'T TRUST IT !
*
*/
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <net/if.h>
/* ------------------------------------------------------------- */
int get_if_flags(char *ifname, short *p_flags)
{
int fd;
int retcode;
struct ifreq req;
#if DEBUG_LEVEL
fprintf(stderr, ">>> %s \"%s\" to %p\n", __func__, ifname, p_flags);
#endif
/* Sanity check */
if ( strlen(ifname) > (IFNAMSIZ-1) )
{
fprintf(stderr, "name %s to long\n", ifname);
abort();
}
fd = socket(PF_INET, SOCK_DGRAM, 0);
if (fd < 0)
{
perror("socket bla...");
return -2;
}
#if DEBUG_LEVEL
fprintf(stderr, "fd socket bla... = %d\n", fd);
#endif
/* populate the struct for the request */
memset(&req, 0, sizeof(req));
strcpy(req.ifr_name, ifname);
/* do the call */
retcode = ioctl(fd, SIOCGIFFLAGS, &req);
if (retcode < 0)
{
perror("ioctl SIOCGIFFLAGS");
close(fd);
return -1;
}
#if DEBUG_LEVEL
fprintf(stderr, "ioctl -> %d\n", retcode);
#endif
#if DEBUG_LEVEL
/* display the result */
fprintf(stderr, "flags = 0x%04x\n", req.ifr_flags);
#endif
close(fd);
*p_flags = req.ifr_flags;
return 0;
}
/* ------------------------------------------------------------- */
int get_if_up_or_down(char *ifname)
{
int foo;
short flags;
foo = get_if_flags(ifname, &flags);
#if DEBUG_LEVEL
fprintf(stderr, "get flags -> %d\n", foo);
#endif
if (foo < 0) /* got an error ? */
return -1;
return (flags & IFF_UP) ? 1 : 0;
}
/* ------------------------------------------------------------- */
int get_if_running(char *ifname)
{
int foo;
short flags;
foo = get_if_flags(ifname, &flags);
#if DEBUG_LEVEL
fprintf(stderr, "get flags -> %d\n", foo);
#endif
if (foo < 0) /* got an error ? */
return -1;
return (flags & IFF_RUNNING) ? 1 : 0;
}
/* ------------------------------------------------------------- */

25
code/voirenv.c Normal file
View File

@ -0,0 +1,25 @@
/*
* Low level acces to the environment space
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[], char *envp[])
{
char *ptr, *clone, *tok;
int foo = 0;
while ( NULL != (ptr=envp[foo]) ) {
printf("%4d %s\n", foo, ptr);
clone = strdup(ptr);
tok = strtok(clone, "=");
printf(" key : %s\n", tok);
tok = strtok(NULL, "=");
printf(" value : %s\n", tok);
free(clone);
foo++;
}
return 0;
}