hDocCleanRgn 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::Button2Click(TObject *Sender)
{
int nRet;
/*HolePunch Remove
This example updates a windows region with all removed hole punches
For the example, a windows region is updated and then converted to a LEAD region
but in practice it would easier and faster to just update a LEAD region
The HOLEPUNCH_USE_DPI flag instructs the API to determine the size of the hole punches
based on the image DPI
The image is modified
The HolePunch Event is used to display information about each hole punch removed*/
pRasterProc->EnableDocCleanEvents = True;
nRet= pRasterProc->HolePunchRemove (LEADRasterView1->Raster,
(HolePunchRemoveFlags)(HOLEPUNCH_SINGLE_REGION + HOLEPUNCH_USE_DPI + HOLEPUNCH_USE_COUNT + HOLEPUNCH_USE_LOCATION),
2, 4, 0, 0, 0, 0, HOLEPUNCH_LEFT);
if (nRet == 0)
{
LEADRasterView1->Raster->FreeRgn ( ) ;
LEADRasterView1->Raster->SetRgnHandle ( pRasterProc->hDocCleanRgn, 0, 0, L_RGN_SET);
pRasterProc->hDocCleanRgn= 0; //no longer need rgn
LEADRasterView1->RgnFrameType = RGNFRAME_COLOR;
}
}
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
if(pRasterProc)
pRasterProc->Release();
}
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_HOLEPUNCHREMOVE:
{
float fBoundingRectLeft= (OleVariant)(Params.rgvarg[7]);
float fBoundingRectTop= (OleVariant)(Params.rgvarg[6]);
float fBoundingRectWidth= (OleVariant)(Params.rgvarg[5]);
float fBoundingRectHeight= (OleVariant)(Params.rgvarg[4]);
int iHoleIndex= (OleVariant)(Params.rgvarg[3]);
int iHoleTotalCount= (OleVariant)(Params.rgvarg[2]);
int iWhiteCount= (OleVariant)(Params.rgvarg[1]);
int iBlackCount= (OleVariant)(Params.rgvarg[0]);
char szTemp[256];
sprintf(szTemp,"HolePunch at [Left,Top,Width,Height] %f,%f,%f,%f HoleIndex= %d TotalCount= %d WhiteCount= %d BlackCount= %d",
fBoundingRectLeft, fBoundingRectTop, fBoundingRectWidth, fBoundingRectHeight, iHoleIndex,
iHoleTotalCount, iWhiteCount, iBlackCount);
OutputDebugString (szTemp);
}
break;
}
}