InvertedText example for Delphi
var
RasterProc: LEADRasterProcess;
procedure TForm1.Button1Click(Sender: TObject);
begin
RasterProc:= CreateComObject (CLASS_LEADRasterProcess) as LEADRasterProcess;
LEADEventSink1.Connect (RasterProc, _LEADRasterProcessEvents);
LEADRasterView1.Raster.UnlockSupport (L_SUPPORT_DOCUMENT, 'TestKey');
end;
procedure TForm1.Button2Click(Sender: TObject);
var
nRet: Integer;
begin
//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
RasterProc.EnableDocCleanEvents:= True;
nRet:= RasterProc.InvertedText (LEADRasterView1.Raster, INVERTEDTEXT_SINGLE_REGION Or INVERTEDTEXT_LEAD_REGION Or INVERTEDTEXT_USE_DPI, 5000, 500, 70, 95);
if (nRet = 0) then
LEADRasterView1.RgnFrameType:= RGNFRAME_COLOR;
end;
procedure TForm1. LEADEventSink1Invoke(Sender: TObject; DispID: Integer;
const IID: TGUID; LocaleID: Integer; Flags: Word; Params: tagDISPPARAMS;
varResult, ExcepInfo, ArgErr: Pointer);
var
fBoundingRectLeft: Single;
fBoundingRectTop: Single;
fBoundingRectWidth: Single;
fBoundingRectHeight: Single;
iWhiteCount: Longint;
iBlackCount: Longint;
begin
case (DispID) of
LEADRASTERPROCESSEVENTS_INVERTEDTEXT:
begin
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]);
OutputDebugString(pChar('Inverted at [Left,Top,Width,Height]' + FloatToStr(fBoundingRectLeft) +','+
FloatToStr(fBoundingRectTop) + ',' + FloatToStr(fBoundingRectWidth) +','+
FloatToStr(fBoundingRectHeight) +' WhiteCount=' +
IntToStr(iWhiteCount) + ' BlackCount= ' +
IntToStr(iBlackCount)));
end;
end;
end;