Available in the LEADTOOLS Imaging toolkit. |
DocCleanSuccess example for C++ 4.0 and later
short nRet;
//This example updates a region with 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 corresponding to all changes
//The image itself is unchanged
//The DotRemove Event is used to display information about each speck that is removed
nRet = m_LEAD1.DotRemove(DOT_USE_SIZE | DOT_SINGLE_REGION | DOT_LEAD_REGION | DOT_IMAGE_UNCHANGED, 1, 1, 3, 3);
if(nRet == 0)
{
m_LEAD1.FreeRgn();
m_LEAD2.SetBitmap(m_LEAD1.GetDocCleanBitmap()); //copy the result so we can get the rgn handle
m_LEAD1.SetRgnHandle(m_LEAD2.GetRgnHandle(), 0.0f, 0.0f, L_RGN_SET);
m_LEAD2.SetBitmap(0); //no longer need copy
m_LEAD1.SetDocCleanBitmap(0); //no longer need rgn either
m_LEAD1.SetRgnFrameType(RGNFRAME_COLOR);
}
void CDoccleanDlg::OnDotRemoveLeadctrl1(long hRgn, float fBoundingRectLeft, float fBoundingRectTop, float fBoundingRectWidth, float fBoundingRectHeight, long iWhiteCount, long iBlackCount)
{
long nRet;
CString csOut;
csOut.Format("Dot Fount at %d, %d, %d, %d, WhiteCount=%d BlackCount=%d\n",
(long)fBoundingRectLeft,
(long)fBoundingRectTop,
(long)fBoundingRectWidth,
(long)fBoundingRectHeight,
iWhiteCount,
iBlackCount);
OutputDebugString(csOut);
//Do not remove the speck if it contains any white pixels
if(iWhiteCount > 0)
nRet = SUCCESS_NOREMOVE;
else
nRet = SUCCESS_REMOVE;
m_LEAD1.SetDocCleanSuccess(nRet);
}