/c_code/captcha.c
http://github.com/ermine/erm_captcha · C · 27 lines · 25 code · 2 blank · 0 comment · 2 complexity · a261308c4297e7a097e0a98a82bf4020 MD5 · raw file
- #include <gd.h>
- #include "gdfontl.h"
- #include "gdfontg.h"
- #include <string.h>
- int main(int argc, char **argv) {
- gdImagePtr im;
- int black;
- int white;
- char *s;
- if (argc > 1) {
- s = argv[1];
- } else {
- return 1;
- };
- im = gdImageCreate(100, 50);
- white = gdImageColorAllocate(im, 255, 255, 255);
- black = gdImageColorAllocate(im, 0, 0, 0);
- gdImageString(im, gdFontGiant,
- im->sx / 2 - (strlen(s) * gdFontGetGiant()->w / 2),
- im->sy / 2 - gdFontGetGiant()->h / 2,
- s, black);
- gdImagePng(im, stdout);
- gdImageDestroy(im);
- return 0;
- }