DocCleanSuccess example for Delphi
procedure TForm1.Button3Click(Sender: TObject);
var
nRet : Integer;
begin
{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}
nRet := LEADImage1.DotRemove (DOT_USE_SIZE Or DOT_SINGLE_REGION Or DOT_LEAD_REGION Or DOT_IMAGE_UNCHANGED, 1, 1, 3, 3);
if (nRet = SUCCESS) then
begin
LEADImage1.FreeRgn;
LEADImage2.Bitmap := LEADImage1.DocCleanBitmap; {copy the result so we can get the rgn handle}
LEADImage1.SetRgnHandle (LEADImage2.GetRgnHandle, 0, 0, L_RGN_SET);
LEADImage2.Bitmap := 0; {no longer need copy}
LEADImage1.DocCleanBitmap := 0; {no longer need rgn either}
LEADImage1.RgnFrameType := ftAnimated;
end;
end;
procedure TForm1.LEADImage1DotRemove (Sender: TObject; hDotRgn: L_HRGN;
nBoundingRectLeft, nBoundingRectTop, nBoundingRectWidth,
nBoundingRectHeight, iWhiteCount, iBlackCount: Integer);
var
nRet : LongInt;
sOutput : String;
szTemp : array[0..255] of Char;
begin
sOutput := Format('Dot Found at %d,%d,%d,%d WhiteCount= %d BlackCount= %d',
[nBoundingRectLeft,
nBoundingRectTop,
nBoundingRectWidth,
nBoundingRectHeight,
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;
LEADImage1.DocCleanSuccess := nRet
end;