#include #include #include #ifndef M_PI #define M_PI 3.14159265358979323846 #endif Convex::Convex() : mIsInThread(TRUE) { } Convex::~Convex() { } HGLOBAL Convex::performConvex(WORD &width,WORD &height,UHUGE *lpImage) { HGLOBAL hGlobalSource; HGLOBAL hGlobalImage; UHUGE *ptrSource; UHUGE *ptrImage; POINT tempPoint; double scaleFactor; double tempFactor; mWidth=width; mHeight=height; mxHalf=mWidth/2; myHalf=mHeight/2; if(!lpImage)return 0; hGlobalSource=Main::upsideDown(width,height,lpImage); ptrSource=(UHUGE*)::GlobalLock(hGlobalSource); hGlobalImage=::GlobalAlloc(GMEM_FIXED,(LONG)width*(LONG)height); ptrImage=(UHUGE *)::GlobalLock(hGlobalImage); Main::hmemset(ptrImage,0,(LONG)width*(LONG)height); for(int y=0;y=width)continue; if(tempPoint.y>=height)continue; *(ptrImage+((LONG)tempPoint.y*(LONG)width)+(LONG)tempPoint.x)= *(ptrSource+((LONG)y*(LONG)width)+(LONG)x); if(!yieldTask())return emergencyCleanup(hGlobalSource,hGlobalImage); } } ::GlobalUnlock(hGlobalSource); ::GlobalFree(hGlobalSource); hGlobalSource=Main::upsideDown(width,height,ptrImage); ::GlobalUnlock(hGlobalImage); ::GlobalFree(hGlobalImage); return hGlobalSource; } WORD Convex::yieldTask(void)const { MSG msg; while(::PeekMessage((MSG far *)&msg,0,0,0,PM_REMOVE)) { ::TranslateMessage(&msg); ::DispatchMessage(&msg); } return mIsInThread; } HGLOBAL Convex::emergencyCleanup(HGLOBAL hGlobalSource,HGLOBAL hGlobal)const { ::GlobalUnlock(hGlobalSource); ::GlobalFree(hGlobalSource); ::GlobalUnlock(hGlobal); ::GlobalFree(hGlobal); return FALSE; }