DocCleanSuccess 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 updates a region with all 1x1 to 3x3 specks that are solid black
If a speck has any white pixels, it is NOT part of the updated region
The call is configured to update a single LEAD region with all changes
The image itself is unchanged
The DotRemove Event is used to display information about each speck that is removed*/
void __fastcall TForm1::Button2Click(TObject *Sender)
{
int nRet;
pRasterProc->EnableDocCleanEvents = true;
nRet = pRasterProc->DotRemove (LEADRasterView1->Raster, (DotRemoveFlags)(DOT_USE_SIZE + DOT_SINGLE_REGION + DOT_LEAD_REGION + DOT_IMAGE_UNCHANGED), 1, 1, 3, 3);
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_DOTREMOVE:
{
float fBoundingRectLeft;
float fBoundingRectTop;
float fBoundingRectWidth;
float fBoundingRectHeight;
int iWhiteCount;
int iBlackCount;
char szTemp[256];
fBoundingRectLeft= OleVariant(Params.rgvarg[5]);
fBoundingRectTop= OleVariant(Params.rgvarg[4]);
fBoundingRectWidth= OleVariant(Params.rgvarg[3]);
fBoundingRectHeight= OleVariant(Params.rgvarg[2]);
iWhiteCount= OleVariant(Params.rgvarg[1]);
iBlackCount= OleVariant(Params.rgvarg[0]);
sprintf(szTemp,"Dot Found at %f,%f,%f,%f WhiteCount= %d BlackCount= %d",
fBoundingRectLeft,
fBoundingRectTop,
fBoundingRectWidth,
fBoundingRectHeight,
iWhiteCount,
iBlackCount);
OutputDebugString(szTemp);
// Do not remove the speck if it contains any white pixels
pRasterProc->DocCleanSuccess = (iWhiteCount > 0) ? SUCCESS_NOREMOVE : SUCCESS_REMOVE;
}
break;
}
}