BorderRemove example for C++ Builder
// add this to Form Private Section.
private: // User declarations
HRGN hRgnAll ;
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int nRet;
//Border Remove
//This example updates a region with the borders of a bitmap
//For the example, windows regions are passed to the OnBorderRemove Event and combined.
//In practice it would be easier and faster to just update a LEAD region representing the changes
//The border is removed from the image
//Create a NULL region
hRgnAll = CreateRectRgn(0, 0, 0, 0);
nRet = LEADImage1->BorderRemove(BORDER_CALLBACK_REGION | BORDER_USE_VARIANCE,
BORDER_TOP | BORDER_BOTTOM | BORDER_LEFT | BORDER_RIGHT, 20, 2, 5);
if ((nRet == SUCCESS) )
{
LEADImage1->FreeRgn ();
LEADImage1->SetRgnHandle ((int)hRgnAll, 0, 0, L_RGN_SET);
LEADImage1->RgnFrameType = ftAnimated;
}
//delete the Windows Rgn
DeleteObject(hRgnAll);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::LEADImage1BorderRemove (TObject *Sender,
L_HRGN hBorderRgn, int uBorderToRemove, int nBoundingRectLeft,
int nBoundingRectTop, int nBoundingRectWidth,
int nBoundingRectHeight)
{
char * szBorder;
char crOut[256];
CombineRgn((HRGN)hRgnAll,(HRGN)hRgnAll, (HRGN)hBorderRgn, RGN_OR);
switch(uBorderToRemove)
{
case BORDER_TOP:
szBorder = "Top";
break;
case BORDER_LEFT:
szBorder = "Left";
break;
case BORDER_RIGHT:
szBorder = "Right";
break;
case BORDER_BOTTOM:
szBorder = "Bottom";
break;
}
wsprintf(crOut,"Border - %s Bounds:%d,%d,%d,%d",
szBorder,
nBoundingRectLeft,
nBoundingRectTop,
nBoundingRectWidth,
nBoundingRectHeight);
OutputDebugString(crOut);
LEADImage1->DocCleanSuccess = SUCCESS_REMOVE;
}