L_HolePunchRemoveBitmap
#include "l_bitmap.h"
L_INT EXT_FUNCTION L_HolePunchRemoveBitmap(pBitmap, pHolePunch, pfnCallback, pUserData)
pBITMAPHANDLE pBitmap; |
/* pointer to the bitmap */ |
LPHOLEPUNCH pHolePunch; |
/* pointer to a structure */ |
HOLEPUNCHREMOVECALLBACK pfnCallback; |
/* optional callback function */ |
/* pointer to more parameters for the callback */ |
Finds and removes hole punches. This function is available in the Document/Medical Toolkits.
Parameter |
Description |
pBitmap |
Pointer to the bitmap handle referencing the bitmap from which to remove hole punches. |
pHolePunch |
Pointer to the HOLEPUNCH structure that LEADTOOLS uses to remove hole punches. |
pfnCallback |
Optional callback function for additional processing. |
|
If you do not provide a callback function, use NULL as the value of this parameter. |
|
If you do provide a callback function, use the function pointer as the value of this parameter. |
|
The callback function must adhere to the function prototype described in HOLEPUNCHREMOVECALLBACK Function. |
pUserData |
Void pointer that you can use to pass one or more additional parameters that the callback function needs. |
|
To use this feature, assign a value to a variable or create a structure that contains as many fields as you need. Then, in this parameter, pass the address of the variable or structure, casting it to L_VOID L_FAR *. The callback function, which receives the address in its own pUserData parameter, can cast it to a pointer of the appropriate data type to access your variable or structure. |
|
If the additional parameters are not needed, you can pass NULL in this parameter. |
Returns
SUCCESS |
The function was successful. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
(Document) This function detects and removes hole punches that are common in scanned documents. The behavior of this function can be modified by using its callback.
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.
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. |
Platforms
Windows 95 / 98 / Me, Windows 2000 / XP.
See Also
Functions: |
HOLEPUNCHREMOVECALLBACK, L_SmoothBitmap, L_LineRemoveBitmap, L_BorderRemoveBitmap, L_DotRemoveBitmap, L_InvertedTextBitmap, L_HolesRemovalBitmapRgn |
Topics: |
Example
//HolePunch Remove
//This example returns a windows region corresponding to hole punches
//For the example, a windows region is returned and 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
//A callback is used to display information about each hole punch removed.
//The callback does NOT return a region
L_INT L_EXPORT EXT_CALLBACK ExampleHolePunchRemoveCB
(
HRGN hRgn,
PRECT pBoundingRect,
L_INT32 iHoleIndex,
L_INT32 iHoleTotalCount,
L_INT32 iWhiteCount,
L_INT32 iBlackCount,
L_VOID L_FAR *pUserData
)
{
L_TCHAR szMsg[200];
wsprintf(
szMsg,
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(szMsg);
return SUCCESS_REMOVE;
}
L_VOID ExampleHolePunchRemove(pBITMAPHANDLE pBitmap)
{
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 = L_HolePunchRemoveBitmap(
pBitmap,
&hr,
(HOLEPUNCHREMOVECALLBACK)(ExampleHolePunchRemoveCB),
NULL
);
if (nRet == SUCCESS)
{
RECT rectRgn;
GetRgnBox(hr.hRgn, &rectRgn);
if (!IsRectEmpty(&rectRgn))
{
L_SetBitmapRgnHandle(pBitmap, NULL, hr.hRgn, L_RGN_SET);
DeleteObject(hr.hRgn);
hr.hRgn = NULL;
}
}
}