#include bool DIB24::create(int width,int height,PureDevice &pureDevice) { destroy(); if(!width||!height||!pureDevice.isOkay())return false; mBitmapInfo.rgbColors(0); mBitmapInfo.bitCount(BitmapInfo::Bit24); mBitmapInfo.width(width); mBitmapInfo.height(height); mBitmapInfo.planes(1); mBitmapInfo.compression(BI_RGB); mBitmapInfo.sizeImage(0); mBitmapInfo.colorUsed(0); mBitmapInfo.colorImportant(0); verifyDimensions(mBitmapInfo); mExtent=mBitmapInfo.width()*(mBitmapInfo.height()<0?-mBitmapInfo.height():mBitmapInfo.height()); mhBitmap=::CreateDIBSection((HDC)pureDevice,(BITMAPINFO*)mBitmapInfo,DIB_RGB_COLORS,(void**)&mpRGBArray,0,0); return isOkay(); } bool DIB24::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; } void DIB24::verifyDimensions(BitmapInfo &someBitmapInfo) { DWORD desiredHeight(someBitmapInfo.height()<0?-someBitmapInfo.height():someBitmapInfo.height()); DWORD desiredWidth(someBitmapInfo.width()); DWORD imageExtent; imageExtent=(((((LONG)desiredWidth*8)+31)&~31)>>3)*(LONG)desiredHeight; if(imageExtent==(LONG)desiredWidth*(LONG)desiredHeight)return; else desiredWidth=(WORD)(imageExtent/(LONG)desiredHeight); someBitmapInfo.width(desiredWidth); } bool DIB24::setAt(DWORD row,DWORD col,JPGImage &jpgImage) { DWORD srcWidth; DWORD srcHeight; DWORD dstWidth; DWORD dstHeight; RGB888 *ptrSrcCol; RGB888 *ptrDstCol; if(!isOkay())return false; srcWidth=jpgImage.width(); srcHeight=jpgImage.height(); dstWidth=mBitmapInfo.width(); dstHeight=mBitmapInfo.height()<0?-mBitmapInfo.height():mBitmapInfo.height(); for(int srcRow=0,dstRow=row;srcRow