64 lines
2.3 KiB
C++
64 lines
2.3 KiB
C++
#include <boneyard/pureimg.hpp>
|
|
#include <common/purehdc.hpp>
|
|
|
|
bool PureImage::draw(PureDevice &pureDevice)
|
|
{
|
|
PureDevice compatibleDevice;
|
|
if(!isOkay())return FALSE;
|
|
compatibleDevice.compatibleDevice(pureDevice);
|
|
compatibleDevice.select((GDIObj)mhBitmap,TRUE);
|
|
pureDevice.bitBlt(Rect(0,0,width(),height()),compatibleDevice,Point(0,0));
|
|
compatibleDevice.select((GDIObj)mhBitmap,FALSE);
|
|
return TRUE;
|
|
}
|
|
|
|
bool PureImage::draw(PureDevice &pureDevice,int xSrc,int ySrc)
|
|
{
|
|
PureDevice compatibleDevice;
|
|
if(!isOkay())return FALSE;
|
|
compatibleDevice.compatibleDevice(pureDevice);
|
|
compatibleDevice.select((GDIObj)mhBitmap,TRUE);
|
|
pureDevice.bitBlt(Rect(xSrc,ySrc,width(),height()),compatibleDevice,Point(0,0));
|
|
compatibleDevice.select((GDIObj)mhBitmap,FALSE);
|
|
return TRUE;
|
|
}
|
|
|
|
bool PureImage::draw(PureDevice &pureDevice,const Rect &dstRect,const Point &srcPoint)
|
|
{
|
|
PureDevice compatibleDevice;
|
|
if(!isOkay())return FALSE;
|
|
compatibleDevice.compatibleDevice(pureDevice);
|
|
compatibleDevice.select((GDIObj)mhBitmap,TRUE);
|
|
pureDevice.bitBlt(dstRect,compatibleDevice,srcPoint);
|
|
compatibleDevice.select((GDIObj)mhBitmap,FALSE);
|
|
return TRUE;
|
|
}
|
|
|
|
bool PureImage::stretch(PureDevice &pureDevice,const Point &xyPoint,int strwidth,int strheight)
|
|
{
|
|
PureDevice compatibleDevice;
|
|
if(!isOkay())return FALSE;
|
|
compatibleDevice.compatibleDevice(pureDevice);
|
|
compatibleDevice.select((GDIObj)mhBitmap,TRUE);
|
|
pureDevice.stretchBlt(Rect(xyPoint.x(),xyPoint.y(),strwidth,strheight),compatibleDevice,Rect(0,0,width(),height()));
|
|
compatibleDevice.select((GDIObj)mhBitmap,FALSE);
|
|
return FALSE;
|
|
}
|
|
|
|
|
|
// ::SetDIBitsToDevice(displayDevice,0,0,640,480,0,0,startScanLine,pureBitmap.height(),&bitmapBytes[0],(BITMAPINFO*)bmInfo,DIB_RGB_COLORS);
|
|
// ::StretchDIBits(displayDevice,0,0,windowWidth,windowHeight,0,0,pureBitmap.width(),pureBitmap.height(),&bitmapBytes[0],(BITMAPINFO*)bmInfo,DIB_RGB_COLORS,SRCCOPY);
|
|
|
|
bool PureImage::decode(BitmapInfo &bitmapInfo,GlobalData<BYTE> &bitmapBytes,PureDevice pureDevice)
|
|
{
|
|
destroy();
|
|
if(bitmapInfo.bitCount()!=BitmapInfo::Bit24)return false;
|
|
getBitmapInfo()=bitmapInfo;
|
|
getBitmapInfo().colorUsed(0);
|
|
getBitmapInfo().colorImportant(0);
|
|
mhBitmap=::CreateDIBitmap((HDC)pureDevice,(BITMAPINFOHEADER*)getBitmapInfo(),CBM_INIT,&bitmapBytes[0],(BITMAPINFO*)getBitmapInfo(),DIB_RGB_COLORS);
|
|
return isOkay();
|
|
}
|
|
|
|
|