Smooth example for C++ Builder
LEADRasterProcess * pRasterProc= NULL;
//Create the RasterProcess object and UnlockSupport
void __fastcall TForm1::Button1Click(TObject *Sender)
{
//.....
CoCreateInstance(CLSID_LEADRasterProcess, NULL, CLSCTX_ALL, IID_ILEADRasterProcess, (void**)&pRasterProc);
LEADRasterView1->Raster->UnlockSupport (L_SUPPORT_DOCUMENT, AnsiToOLESTR("TestKey"));
LEADEventSink1->Connect (pRasterProc, DIID__LEADRasterProcessEvents);
//.....
}
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
if(pRasterProc)
pRasterProc->Release();
}
/*This example smooths all nicks and bumps up to 2 pixels in length
Long bumps/nicks are treated before short bumps/nicks
A LEAD region is updated to show all the changes
The Smooth Event is used to display information about bump or nick*/
void __fastcall TForm1::Button2Click(TObject *Sender)
{
int nRet;
pRasterProc->EnableDocCleanEvents = True;
pRasterProc->DocCleanSuccess = SUCCESS_REMOVE;
nRet= pRasterProc->Smooth (LEADRasterView1->Raster, 2, (SmoothFlags)(SMOOTH_SINGLE_REGION + SMOOTH_LEAD_REGION + SMOOTH_FAVOR_LONG));
if (nRet == 0)
LEADRasterView1->RgnFrameType = RGNFRAME_COLOR;
}
void __fastcall TForm1:: LEADEventSink1Invoke(TObject *Sender, int DispID,
const TGUID &IID, int LocaleID, WORD Flags, tagDISPPARAMS &Params,
Pointer varResult, Pointer ExcepInfo, Pointer ArgErr)
{
switch (DispID)
{
case LEADRASTERPROCESSEVENTS_SMOOTH:
{
int nBumpOrNick;
float fStartRow;
float fStartCol;
float fLength;
int uHorV;
char * szType;
char * szHorV;
char szTemp[256];
nBumpOrNick= OleVariant(Params.rgvarg[4]);
fStartRow= OleVariant(Params.rgvarg[3]);
fStartCol= OleVariant(Params.rgvarg[2]);
fLength= OleVariant(Params.rgvarg[1]);
uHorV= OleVariant(Params.rgvarg[0]);;
if (nBumpOrNick == SMOOTH_BUMP)
szType = "Bump";
else
szType= "Nick";
if (uHorV == SMOOTH_HORIZONTAL_ELEMENT)
szHorV = "Horz.";
else
szHorV= "Vert.";
sprintf(szTemp,"Fount %s at %f,%f Length %f - %s",
szType,fStartRow,fStartCol,fLength,szHorV);
OutputDebugString(szTemp);
}
break;
}
}