#include #include #include #include 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; } bool PureImage::resample(PureDevice &pureDevice,int newWidth) { Array rgbArray; Array tmpArray; BitmapInfo bitmapInfo; float heightFactor; float aspectRatio; int newHeight; newWidth-=(newWidth%4); // align the width on DWORD boundary if(!isOkay())return false; aspectRatio=(float)width()/(float)height(); newHeight=(float)newWidth/aspectRatio; heightFactor=(float)newHeight/height(); bitmapInfo.rgbColors(0); bitmapInfo.bitCount(BitmapInfo::Bit24); bitmapInfo.width(newWidth); bitmapInfo.height(int((float)getBitmapInfo().height()*heightFactor)); bitmapInfo.planes(1); bitmapInfo.compression(BI_RGB); bitmapInfo.sizeImage(0); bitmapInfo.colorUsed(0); bitmapInfo.colorImportant(0); tmpArray.size(bitmapInfo.width()*height()); for(int row=0;row rgbArray; Array tmpArray; BitmapInfo bitmapInfo; if(!isOkay())return false; bitmapInfo.rgbColors(0); bitmapInfo.bitCount(BitmapInfo::Bit24); bitmapInfo.width(newWidth); bitmapInfo.height(-newHeight); bitmapInfo.planes(1); bitmapInfo.compression(BI_RGB); bitmapInfo.sizeImage(0); bitmapInfo.colorUsed(0); bitmapInfo.colorImportant(0); bitmapInfo.verifyDimensions(); tmpArray.size(bitmapInfo.width()*(height()<0?-height():height())); for(int row=0;row rgbArray; Array tmpArray; BitmapInfo bitmapInfo; if(!getRGBArray().size())return false; bitmapInfo.rgbColors(0); bitmapInfo.bitCount(BitmapInfo::Bit24); bitmapInfo.width(newWidth); bitmapInfo.height(-newHeight); bitmapInfo.planes(1); bitmapInfo.compression(BI_RGB); bitmapInfo.sizeImage(0); bitmapInfo.colorUsed(0); bitmapInfo.colorImportant(0); bitmapInfo.verifyDimensions(); tmpArray.size(bitmapInfo.width()*(height()<0?-height():height())); for(int row=0;row &rawData) { return RawImage::getRawData(rawData); } bool PureImage::setRawData(GlobalData &rawData,PureDevice &pureDevice) { destroy(); if(!RawImage::setRawData(rawData))return false; mhBitmap=::CreateDIBitmap((HDC)pureDevice,(BITMAPINFOHEADER*)getBitmapInfo(),CBM_INIT,&getRGBArray()[0],(BITMAPINFO*)getBitmapInfo(),DIB_RGB_COLORS); return true; }