L_SmoothBitmap
#include "l_bitmap.h"
L_INT EXT_FUNCTION L_SmoothBitmap(pBitmap, pSmooth, pfnCallback, pUserData)
pBITMAPHANDLE pBitmap; |
/* pointer to the bitmap */ |
LPSMOOTH pSmooth; |
/* pointer to a structure */ |
SMOOTHCALLBACK pfnCallback; |
/* optional callback function */ |
/* pointer to more parameters for the callback */ |
Smooths the bumps and fills in the nicks of a 1-bit black and white image.
This function is available in the Document/Medical Toolkits.``
Parameter |
Description |
pBitmap |
Pointer to the bitmap handle referencing the bitmap to smooth. |
pSmooth |
Pointer to the SMOOTH structure that LEADTOOLS uses to perform the smoothing operation |
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 SMOOTHCALLBACK 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 smooths the text in scanned text documents. The behavior of this function can be modified by using its callback.
This function works only on 1-bit black and white images.
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: |
SMOOTHCALLBACK, L_LineRemoveBitmap, L_BorderRemoveBitmap, L_InvertedTextBitmap, L_DotRemoveBitmap, L_HolePunchRemoveBitmap, L_HolesRemovalBitmapRgn |
Topics: |
Example
//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 returned showing all the changes
//A callback is used to display information about bump or nick
//The callback does NOT return a region
L_INT L_EXPORT EXT_CALLBACK ExampleSmoothCB(
L_UINT32 uBumpOrNick,
L_INT32 iStartRow,
L_INT32 iStartCol,
L_INT32 iLength,
L_UINT32 uHorV,
L_VOID L_FAR *pUserData
)
{
L_TCHAR szMsg[200];
L_TCHAR L_FAR* pszBumpOrNick, *pszHorV;
switch (uBumpOrNick)
{
case SMOOTH_BUMP:
pszBumpOrNick = TEXT("Bump");
break;
case SMOOTH_NICK:
pszBumpOrNick = TEXT("Nick");
break;
}
if (uHorV == SMOOTH_HORIZONTAL_ELEMENT)
{
pszHorV = TEXT("Horizontal");
}
else
{
pszHorV = TEXT("Vertical");
}
//Note: no hRgn to delete because it was not requested
wsprintf(
szMsg,
TEXT("Type[%s]\tRow Col[%d, %d]\tLength[%d]\t[%s]\n"),
pszBumpOrNick,
iStartRow,
iStartCol,
iLength,
pszHorV);
OutputDebugString(szMsg);
return SUCCESS_REMOVE;
}
L_VOID ExampleSmooth(pBITMAPHANDLE pBitmap)
{
L_INT32 nRet;
BITMAPHANDLE BitmapRegion;
SMOOTH sm;
memset(&BitmapRegion, 0, sizeof(BITMAPHANDLE));
sm.uStructSize = sizeof(SMOOTH);
sm.iLength = 2;
sm.pBitmapRegion = &BitmapRegion;
sm.uFlags = SMOOTH_SINGLE_REGION | SMOOTH_LEAD_REGION | SMOOTH_FAVOR_LONG;
nRet = L_SmoothBitmap(
pBitmap,
&sm,
(SMOOTHCALLBACK)(ExampleSmoothCB),
NULL
);
if (nRet == SUCCESS)
{
RECT rectRgn;
//Delete the existing region
L_FreeBitmapRgn(pBitmap);
L_GetBitmapRgnBounds(sm.pBitmapRegion, NULL, &rectRgn);
if (!IsRectEmpty(&rectRgn))
{
L_CopyBitmapHandle(pBitmap, sm.pBitmapRegion, sizeof(BITMAPHANDLE));
}
}
}