LBitmap::HolePunchRemove
#include "ltwrappr.h"
virtual L_INT LBitmap::HolePunchRemove(pHolePunch)
LPHOLEPUNCH pHolePunch; |
/* pointer to a structure */ |
Finds and removes hole punches. This function is available in the Document/Medical Toolkits.
Parameter |
Description |
pHolePunch |
Pointer to the HOLEPUNCH structure that LEADTOOLS uses to remove hole punches. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
This function detects and removes hole punches that are common in scanned documents.
This function works only on 1-bit black and white images.
Hole punch configurations may consist of 2 or more holes.
If a region is selected, only the selected region will be changed by this function. If no region is selected, the whole image will be processed.
The behavior of this function can be modified by overriding LBitmap::HolePunchRemoveCallback.
This function does not support signed data images. It returns the error code ERROR_SIGNED_DATA_NOT_SUPPORTED if a signed data image is passed to this function.
Required DLLs and Libraries
LTIMG For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
See Also
Functions: |
LBitmap::HolePunchRemoveCallback, LBitmap::Smooth, LBitmap::LineRemove, LBitmap::BorderRemove, LBitmap::DotRemove, LBitmap::InvertedText |
Topics: |
Example
//This example updates a Windows region with removed hole punches
//For the example, a Windows region is updated and then converted to a LEAD region
//but in practice it would easier and faster to just return a LEAD region
//The HOLEPUNCH_USE_DPI flag instructs the API to determine the size of the hole punches
// based on the image DPI
//The image is modified
//The derived class LMyBitmap is used to override the HolePunchRemoveCallBack function
//The callback member function is used to display information about each hole punch removed
//The callback member function does NOT receive a Windows region
void CCleanv12Dlg::OnButtonHolepunch()
{
L_INT32 nRet;
HOLEPUNCH hr;
hr.uStructSize = sizeof(HOLEPUNCH);
hr.iLocation = HOLEPUNCH_LEFT;
hr.iMinHoleCount = 2;
hr.iMaxHoleCount = 4;
hr.uFlags = HOLEPUNCH_SINGLE_REGION | HOLEPUNCH_USE_DPI | HOLEPUNCH_USE_COUNT | HOLEPUNCH_USE_LOCATION;
nRet = m_Bitmap.HolePunchRemove(&hr);
if (nRet == SUCCESS)
{
//Delete the existing region
LBitmapRgn Region(&m_Bitmap);
if(Region.BitmapHasRgn())
{
Region.Free();
}
Region.SetRgnCombineMode(L_RGN_SET) ;
Region.SetRgnHandle(hr.hRgn);
DeleteObject(hr.hRgn);
Invalidate();
}
}
L_INT LMyBitmap::HolePunchRemoveCallBack(
HRGN hRgn,
PRECT pBoundingRect,
L_INT32 iHoleIndex,
L_INT32 iHoleTotalCount,
L_INT32 iWhiteCount,
L_INT32 iBlackCount
)
{
CString strMsg;
strMsg.Format (
TEXT("Bounds[%d,%d][%d,%d]\tHole[%d] of [%d]\tWhiteCount[%d]\tBlackCount[%d]\n"),
pBoundingRect->left,
pBoundingRect->top,
pBoundingRect->right,
pBoundingRect->bottom,
iHoleIndex,
iHoleTotalCount,
iWhiteCount,
iBlackCount
);
OutputDebugString(strMsg);
return SUCCESS_REMOVE;
}