Initial
This commit is contained in:
112
meshwrp/image.cpp
Normal file
112
meshwrp/image.cpp
Normal file
@@ -0,0 +1,112 @@
|
||||
#include <meshwrp/image.hpp>
|
||||
#include <common/crsctrl.hpp>
|
||||
#include <gif/gifbmp.hpp>
|
||||
|
||||
Image::Image()
|
||||
{
|
||||
}
|
||||
|
||||
Image::~Image()
|
||||
{
|
||||
}
|
||||
|
||||
bool Image::open(String strPathFileName,GUIWindow &window)
|
||||
{
|
||||
CursorControl cursorControl;
|
||||
PureDevice pureDevice;
|
||||
bool returnCode=false;
|
||||
|
||||
if(strPathFileName.isNull())return false;
|
||||
strPathFileName.lower();
|
||||
pureDevice=window;
|
||||
cursorControl.waitCursor(true);
|
||||
if(0!=strPathFileName.strstr(".gif"))returnCode=handleOpenGIF(strPathFileName,pureDevice);
|
||||
else if(0!=strPathFileName.strstr(".jpg"))returnCode=handleOpenJPG(strPathFileName,pureDevice);
|
||||
else if(0!=strPathFileName.strstr(".bmp"))returnCode=handleOpenBMP(strPathFileName,pureDevice);
|
||||
cursorControl.waitCursor(false);
|
||||
return returnCode;
|
||||
}
|
||||
|
||||
bool Image::newImage(LONG width,LONG height,GUIWindow &window)
|
||||
{
|
||||
PureDevice pureDevice;
|
||||
|
||||
pureDevice=window;
|
||||
create(width,height,pureDevice);
|
||||
if(!isOkay())return false;
|
||||
for(int row=0;row<DIB24::height();row++)
|
||||
{
|
||||
for(int col=0;col<DIB24::width();col++)
|
||||
{
|
||||
setAt(row,col,RGB888(0,0,0));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Image::handleOpenGIF(const String &strPathFileName,PureDevice &pureDevice)
|
||||
{
|
||||
GIFBitmap gifBitmap;
|
||||
|
||||
if(!gifBitmap.open(strPathFileName))return false;
|
||||
create(gifBitmap.width(),-gifBitmap.height(),pureDevice);
|
||||
PurePalette palette(gifBitmap.getPalette());
|
||||
RGBColor color;
|
||||
for(int row=0;row<gifBitmap.height();row++)
|
||||
{
|
||||
for(int col=0;col<gifBitmap.width();col++)
|
||||
{
|
||||
palette.getPaletteColor(gifBitmap.getByte(row,col),color);
|
||||
setAt(row,col,RGB888(color.red(),color.green(),color.blue()));
|
||||
}
|
||||
}
|
||||
return isOkay();
|
||||
}
|
||||
|
||||
bool Image::handleOpenJPG(const String &strPathFileName,PureDevice &pureDevice)
|
||||
{
|
||||
JPGImage jpgImage;
|
||||
RGB888 rgb888;
|
||||
|
||||
if(!jpgImage.decode(strPathFileName,pureDevice))return false;
|
||||
create(jpgImage.width(),-jpgImage.height(),pureDevice);
|
||||
for(int row=0;row<jpgImage.height();row++)
|
||||
{
|
||||
for(int col=0;col<jpgImage.width();col++)
|
||||
{
|
||||
jpgImage.getAt(row,col,rgb888);
|
||||
setAt(row,col,rgb888);
|
||||
}
|
||||
}
|
||||
return isOkay();
|
||||
}
|
||||
|
||||
bool Image::handleOpenBMP(const String &strPathFileName,PureDevice &pureDevice)
|
||||
{
|
||||
OutputDebugString("Image::handleOpenBMP\n");
|
||||
return isOkay();
|
||||
}
|
||||
|
||||
bool Image::display(GUIWindow &window,const Rect &dstRect,const Point &srcPoint)
|
||||
{
|
||||
PureDevice pureDevice;
|
||||
|
||||
if(!isOkay())return false;
|
||||
pureDevice=window;
|
||||
draw(pureDevice,dstRect,srcPoint);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Image::display(GUIWindow &window)
|
||||
{
|
||||
PureDevice pureDevice;
|
||||
Rect dstRect;
|
||||
|
||||
if(!isOkay())return false;
|
||||
pureDevice=window;
|
||||
dstRect.right(width());
|
||||
dstRect.bottom(height());
|
||||
draw(pureDevice,dstRect,Point());
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user