#include "captcha.h" int captcha_print(char* text) { File* file = file_open("code.png"); gdImagePtr im = gdImageCreateFromPngPtr(file->size, file->data); gdImageColorTransparent(im, gdImageColorAllocate(im, 255, 255, 255)); char text_width = strlen(text); float letter_width = ((float) gdImageSX(im) / 26.00); int image_width = letter_width * (text_width - 2); int image_height = gdImageSY(im); gdImagePtr image = gdImageCreateTrueColor(image_width, image_height); gdImageColorTransparent(image, gdImageColorAllocate(image, 0, 0, 0)); srand(time(NULL) * (*text)); int i; for(i=0; i<=10; i++) { int x1 = ((double) rand() / RAND_MAX) * image_width; int y1 = ((double) rand() / RAND_MAX) * image_height; gdImageFilledArc(image, x1, y1, x1 + 10, y1 + 10, ((double) rand() / RAND_MAX) * 360, ((double) rand() / RAND_MAX) * 360, gdImageColorAllocate(image, 100 + (rand() * 155), 150 + (rand() * 105), 150 + (rand() * 105)), gdEdged); } int pos; for(pos=0; pos