InvertedText example for C++ Builder
LEADRasterProcess * pRasterProc= NULL;
void __fastcall TForm1::Button1Click(TObject *Sender)
{
CoCreateInstance(CLSID_LEADRasterProcess, NULL, CLSCTX_ALL, IID_ILEADRasterProcess, (void**)&pRasterProc);
LEADEventSink1->Connect (pRasterProc, DIID__LEADRasterProcessEvents);
LEADRasterView1->Raster->UnlockSupport (L_SUPPORT_DOCUMENT, AnsiToOLESTR("TestKey"));
}
void __fastcall TForm1::FormClose(TObject *Sender, TCloseAction &Action)
{
if(pRasterProc)
pRasterProc->Release();
}
void __fastcall TForm1::Button2Click(TObject *Sender)
{
int nRet;
//InvertedText
//This example finds all inverted text regions greater than 5 inches in width and 1/2 inch in height
//and inverts the text so that it appears normal
//The InvertedText Event is used to display additional information about the inverted text regions
//A LEAD region is updated to show all of the changes
pRasterProc->EnableDocCleanEvents = True;
nRet= pRasterProc->InvertedText (LEADRasterView1->Raster, (InvertedTextFlags)(INVERTEDTEXT_SINGLE_REGION + INVERTEDTEXT_LEAD_REGION + INVERTEDTEXT_USE_DPI), 5000, 500, 70, 95);
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_INVERTEDTEXT:
{
float fBoundingRectLeft= (OleVariant)(Params.rgvarg[5]);
float fBoundingRectTop= (OleVariant)(Params.rgvarg[4]);
float fBoundingRectWidth= (OleVariant)(Params.rgvarg[3]);
float fBoundingRectHeight= (OleVariant)(Params.rgvarg[2]);
int iWhiteCount= (OleVariant)(Params.rgvarg[1]);
int iBlackCount= (OleVariant)(Params.rgvarg[0]);
AnsiString strTemp;
strTemp = "Inverted at [Left,Top,Width,Height]" + FloatToStr(fBoundingRectLeft) +","+
FloatToStr(fBoundingRectTop) + "," + FloatToStr(fBoundingRectWidth) +","+
FloatToStr(fBoundingRectHeight) +" WhiteCount=" +
IntToStr(iWhiteCount) + " BlackCount= " +
IntToStr(iBlackCount);
OutputDebugString(strTemp.c_str());
}
break;
}
}