Regardez l'exemple de code void gdImageStringUp(gdImagePtr im, gdFontPtr font, int x, int y, unsigned char *s, int color) (FUNCTION)
(vous pouvez très bien copier-coller) ..
#include "gd.h"
#include "gdfontl.h"
#include <string.h>
/*... inside a function ...*/
gdImagePtr im;
int black;
int white;
/* String to draw. */
char *s = "Hello.";
im = gdImageCreate(100, 100);
/* Background color (first allocated) */
black = gdImageColorAllocate(im, 0, 0, 0);
/* Allocate the color white (red, green and blue all maximum). */
white = gdImageColorAllocate(im, 255, 255, 255);
/* Draw a centered string going upwards. Axes are reversed,
and Y axis is decreasing as the string is drawn. */
gdImageStringUp(im, gdFontGetLarge(),
im->w/2 - gdFontGetLarge()->h/2,
im->h/2 + (strlen(s) * gdFontGetLarge()->w/2), s, white);
/* ... Do something with the image, such as
saving it to a file... */
/* Destroy it */
gdImageDestroy(im);
http://www.libgd.org/Font
Le bruit se fait avec des pixels/lignes/etc aléatoire, ce qui est trivial:
/*... inside a function ...*/
gdImagePtr im;
int black;
int white;
im = gdImageCreate(100, 100);
/* Background color (first allocated) */
black = gdImageColorAllocate(im, 0, 0, 0);
/* Allocate the color white (red, green and blue all maximum). */
white = gdImageColorAllocate(im, 255, 255, 255);
/* Set a pixel near the center. */
gdImageSetPixel(im, 50, 50, white);
/* ... Do something with the image, such as
saving it to a file... */
/* Destroy it */
gdImageDestroy(im);
http://www.libgd.org/Drawing
LibGD a comme des exemples de zillion sur leur site Web.
Très probablement, je vais utiliser captcha numérique, mais votre code est la peine d'essayer. :) Merci. – Nilesh