X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=src%2Fbitmapvalidator.cpp;h=12ba6de23475da02dfbf06740c3200818d53ad39;hb=c0ebc7b53a977885ebc2d3a679c586ae20c0bc4a;hp=771b707eca577677011710deeb137206f86541bc;hpb=dec33c63afafabf83c3039e916725cac6faef9b3;p=fms.git diff --git a/src/bitmapvalidator.cpp b/src/bitmapvalidator.cpp index 771b707..12ba6de 100644 --- a/src/bitmapvalidator.cpp +++ b/src/bitmapvalidator.cpp @@ -6,11 +6,26 @@ #include #include +BitmapValidator::BitmapValidator():m_maxwidth(-1),m_maxheight(-1) +{ + +} + +BitmapValidator::~BitmapValidator() +{ + +} + const bool BitmapValidator::Validate(const std::vector &data) { bool validated=false; std::string tempname=Poco::TemporaryFile::tempName(); + if(data.size()==0) + { + return false; + } + FILE *outfile=fopen(tempname.c_str(),"w+b"); if(outfile) { @@ -20,7 +35,15 @@ const bool BitmapValidator::Validate(const std::vector &data) BMP temp; if(temp.ReadFromFile(tempname.c_str())) { - validated=true; + validated=true; + if(m_maxwidth!=-1 && temp.TellWidth()>m_maxwidth) + { + validated=false; + } + if(m_maxheight!=-1 && temp.TellHeight()>m_maxheight) + { + validated=false; + } } unlink(tempname.c_str());