#include #include #include #include #include #include void DIBitmap::createBitmap(const PureDevice &somePureDevice) { destroyBitmap(); mhBitmap=::CreateDIBSection(somePureDevice,(BITMAPINFO*)(static_cast(*this)),DIB_RGB_COLORS,&mlpBmBits,(HANDLE)0,0L); if(!mhBitmap)::GetLastError(); if(mhBitmap)mImageExtent=BitmapInfo::imageExtent(); } void DIBitmap::createBitmap(void) { destroyBitmap(); mhBitmap=::CreateDIBSection((HDC)0,(BITMAPINFO*)(static_cast(*this)),DIB_RGB_COLORS,&mlpBmBits,(HANDLE)0,0L); if(mhBitmap)mImageExtent=BitmapInfo::imageExtent(); } WORD DIBitmap::size(DWORD newWidth,DWORD newHeight) { if(!isOkay())return FALSE; verifyDimensions(newWidth,newHeight); width(newWidth); height(newHeight); createBitmap(mBitmapDevice); mBitmapDevice.select(mhBitmap); return isOkay(); } void DIBitmap::verifyDimensions(DWORD &desiredWidth,DWORD desiredHeight)const { DWORD imageExtent; imageExtent=(((((LONG)desiredWidth*8)+31)&~31)>>3)*(LONG)desiredHeight; if(imageExtent==(LONG)desiredWidth*(LONG)desiredHeight)return; desiredWidth=(WORD)(imageExtent/(LONG)desiredHeight); } void DIBitmap::setBits(BYTE charByte) { if(!charByte)clearBits(); BYTE *lpImagePtr=(BYTE*)mlpBmBits; for(DWORD ptrIndex=0;ptrIndex>2; DWORD numBytes=0; int *ptrSrcDataInt=0; int *ptrDstDataInt=0; char *ptrSrcDataChar; char *ptrDstDataChar; if(!writeExtent)return false; numBytes=(writeExtent%writeExtent); ptrSrcDataInt=(int*)ptrDataChar; ptrDstDataInt=(int*)mlpBmBits; for(DWORD count=0;count &bitmap,const Rect &areaRect) { bitmap.destroy(); bitmap=::new DIBitmap(getDevice(),areaRect.width(),areaRect.height(),getPalette()); bitmap.disposition(PointerDisposition::Delete); for(int col=areaRect.left(),dstCol=0;col<=areaRect.right();col++,dstCol++) { for(int row=areaRect.top(),dstRow=0;row<=areaRect.bottom();row++,dstRow++) { bitmap->setByte(dstRow,dstCol,getByte(row,col)); } } return true; } bool DIBitmap::overlay(Bitmap &bitmap,const Point &placementPoint) { return overlay(placementPoint,bitmap.width(),bitmap.height(),bitmap.getDataPtr()); } bool DIBitmap::overlay(ResBitmap &resBitmap,const Point &placementPoint) { return overlay(placementPoint,resBitmap.width(),resBitmap.height(),resBitmap.ptrData()); } bool DIBitmap::overlay(DIBitmap &bitmap,const Point &placementPoint) { return overlay(placementPoint,bitmap.width(),bitmap.height(),(unsigned char*)bitmap.ptrData()); } bool DIBitmap::overlay(const Point &placementPoint,int srcWidth,int srcHeight,UCHAR *pBmBits) { DWORD newSrcY; DWORD newDstY; DWORD srcIndex; DWORD dstIndex; UINT srcRow; UINT srcCol; if(!isOkay())return false; if(srcWidth>width())srcWidth=width(); if(srcHeight>height())srcHeight=height(); for(srcRow=0;srcRow>0x10,xRunning>>0x10,byteValue); xRunning-=xDelta; yRunning-=yDelta; } } else if(-1==xDir&&1==yDir) { for(short stepIndex=0;stepIndex>0x10,xRunning>>0x10,byteValue); xRunning-=xDelta; yRunning+=yDelta; } } else if(1==xDir&&-1==yDir) { for(short itemIndex=0;itemIndex>0x10,xRunning>>0x10,byteValue); xRunning+=xDelta; yRunning-=yDelta; } } else if(1==xDir&&1==yDir) { for(short itemIndex=0;itemIndex>0x10,xRunning>>0x10,byteValue); xRunning+=xDelta; yRunning+=yDelta; } } } WORD DIBitmap::square(const Point ¢erPoint,WORD lineLength,BYTE palIndex) { WORD halfLength(lineLength>>0x01); Point topLeft; Point topRight; Point bottomLeft; Point bottomRight; if(!isOkay())return FALSE; topLeft.x(centerPoint.x()-halfLength); topLeft.y(centerPoint.y()-halfLength); topRight.x(centerPoint.x()+halfLength); topRight.y(centerPoint.y()-halfLength); bottomRight.x(centerPoint.x()+halfLength); bottomRight.y(centerPoint.y()+halfLength); bottomLeft.x(centerPoint.x()-halfLength); bottomLeft.y(centerPoint.y()+halfLength); line(topLeft,topRight,palIndex); line(topRight,bottomRight,palIndex); line(bottomRight,bottomLeft,palIndex); line(bottomLeft,topLeft,palIndex); return TRUE; } WORD DIBitmap::circle(WORD aspectValue,const Point &xyPoint,WORD radius,WORD palIndex) { int a(radius); int af; int bf; int b(0); int target(1); int radiusSquared(radius*radius); if(!isOkay())return FALSE; while(a>=b) { b=(int)(Math::sqrt(radiusSquared-(a*a))+.50); int temp(target); target=b; b=temp; while(b