Available in the LEADTOOLS Imaging toolkit. |
DocCleanSuccess example for Visual Basic
Dim nRet As Integer
'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 = LEAD1.DotRemove(DOT_USE_SIZE Or DOT_SINGLE_REGION Or DOT_LEAD_REGION Or DOT_IMAGE_UNCHANGED, 1, 1, 3, 3)
If (nRet = 0) Then
LEAD1.FreeRgn
LEAD2.Bitmap = LEAD1.DocCleanBitmap 'copy the result so we can get the rgn handle
LEAD1.SetRgnHandle LEAD2.GetRgnHandle, 0, 0, L_RGN_SET
LEAD2.Bitmap = 0 'no longer need copy
LEAD1.DocCleanBitmap = 0 'no longer need rgn either
LEAD1.RgnFrameType = RGNFRAME_COLOR
End If
Private Sub LEAD1_DotRemove(ByVal hRgn As Stdole.OLE_HANDLE, ByVal fBoundingRectLeft As Single, ByVal fBoundingRectTop As Single, ByVal fBoundingRectWidth As Single, ByVal fBoundingRectHeight As Single, ByVal iWhiteCount As Long, ByVal iBlackCount As Long)
Dim nRet As Long
Debug.Print "Dot Found at " & CStr(fBoundingRectLeft) & "," & CStr(fBoundingRectTop) & "," & CStr(fBoundingRectWidth) & "," & CStr(fBoundingRectHeight) & " WhiteCount=" & CStr(iWhiteCount) & " BlackCount=" & CStr(iBlackCount)
'Do not remove the speck if it contains any white pixels
If (iWhiteCount > 0) Then
nRet = SUCCESS_NOREMOVE
Else
nRet = SUCCESS_REMOVE
End If
LEAD1.DocCleanSuccess = nRet
End Sub