#include #include #include #include /* Dbyt3r ** Kick ARSE! */ int main(int argc, char *argv[]) { time_t now = time(NULL) * 1000; gdImagePtr captcha; FILE *fp; int train = 1; fp = fopen("C:\\Program Files\\xampp\\htdocs\\delicious.png","rb"); captcha = gdImageCreateFromPng(fp); fclose(fp); int width = gdImageSX(captcha); int height = gdImageSY(captcha); int x,y; for(x=0;x lowestY) { lowestY = y;} } } if((started==1) && (hasblack == 0)){ gdImagePtr newCaptcha = gdImageCreate(x-firstX,lowestY - highestY); gdImageCopy(newCaptcha,captcha,0,0,firstX,highestY,x-firstX,lowestY-highestY); arrNewCaptchas[count] = newCaptcha; if(train == 1){ printf("Character #%d:\n",count+1); letter=getchar(); sprintf(strcount,""); while(letter != '\n') { sprintf(strcount,"%s%c",strcount,letter); letter= getchar(); } sprintf(strcount,"C:\\delicious-captcha\\\%s.png",strcount); //sprintf(totalPath,"delicious-captcha/%s.png",strcount); fp = fopen(strcount,"wb"); gdImagePng(newCaptcha,fp); fclose(fp); } count++; started = 0; } } printf("%d letters extracted\n",count); fp = fopen("delicious.png","wb"); gdImagePng(captcha,fp); fclose(fp); gdImageDestroy(captcha); //now = now_ - now; system("PAUSE"); return 0; } int getPopularity(int x, int y,gdImagePtr captcha){ int popularity =0; if(gdImageGetPixel(captcha,x+1,y) != 0){ popularity++; } if(gdImageGetPixel(captcha,x-1,y) != 0){ popularity++; } if(gdImageGetPixel(captcha,x,y+1) != 0){ popularity++; } if(gdImageGetPixel(captcha,x,y-1) != 0){ popularity++; } if(gdImageGetPixel(captcha,x+1,y+1) != 0){ popularity++; } if(gdImageGetPixel(captcha,x+1,y-1) != 0){ popularity++; } if(gdImageGetPixel(captcha,x-1,y+1) != 0){ popularity++; } if(gdImageGetPixel(captcha,x-1,y-1) != 0){ popularity++; } return popularity; }