Available in the LEADTOOLS Imaging toolkit. |
DocCleanBitmap example for C++ 4.0 and later
short nRet;
//Smooth
//This example smooths all nicks and bumps up to 2 pixels in length
//Long bumps/nicks are treated before short bumps/nicks
//A LEAD region is updated to show all the changes
//The Smooth Event is used to display information about bump or nick
m_LEAD1.SetDocCleanSuccess(SUCCESS_REMOVE);
nRet = m_LEAD1.Smooth(2, SMOOTH_SINGLE_REGION |
SMOOTH_LEAD_REGION | SMOOTH_FAVOR_LONG);
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::OnSmoothLeadctrl1(long nBumpOrNick, long nStartRow, long nStartCol, long nLength, long uHorV)
{
CString szType;
CString szHorV;
CString szOut;
if(nBumpOrNick == SMOOTH_BUMP)
szType = "Bump";
else
szType = "Nick";
if(uHorV == SMOOTH_HORIZONTAL_ELEMENT)
szHorV = "Horz.";
else
szHorV = "Vert.";
szOut.Format("Found %s at %d,%d Length=%d Type=%s\n", szType, nStartRow, nStartCol, nLength, szHorV);
OutputDebugString(szOut);
}