1 #include "../include/bitmapvalidator.h"
\r
2 #include "../include/freenet/captcha/easybmp/EasyBMP.h"
\r
4 #include <Poco/TemporaryFile.h>
\r
9 BitmapValidator::BitmapValidator():m_maxwidth(-1),m_maxheight(-1)
\r
14 BitmapValidator::~BitmapValidator()
\r
19 const bool BitmapValidator::Validate(const std::vector<unsigned char> &data)
\r
21 bool validated=false;
\r
22 std::string tempname=Poco::TemporaryFile::tempName();
\r
29 FILE *outfile=fopen(tempname.c_str(),"w+b");
\r
32 fwrite(&data[0],1,data.size(),outfile);
\r
36 if(temp.ReadFromFile(tempname.c_str()))
\r
39 if(m_maxwidth!=-1 && temp.TellWidth()>m_maxwidth)
\r
43 if(m_maxheight!=-1 && temp.TellHeight()>m_maxheight)
\r
49 unlink(tempname.c_str());
\r