DocCleanSuccess example for Delphi
var
RasterProc: LEADRasterProcess;
//Create the RasterProcess object and UnlockSupport
procedure TForm1.Button1Click(Sender: TObject);
begin
//.....
RasterProc:= CreateComObject(CLASS_LEADRasterProcess) as LEADRasterProcess;
LEADRasterView1.Raster.UnlockSupport (L_SUPPORT_DOCUMENT, ‘TestKey’);
LEADEventSink1.Connect (RasterProc, _LEADRasterProcessEvents);
//.....
end;
//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
procedure TForm1.Button2Click(Sender: TObject);
var
nRet: Integer;
begin
RasterProc.EnableDocCleanEvents:= True;
nRet:= RasterProc.DotRemove (LEADRasterView1.Raster, DOT_USE_SIZE Or DOT_SINGLE_REGION Or DOT_LEAD_REGION Or DOT_IMAGE_UNCHANGED, 1, 1, 3, 3);
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;
nRet : LongInt;
sOutput : String;
szTemp : array[0..255] of Char;
begin
case (DispID) of
LEADRASTERPROCESSEVENTS_DOTREMOVE:
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]);
sOutput := Format('Dot Found at [Left,Top,Width,Height] %f,%f,%f,%f WhiteCount= %d BlackCount= %d',
[fBoundingRectLeft,
fBoundingRectTop,
fBoundingRectWidth,
fBoundingRectHeight,
iWhiteCount,
iBlackCount]);
OutputDebugString(StrPCopy(szTemp,sOutput));
//Do not remove the speck if it contains any white pixels
if (iWhiteCount > 0) Then
nRet:= SUCCESS_NOREMOVE
else
nRet:= SUCCESS_REMOVE;
RasterProc.DocCleanSuccess:= nRet;
end;
end;
end;