/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

  1. #include <gd.h>
  2. #include "gdfontl.h"
  3. #include "gdfontg.h"
  4. #include <string.h>
  5. int main(int argc, char **argv) {
  6. gdImagePtr im;
  7. int black;
  8. int white;
  9. char *s;
  10. if (argc > 1) {
  11. s = argv[1];
  12. } else {
  13. return 1;
  14. };
  15. im = gdImageCreate(100, 50);
  16. white = gdImageColorAllocate(im, 255, 255, 255);
  17. black = gdImageColorAllocate(im, 0, 0, 0);
  18. gdImageString(im, gdFontGiant,
  19. im->sx / 2 - (strlen(s) * gdFontGetGiant()->w / 2),
  20. im->sy / 2 - gdFontGetGiant()->h / 2,
  21. s, black);
  22. gdImagePng(im, stdout);
  23. gdImageDestroy(im);
  24. return 0;
  25. }