X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;ds=inline;f=src%2Ffreenet%2Fcaptcha%2Fsimplecaptcha.cpp;h=7539f80e15973aebb1ce4b9e6aeaebb5b0d48ff0;hb=44f964d9b2b2d55a5b5672e9297717bd25fa8ee2;hp=2d4a4ae6320995e81126b4acf194173587fed1a4;hpb=9048d8e482c91960265f29c2b5b3112f2a52f3d8;p=fms.git diff --git a/src/freenet/captcha/simplecaptcha.cpp b/src/freenet/captcha/simplecaptcha.cpp index 2d4a4ae..7539f80 100644 --- a/src/freenet/captcha/simplecaptcha.cpp +++ b/src/freenet/captcha/simplecaptcha.cpp @@ -3,6 +3,8 @@ #include "../../../include/freenet/captcha/easybmp/EasyBMP_Font.h" #include "../../../include/freenet/captcha/easybmp/EasyBMP_Geometry.h" +#include + #ifdef XMEM #include #endif @@ -10,8 +12,9 @@ void SimpleCaptcha::Generate() { BMP bmp; - int bmpwidth=100; + int bmpwidth=110; int bmpheight=50; + RGBApixel lettercols[5]; std::string puzzlestring; std::string tempfilename=GenerateRandomString(10); tempfilename+=".bmp"; @@ -23,7 +26,7 @@ void SimpleCaptcha::Generate() bmp.SetSize(bmpwidth,bmpheight); // first draw some random lines around the bitmap - int numlines=(rand()%20)+10; + int numlines=(rand()%10)+10; for(int i=0; iskew; xx--) + { + pixel=bmp.GetPixel(xx-skew,yy); + bmp.SetPixel(xx,yy,pixel); + } + } + for(xx=bmpwidth+skew; xx 255 ? tempred=255 : false; + tempgreen < 0 ? tempgreen=0 : false; + tempgreen > 255 ? tempgreen=255 : false; + tempblue < 0 ? tempblue=0 : false; + tempblue > 255 ? tempblue=255 : false; + + pixel.Red=tempred; + pixel.Green=tempgreen; + pixel.Blue=tempblue; + + bmp.SetPixel(xx,yy,pixel); + } } bmp.WriteToFile(tempfilename.c_str()); @@ -91,4 +180,4 @@ void SimpleCaptcha::ReadPuzzleData(const std::string &filename) fread(&m_puzzle[0],1,filelen,infile); fclose(infile); } -} \ No newline at end of file +}