Files
Work/nntp/THMBNAIL.CPP
2024-08-07 09:16:27 -04:00

47 lines
1.5 KiB
C++

#include <nntp/thmbnail.hpp>
bool ThumbNail::setImage(PakEntry &pakEntry,PureDevice &pureDevice)
{
mImage.setRawData(pakEntry.rawData(),pureDevice);
if(!mImage.isOkay())return false;
mStrPathFileName=pakEntry.name();
return true;
}
bool ThumbNail::setImage(PakEntry &pakEntry)
{
mImage.setRawData(pakEntry.rawData());
mStrPathFileName=pakEntry.name();
return true;
}
bool ThumbNail::setImage(const String &strPathFileName,PureDevice &pureDevice)
{
mImage.decode(strPathFileName,pureDevice);
if(!mImage.isOkay())return false;
mStrPathFileName=strPathFileName;
mImage.resample(pureDevice,DefaultResampleWidth,DefaultResampleWidth);
return true;
}
bool ThumbNail::setImage(const String &strPathFileName)
{
mImage.decode(strPathFileName);
if(!mImage.getRGBArray().size())return false;
mStrPathFileName=strPathFileName;
mImage.resample(DefaultResampleWidth,DefaultResampleWidth);
return true;
}
bool ThumbNail::draw(PureDevice &pureDevice,const Point &xyPoint)
{
if(!isOkay())return false;
pureDevice.line(xyPoint,Point(xyPoint.x()+width(),xyPoint.y()),light());
pureDevice.line(xyPoint,Point(xyPoint.x(),xyPoint.y()+height()),light());
pureDevice.line(Point(xyPoint.x()+width(),xyPoint.y()),Point(xyPoint.x()+width(),xyPoint.y()+height()),dark());
pureDevice.line(Point(xyPoint.x(),xyPoint.y()+height()),Point(xyPoint.x()+width(),xyPoint.y()+height()),dark());
mImage.stretch(pureDevice,Point(xyPoint.x()+OffsetImage,xyPoint.y()+OffsetImage),DefaultResampleWidth,DefaultResampleWidth-BottomBorderHeight);
return true;
}